blob: 68c9ae3bd37e4a54bd72c15a9dc2411104bc026c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 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
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Jeff Johnson295189b2012-06-20 16:38:30 -070026 */
Kiet Lam842dad02014-02-18 18:44:02 -080027
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/**
32 * \file limSendManagementFrames.c
33 *
34 * \brief Code for preparing and sending 802.11 Management frames
35 *
Kiet Lam842dad02014-02-18 18:44:02 -080036
Jeff Johnson295189b2012-06-20 16:38:30 -070037 *
38 */
39
40#include "sirApi.h"
41#include "aniGlobal.h"
42#include "sirMacProtDef.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070043#include "cfgApi.h"
44#include "utilsApi.h"
45#include "limTypes.h"
46#include "limUtils.h"
47#include "limSecurityUtils.h"
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -070048#include "limPropExtsUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070049#include "dot11f.h"
50#include "limStaHashApi.h"
51#include "schApi.h"
52#include "limSendMessages.h"
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080053#include "limAssocUtils.h"
54#include "limFT.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080055#ifdef WLAN_FEATURE_11W
56#include "wniCfgAp.h"
57#endif
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -080058
Jeff Johnson295189b2012-06-20 16:38:30 -070059#if defined WLAN_FEATURE_VOWIFI
60#include "rrmApi.h"
61#endif
62
Jeff Johnson295189b2012-06-20 16:38:30 -070063#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070064
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053065#define IS_BROADCAST_MAC(x) (((x[0] & x[1] & x[2] & x[3] & x[4] & x[5]) == 0xff) ? 1 : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070066////////////////////////////////////////////////////////////////////////
67
Kalikinkar dhara205da782014-03-21 15:49:32 -070068tSirRetStatus limStripOffExtCapIE(tpAniSirGlobal pMac,
69 tANI_U8 *addIE,
70 tANI_U16 *addnIELen,
71 tANI_U8 *pExtractedExtCapIEBuf )
72{
73 tANI_U8* tempbuf = NULL;
74 tANI_U16 tempLen = 0;
75 int left = *addnIELen;
76 tANI_U8 *ptr = addIE;
77 tANI_U8 elem_id, elem_len;
78
79 if (NULL == addIE)
80 {
81 PELOGE(limLog(pMac, LOG1, FL("NULL addIE pointer"));)
82 return eSIR_IGNORE_IE ;
83 }
84
85 tempbuf = vos_mem_malloc(left);
86 if ( NULL == tempbuf )
87 {
88 PELOGE(limLog(pMac, LOGE,
89 FL("Unable to allocate memory to store addn IE"));)
90 return eSIR_MEM_ALLOC_FAILED;
91 }
92
93 while(left >= 2)
94 {
95 elem_id = ptr[0];
96 elem_len = ptr[1];
97 left -= 2;
98 if (elem_len > left)
99 {
100 limLog( pMac, LOGE,
101 FL("Invalid IEs eid = %d elem_len=%d left=%d"),
102 elem_id,elem_len,left);
103 vos_mem_free(tempbuf);
104 return eSIR_FAILURE;
105 }
106 if ( !(DOT11F_EID_EXTCAP == elem_id) )
107 {
108 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
109 tempLen += (elem_len + 2);
110 }
111 else
112 { /*Est Cap present size is 8 + 2 byte at present*/
113 if ( NULL != pExtractedExtCapIEBuf )
114 {
115 vos_mem_set(pExtractedExtCapIEBuf,
116 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
117 if (elem_len <= DOT11F_IE_EXTCAP_MAX_LEN )
118 {
119 vos_mem_copy (pExtractedExtCapIEBuf, &ptr[0],
120 elem_len + 2);
121 }
122 }
123 }
124 left -= elem_len;
125 ptr += (elem_len + 2);
126 }
127 vos_mem_copy (addIE, tempbuf, tempLen);
128 *addnIELen = tempLen;
129 vos_mem_free(tempbuf);
130 return eSIR_SUCCESS;
131}
132
133void limUpdateExtCapIEtoStruct(tpAniSirGlobal pMac,
134 tANI_U8 *pBuf,
135 tDot11fIEExtCap *pDst)
136{
137 tANI_U8 pOut[DOT11F_IE_EXTCAP_MAX_LEN];
138
139 if ( NULL == pBuf )
140 {
141 limLog( pMac, LOGE,
142 FL("Invalid Buffer Address"));
143 return;
144 }
145 if(NULL == pDst)
146 {
147 PELOGE(limLog(pMac, LOGE,
148 FL("NULL pDst pointer"));)
149 return ;
150 }
151
152 if ( DOT11F_EID_EXTCAP != pBuf[0] ||
153 pBuf[1] > DOT11F_IE_EXTCAP_MAX_LEN )
154 {
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +0530155 limLog( pMac, LOG1,
Kalikinkar dhara205da782014-03-21 15:49:32 -0700156 FL("Invalid IEs eid = %d elem_len=%d "),
157 pBuf[0],pBuf[1]);
158 return;
159 }
160 vos_mem_set(( tANI_U8* )&pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
161 /* conversion should follow 4, 2, 2 byte order */
162 limUtilsframeshtonl(pMac, &pOut[0],*((tANI_U32*)&pBuf[2]),0);
163 limUtilsframeshtons(pMac, &pOut[4],*((tANI_U16*)&pBuf[6]),0);
164 limUtilsframeshtons(pMac, &pOut[6],*((tANI_U16*)&pBuf[8]),0);
165
166 if ( DOT11F_PARSE_SUCCESS != dot11fUnpackIeExtCap( pMac,
167 &pOut[0], DOT11F_IE_EXTCAP_MAX_LEN, pDst) )
168 {
169 limLog( pMac, LOGE,
170 FL("dot11fUnpackIeExtCap Parse Error "));
171 }
172}
173
174tSirRetStatus limStripOffExtCapIEAndUpdateStruct(tpAniSirGlobal pMac,
175 tANI_U8* addIE,
176 tANI_U16 *addnIELen,
177 tDot11fIEExtCap * pDst )
178{
179 tANI_U8 pExtractedExtCapIEBuf[DOT11F_IE_EXTCAP_MAX_LEN + 2];
180 tSirRetStatus nSirStatus;
181
182 vos_mem_set(( tANI_U8* )&pExtractedExtCapIEBuf[0],
183 DOT11F_IE_EXTCAP_MAX_LEN + 2, 0);
184 nSirStatus = limStripOffExtCapIE(pMac, addIE, addnIELen,
185 pExtractedExtCapIEBuf);
186 if ( eSIR_SUCCESS != nSirStatus )
187 {
188 limLog( pMac, LOG1, FL("Failed to strip off in"
189 "limStripOffExtCapIE status = (%d)."),
190 nSirStatus );
191 return nSirStatus;
192 }
193 /* update the extracted ExtCap to struct*/
194 limUpdateExtCapIEtoStruct(pMac, pExtractedExtCapIEBuf, pDst);
195 return nSirStatus;
196}
197
198void limMergeExtCapIEStruct(tDot11fIEExtCap *pDst,
199 tDot11fIEExtCap *pSrc)
200{
201 tANI_U8 *tempDst = (tANI_U8 *)pDst;
202 tANI_U8 *tempSrc = (tANI_U8 *)pSrc;
203 tANI_U8 structlen = sizeof(tDot11fIEExtCap);
204
205 while(tempDst && tempSrc && structlen--)
206 {
207 *tempDst |= *tempSrc;
208 tempDst++;
209 tempSrc++;
210 }
211}
Jeff Johnson295189b2012-06-20 16:38:30 -0700212
213/**
214 *
215 * \brief This function is called by various LIM modules to prepare the
216 * 802.11 frame MAC header
217 *
218 *
219 * \param pMac Pointer to Global MAC structure
220 *
221 * \param pBD Pointer to the frame buffer that needs to be populate
222 *
223 * \param type Type of the frame
224 *
225 * \param subType Subtype of the frame
226 *
227 * \return eHalStatus
228 *
229 *
230 * The pFrameBuf argument points to the beginning of the frame buffer to
231 * which - a) The 802.11 MAC header is set b) Following this MAC header
232 * will be the MGMT frame payload The payload itself is populated by the
233 * caller API
234 *
235 *
236 */
237
238tSirRetStatus limPopulateMacHeader( tpAniSirGlobal pMac,
239 tANI_U8* pBD,
240 tANI_U8 type,
241 tANI_U8 subType,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530242 tSirMacAddr peerAddr, tSirMacAddr selfMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -0700243{
244 tSirRetStatus statusCode = eSIR_SUCCESS;
245 tpSirMacMgmtHdr pMacHdr;
246
247 /// Prepare MAC management header
248 pMacHdr = (tpSirMacMgmtHdr) (pBD);
249
250 // Prepare FC
251 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
252 pMacHdr->fc.type = type;
253 pMacHdr->fc.subType = subType;
254
255 // Prepare Address 1
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530256 vos_mem_copy( (tANI_U8 *) pMacHdr->da,
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 (tANI_U8 *) peerAddr,
258 sizeof( tSirMacAddr ));
259
260 // Prepare Address 2
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
262
263 // Prepare Address 3
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530264 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
Jeff Johnson295189b2012-06-20 16:38:30 -0700265 (tANI_U8 *) peerAddr,
266 sizeof( tSirMacAddr ));
267 return statusCode;
268} /*** end limPopulateMacHeader() ***/
269
270/**
271 * \brief limSendProbeReqMgmtFrame
272 *
273 *
274 * \param pMac Pointer to Global MAC structure
275 *
276 * \param pSsid SSID to be sent in Probe Request frame
277 *
278 * \param bssid BSSID to be sent in Probe Request frame
279 *
280 * \param nProbeDelay probe delay to be used before sending Probe Request
281 * frame
282 *
283 * \param nChannelNum Channel # on which the Probe Request is going out
284 *
285 * \param nAdditionalIELen if non-zero, include pAdditionalIE in the Probe Request frame
286 *
287 * \param pAdditionalIE if nAdditionalIELen is non zero, include this field in the Probe Request frame
288 *
289 * This function is called by various LIM modules to send Probe Request frame
290 * during active scan/learn phase.
291 * Probe request is sent out in the following scenarios:
292 * --heartbeat failure: session needed
293 * --join req: session needed
294 * --foreground scan: no session
295 * --background scan: no session
296 * --schBeaconProcessing: to get EDCA parameters: session needed
297 *
298 *
299 */
300tSirRetStatus
301limSendProbeReqMgmtFrame(tpAniSirGlobal pMac,
302 tSirMacSSid *pSsid,
303 tSirMacAddr bssid,
304 tANI_U8 nChannelNum,
305 tSirMacAddr SelfMacAddr,
306 tANI_U32 dot11mode,
307 tANI_U32 nAdditionalIELen,
308 tANI_U8 *pAdditionalIE)
309{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530310 tDot11fProbeRequest pr;
311 tANI_U32 nStatus, nBytes, nPayload;
312 tSirRetStatus nSirStatus;
313 tANI_U8 *pFrame;
314 void *pPacket;
315 eHalStatus halstatus;
316 tpPESession psessionEntry;
317 tANI_U8 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700318 tANI_U8 *p2pIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530319 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700320
321#ifndef GEN4_SCAN
322 return eSIR_FAILURE;
323#endif
324
325#if defined ( ANI_DVT_DEBUG )
326 return eSIR_FAILURE;
327#endif
328
Abhishek Singh4beed422014-02-03 16:47:17 +0530329 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
330 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
331 * is false and dot11mode is 11ac set it to 11n.
332 */
333 if ( nChannelNum <= SIR_11B_CHANNEL_END &&
334 ( FALSE == pMac->roam.configParam.enableVhtFor24GHz ) &&
335 ( WNI_CFG_DOT11_MODE_11AC == dot11mode ||
336 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode ) )
337 dot11mode = WNI_CFG_DOT11_MODE_11N;
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 /*
339 * session context may or may not be present, when probe request needs to be sent out.
340 * following cases exist:
341 * --heartbeat failure: session needed
342 * --join req: session needed
343 * --foreground scan: no session
344 * --background scan: no session
345 * --schBeaconProcessing: to get EDCA parameters: session needed
346 * If session context does not exist, some IEs will be populated from CFGs,
347 * e.g. Supported and Extended rate set IEs
348 */
349 psessionEntry = peFindSessionByBssid(pMac,bssid,&sessionId);
350
351 // The scheme here is to fill out a 'tDot11fProbeRequest' structure
352 // and then hand it off to 'dot11fPackProbeRequest' (for
353 // serialization). We start by zero-initializing the structure:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530354 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700355
356 // & delegating to assorted helpers:
357 PopulateDot11fSSID( pMac, pSsid, &pr.SSID );
358
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 if( nAdditionalIELen && pAdditionalIE )
360 {
361 p2pIe = limGetP2pIEPtr(pMac, pAdditionalIE, nAdditionalIELen);
362 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700363 /* Don't include 11b rate only when device is doing P2P Search */
364 if( ( WNI_CFG_DOT11_MODE_11B != dot11mode ) &&
365 ( p2pIe != NULL ) &&
366 /* Don't include 11b rate if it is a P2P serach or probe request is sent by P2P Client */
367 ( ( ( pMac->lim.gpLimMlmScanReq != NULL ) &&
368 pMac->lim.gpLimMlmScanReq->p2pSearch ) ||
369 ( ( psessionEntry != NULL ) &&
370 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
371 )
372 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700373 {
374 /* In the below API pass channel number > 14, do that it fills only
375 * 11a rates in supported rates */
376 PopulateDot11fSuppRates( pMac, 15, &pr.SuppRates,psessionEntry);
377 }
378 else
379 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 PopulateDot11fSuppRates( pMac, nChannelNum,
381 &pr.SuppRates,psessionEntry);
382
383 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
384 {
385 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
386 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700388
389#if defined WLAN_FEATURE_VOWIFI
390 //Table 7-14 in IEEE Std. 802.11k-2008 says
391 //DS params "can" be present in RRM is disabled and "is" present if
392 //RRM is enabled. It should be ok even if we add it into probe req when
393 //RRM is not enabled.
394 PopulateDot11fDSParams( pMac, &pr.DSParams, nChannelNum, psessionEntry );
395 //Call RRM module to get the tx power for management used.
396 {
397 tANI_U8 txPower = (tANI_U8) rrmGetMgmtTxPower( pMac, psessionEntry );
398 PopulateDot11fWFATPC( pMac, &pr.WFATPC, txPower, 0 );
399 }
400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700401
402 if (psessionEntry != NULL ) {
Jeff Johnsone7245742012-09-05 17:12:55 -0700403 psessionEntry->htCapability = IS_DOT11_MODE_HT(dot11mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 //Include HT Capability IE
Jeff Johnsone7245742012-09-05 17:12:55 -0700405 if (psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700407 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700409 } else { //psessionEntry == NULL
410 if (IS_DOT11_MODE_HT(dot11mode))
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700412 PopulateDot11fHTCaps( pMac, psessionEntry, &pr.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
414 }
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800415
Hardik Kantilal Patelbca5b002015-01-19 15:30:18 +0530416 if((nChannelNum <= SIR_11B_CHANNEL_END)
417 && (!IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
418 && (!pMac->roam.configParam.channelBondingMode24GHz))
Gopichand Nakkala40bc6502012-12-20 16:55:36 -0800419 {
420 pr.HTCaps.supportedChannelWidthSet = eHT_CHANNEL_WIDTH_20MHZ;
421 pr.HTCaps.shortGI40MHz = 0;
422 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700423#ifdef WLAN_FEATURE_11AC
424 if (psessionEntry != NULL ) {
425 psessionEntry->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
426 //Include HT Capability IE
427 if (psessionEntry->vhtCapability)
428 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700430 }
431 } else {
432 if (IS_DOT11_MODE_VHT(dot11mode))
433 {
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530434 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700435 }
436 }
437#endif
438
Jeff Johnson295189b2012-06-20 16:38:30 -0700439
440 // That's it-- now we pack it. First, how much space are we going to
441 // need?
442 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
443 if ( DOT11F_FAILED( nStatus ) )
444 {
445 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700446 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 // We'll fall back on the worst case scenario:
448 nPayload = sizeof( tDot11fProbeRequest );
449 }
450 else if ( DOT11F_WARNED( nStatus ) )
451 {
452 limLog( pMac, LOGW, FL("There were warnings while calculating"
453 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700454 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456
457 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
458
459 // Ok-- try to allocate some memory:
460 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
461 ( tANI_U16 )nBytes, ( void** ) &pFrame,
462 ( void** ) &pPacket );
463 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
464 {
465 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700466 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 return eSIR_MEM_ALLOC_FAILED;
468 }
469
470 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530471 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472
473 // Next, we fill out the buffer descriptor:
474 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530475 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 if ( eSIR_SUCCESS != nSirStatus )
477 {
478 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700479 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 nSirStatus );
481 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
482 ( void* ) pFrame, ( void* ) pPacket );
483 return nSirStatus; // allocated!
484 }
485
486 // That done, pack the Probe Request:
487 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
488 sizeof( tSirMacMgmtHdr ),
489 nPayload, &nPayload );
490 if ( DOT11F_FAILED( nStatus ) )
491 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700492 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 nStatus );
494 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
495 return eSIR_FAILURE; // allocated!
496 }
497 else if ( DOT11F_WARNED( nStatus ) )
498 {
499 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800500 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 }
502
503 // Append any AddIE if present.
504 if( nAdditionalIELen )
505 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530506 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 pAdditionalIE, nAdditionalIELen );
508 nPayload += nAdditionalIELen;
509 }
510
511 /* If this probe request is sent during P2P Search State, then we need
512 * to send it at OFDM rate.
513 */
514 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
516 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530517 /* For unicast probe req mgmt from Join function
518 we don't set above variables. So we need to add
519 one more check whether it is pePersona is P2P_CLIENT or not */
520 || ( ( psessionEntry != NULL ) &&
521 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 )
523 {
524 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
525 }
526
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530527 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
528 ( !IS_BROADCAST_MAC(bssid) ) ){
529 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
530 }
531
Jeff Johnson295189b2012-06-20 16:38:30 -0700532 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
533 HAL_TXRX_FRM_802_11_MGMT,
534 ANI_TXDIR_TODS,
535 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
536 limTxComplete, pFrame, txFlag );
537 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
538 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700539 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 //Pkt will be freed up by the callback
541 return eSIR_FAILURE;
542 }
543
544 return eSIR_SUCCESS;
545} // End limSendProbeReqMgmtFrame.
546
Jeff Johnson295189b2012-06-20 16:38:30 -0700547tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
548 tANI_U8* addIE, tANI_U16 *addnIELen,
549 tANI_U8 probeReqP2pIe)
550{
551 /* If Probe request doesn't have P2P IE, then take out P2P IE
552 from additional IE */
553 if(!probeReqP2pIe)
554 {
555 tANI_U8* tempbuf = NULL;
556 tANI_U16 tempLen = 0;
557 int left = *addnIELen;
558 v_U8_t *ptr = addIE;
559 v_U8_t elem_id, elem_len;
560
561 if(NULL == addIE)
562 {
563 PELOGE(limLog(pMac, LOGE,
564 FL(" NULL addIE pointer"));)
565 return eSIR_FAILURE;
566 }
567
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530568 tempbuf = vos_mem_malloc(left);
569 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 {
571 PELOGE(limLog(pMac, LOGE,
572 FL("Unable to allocate memory to store addn IE"));)
573 return eSIR_MEM_ALLOC_FAILED;
574 }
575
576 while(left >= 2)
577 {
578 elem_id = ptr[0];
579 elem_len = ptr[1];
580 left -= 2;
581 if(elem_len > left)
582 {
583 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700584 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530586 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return eSIR_FAILURE;
588 }
589 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
590 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
591 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530592 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700593 tempLen += (elem_len + 2);
594 }
595 left -= elem_len;
596 ptr += (elem_len + 2);
597 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530598 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530600 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 }
602 return eSIR_SUCCESS;
603}
Jeff Johnson295189b2012-06-20 16:38:30 -0700604
605void
606limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
607 tSirMacAddr peerMacAddr,
608 tpAniSSID pSsid,
609 short nStaId,
610 tANI_U8 nKeepAlive,
611 tpPESession psessionEntry,
612 tANI_U8 probeReqP2pIe)
613{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700614 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530615 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530616 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530617 tpSirMacMgmtHdr pMacHdr;
618 tANI_U8 *pFrame;
619 void *pPacket;
620 eHalStatus halstatus;
621 tANI_U32 addnIEPresent;
622 tANI_U32 addnIE1Len=0;
623 tANI_U32 addnIE2Len=0;
624 tANI_U32 addnIE3Len=0;
625 tANI_U16 totalAddnIeLen = 0;
626 tANI_U32 wpsApEnable=0, tmp;
627 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530629 tANI_U8 *pP2pIe = NULL;
630 tANI_U8 noaLen = 0;
631 tANI_U8 total_noaLen = 0;
632 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530634 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700635 tDot11fIEExtCap extractedExtCap;
636 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530637 tANI_U32 nBytes = 0;
638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
640 {
641 return; // in this case.
642 }
643
644 if(NULL == psessionEntry)
645 {
646 return;
647 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530648
649 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
650 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700651 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530652 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700653 return;
654 }
655
Girish Gowli0e826792014-05-17 17:56:44 +0530656 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
657
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 // Fill out 'frm', after which we'll just hand the struct off to
659 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530660 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700661
662 // Timestamp to be updated by TFP, below.
663
664 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
666 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700667 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 }
669 else
670 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800671 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
672 if (eSIR_SUCCESS != nSirStatus)
673 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700674 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800675 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530676 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800677 return;
678 }
679 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800680 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700681
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700682 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
683 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700685 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700686
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700687 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
688 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
692 {
693 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
694 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700695 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 }
697 }
698 else
699 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800700 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700701 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800703 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700704
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800705 if (wpsApEnable)
706 {
707 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
708 }
709
710 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
711 {
712 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
713 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
714 }
715
716 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
717 {
718 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
719 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
720 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700723 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
724 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
727 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700728 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700729
730
731 // N.B. In earlier implementations, the RSN IE would be placed in
732 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
733 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700734 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700735
736 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700737 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700738 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700739 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530742
743#ifdef WLAN_FEATURE_AP_HT40_24G
744 /* Populate Overlapping BSS Scan Parameters IEs,
745 * when operating in HT40 in 2.4GHz.
746 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530747 if ((pMac->roam.configParam.apHT40_24GEnabled)
748 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530749 {
750 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
751 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530752 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
753 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
754 * Mode in 40 MHz bit in HT capablity.
755 */
756 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530757 }
758#endif
759
760 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
761
Jeff Johnsone7245742012-09-05 17:12:55 -0700762#ifdef WLAN_FEATURE_11AC
763 if(psessionEntry->vhtCapability)
764 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800765 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +0530766 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_TRUE );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700767 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation );
Jeff Johnsone7245742012-09-05 17:12:55 -0700768 // we do not support multi users yet
769 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
770 }
771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
Sandeep Puligilla60342762014-01-30 21:05:37 +0530773
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530774 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 {
776 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700777 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700778 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
779 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 }
781
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700782 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783
784#if defined(FEATURE_WLAN_WAPI)
785 if( psessionEntry->pLimStartBssReq )
786 {
787 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700788 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 }
790
791#endif // defined(FEATURE_WLAN_WAPI)
792
Jeff Johnson295189b2012-06-20 16:38:30 -0700793 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 if( pMac->lim.gpLimRemainOnChanReq )
795 {
796 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
797 }
798 //Only use CFG for non-listen mode. This CFG is not working for concurrency
799 //In listening mode, probe rsp IEs is passed in the message from SME to PE
800 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 {
802
803 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
804 &addnIEPresent) != eSIR_SUCCESS)
805 {
806 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530807 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 return;
809 }
810 }
811
812 if (addnIEPresent)
813 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530814
815 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
816 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
818 PELOGE(limLog(pMac, LOGE,
819 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530820 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700821 return;
822 }
823
824 //Probe rsp IE available
825 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
826 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
827 {
828 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530829 vos_mem_free(addIE);
830 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 return;
832 }
833 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
834 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
835 {
836 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
837 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
838 &addnIE1Len) )
839 {
840 limLog(pMac, LOGP,
841 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530842 vos_mem_free(addIE);
843 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 return;
845 }
846 }
847
848 //Probe rsp IE available
849 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
850 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
851 {
852 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530853 vos_mem_free(addIE);
854 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 return;
856 }
857 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
858 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
859 {
860 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
861 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
862 &addnIE2Len) )
863 {
864 limLog(pMac, LOGP,
865 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530866 vos_mem_free(addIE);
867 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 return;
869 }
870 }
871
872 //Probe rsp IE available
873 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
874 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
875 {
876 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530877 vos_mem_free(addIE);
878 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 return;
880 }
881 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
882 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
883 {
884 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
885 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
886 &addIE[addnIE1Len + addnIE2Len],
887 &addnIE3Len) )
888 {
889 limLog(pMac, LOGP,
890 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530891 vos_mem_free(addIE);
892 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 return;
894 }
895 }
896 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
897
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
899 {
900 limLog(pMac, LOGP,
901 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530902 vos_mem_free(addIE);
903 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return;
905 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700906
Kalikinkar dhara205da782014-03-21 15:49:32 -0700907 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
908 addIE,
909 &totalAddnIeLen,
910 &extractedExtCap );
911 if(eSIR_SUCCESS != nSirStatus )
912 {
913 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
914 limLog(pMac, LOG1,
915 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
916 }
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530919 limLog(pMac, LOG1,
920 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 if (probeReqP2pIe)
922 {
923 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
924 if (pP2pIe != NULL)
925 {
926 //get NoA attribute stream P2P IE
927 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
928 if (noaLen != 0)
929 {
930 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
931 &noaStream[0], noaLen);
932 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530933 limLog(pMac, LOG1,
934 FL("p2p probe rsp packet size is %d, noalength is %d"),
935 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 }
937 }
938 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940
c_hpothubcd78652014-04-28 22:31:08 +0530941 /*merge ExtCap IE*/
942 if (extractedExtCapFlag && extractedExtCap.present)
943 {
944 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
945 }
946
947 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
948 if ( DOT11F_FAILED( nStatus ) )
949 {
950 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
951 "or a Probe Response (0x%08x)."),
952 nStatus );
953 // We'll fall back on the worst case scenario:
954 nPayload = sizeof( tDot11fProbeResponse );
955 }
956 else if ( DOT11F_WARNED( nStatus ) )
957 {
958 limLog( pMac, LOGW, FL("There were warnings while calculating"
959 "the packed size for a Probe Response "
960 "(0x%08x)."), nStatus );
961 }
962
963 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
964
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
966 ( tANI_U16 )nBytes, ( void** ) &pFrame,
967 ( void** ) &pPacket );
968 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
969 {
970 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700971 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 if ( addIE != NULL )
973 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530974 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530976 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700977 return;
978 }
979
980 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530981 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700982
983 // Next, we fill out the buffer descriptor:
984 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
985 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
986 if ( eSIR_SUCCESS != nSirStatus )
987 {
988 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700989 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 nSirStatus );
991 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
992 ( void* ) pFrame, ( void* ) pPacket );
993 if ( addIE != NULL )
994 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530995 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530997 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 return;
999 }
1000
1001 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1002
1003 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1004
1005 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001006 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 nPayload, &nPayload );
1008 if ( DOT11F_FAILED( nStatus ) )
1009 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001010 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 nStatus );
1012 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1013 if ( addIE != NULL )
1014 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301015 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301017 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 return; // allocated!
1019 }
1020 else if ( DOT11F_WARNED( nStatus ) )
1021 {
1022 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001023 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001024 }
1025
1026 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1027 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1028
1029 pMac->sys.probeRespond++;
1030
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 if( pMac->lim.gpLimRemainOnChanReq )
1032 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301033 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001036
1037 if ( addnIEPresent )
1038 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301039 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 if (noaLen != 0)
1042 {
Krunal Soni81b24262013-05-15 17:46:41 -07001043 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
1045 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301046 FL("Not able to insert NoA because of length constraint."
1047 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301048 vos_mem_free(addIE);
1049 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001050 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1051 ( void* ) pFrame, ( void* ) pPacket );
1052 return;
1053 }
1054 else
1055 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301056 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001057 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 }
1059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001060
1061 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1063 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 )
1065 {
1066 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1067 }
1068
1069 // Queue Probe Response frame in high priority WQ
1070 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1071 ( tANI_U16 ) nBytes,
1072 HAL_TXRX_FRM_802_11_MGMT,
1073 ANI_TXDIR_TODS,
1074 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1075 limTxComplete, pFrame, txFlag );
1076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1077 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001078 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 //Pkt will be freed up by the callback
1080 }
1081
1082 if ( addIE != NULL )
1083 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301084 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 }
1086
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001088 return;
1089
1090
Jeff Johnson295189b2012-06-20 16:38:30 -07001091} // End limSendProbeRspMgmtFrame.
1092
1093void
1094limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1095 tSirMacAddr peerMacAddr,
1096 tSirAddtsReqInfo *pAddTS,
1097 tpPESession psessionEntry)
1098{
1099 tANI_U16 i;
1100 tANI_U8 *pFrame;
1101 tSirRetStatus nSirStatus;
1102 tDot11fAddTSRequest AddTSReq;
1103 tDot11fWMMAddTSRequest WMMAddTSReq;
1104 tANI_U32 nPayload, nBytes, nStatus;
1105 tpSirMacMgmtHdr pMacHdr;
1106 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001107#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 tANI_U32 phyMode;
1109#endif
1110 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301111 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
1113 if(NULL == psessionEntry)
1114 {
1115 return;
1116 }
1117
1118 if ( ! pAddTS->wmeTspecPresent )
1119 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301120 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
1122 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1123 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1124 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1125 if ( pAddTS->lleTspecPresent )
1126 {
1127 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1128 }
1129 else
1130 {
1131 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1132 }
1133
1134 if ( pAddTS->lleTspecPresent )
1135 {
1136 AddTSReq.num_WMMTCLAS = 0;
1137 AddTSReq.num_TCLAS = pAddTS->numTclas;
1138 for ( i = 0; i < pAddTS->numTclas; ++i)
1139 {
1140 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1141 &AddTSReq.TCLAS[i] );
1142 }
1143 }
1144 else
1145 {
1146 AddTSReq.num_TCLAS = 0;
1147 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1148 for ( i = 0; i < pAddTS->numTclas; ++i)
1149 {
1150 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1151 &AddTSReq.WMMTCLAS[i] );
1152 }
1153 }
1154
1155 if ( pAddTS->tclasProcPresent )
1156 {
1157 if ( pAddTS->lleTspecPresent )
1158 {
1159 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1160 AddTSReq.TCLASSPROC.present = 1;
1161 }
1162 else
1163 {
1164 AddTSReq.WMMTCLASPROC.version = 1;
1165 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1166 AddTSReq.WMMTCLASPROC.present = 1;
1167 }
1168 }
1169
1170 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1171 if ( DOT11F_FAILED( nStatus ) )
1172 {
1173 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001174 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001175 nStatus );
1176 // We'll fall back on the worst case scenario:
1177 nPayload = sizeof( tDot11fAddTSRequest );
1178 }
1179 else if ( DOT11F_WARNED( nStatus ) )
1180 {
1181 limLog( pMac, LOGW, FL("There were warnings while calculating"
1182 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001183 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 }
1185 }
1186 else
1187 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301188 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001189
1190 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1191 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1192 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1193
1194 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1195 WMMAddTSReq.StatusCode.statusCode = 0;
1196
1197 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001198#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 limGetPhyMode(pMac, &phyMode, psessionEntry);
1200
1201 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1202 {
1203 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1204 }
1205 else
1206 {
1207 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1208 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001209 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001210#endif
1211 // fillWmeTspecIE
1212
1213 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1214 if ( DOT11F_FAILED( nStatus ) )
1215 {
1216 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001217 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001218 nStatus );
1219 // We'll fall back on the worst case scenario:
1220 nPayload = sizeof( tDot11fAddTSRequest );
1221 }
1222 else if ( DOT11F_WARNED( nStatus ) )
1223 {
1224 limLog( pMac, LOGW, FL("There were warnings while calculating"
1225 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001226 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001227 }
1228 }
1229
1230 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1231
1232 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1233 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1234 ( void** ) &pPacket );
1235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1236 {
1237 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001238 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 return;
1240 }
1241
1242 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301243 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001244
1245 // Next, we fill out the buffer descriptor:
1246 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1247 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1248 if ( eSIR_SUCCESS != nSirStatus )
1249 {
1250 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001251 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001252 nSirStatus );
1253 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1254 ( void* ) pFrame, ( void* ) pPacket );
1255 return;
1256 }
1257
1258 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1259
1260 #if 0
1261 cfgLen = SIR_MAC_ADDR_LENGTH;
1262 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1263 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1264 {
1265 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001266 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1268 ( void* ) pFrame, ( void* ) pPacket );
1269 return;
1270 }
1271 #endif //TO SUPPORT BT-AMP
1272
1273 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1274
Chet Lanctot186b5732013-03-18 10:26:30 -07001275#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001276 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001277#endif
1278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279 // That done, pack the struct:
1280 if ( ! pAddTS->wmeTspecPresent )
1281 {
1282 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1283 pFrame + sizeof(tSirMacMgmtHdr),
1284 nPayload, &nPayload );
1285 if ( DOT11F_FAILED( nStatus ) )
1286 {
1287 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001288 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001289 nStatus );
1290 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1291 return; // allocated!
1292 }
1293 else if ( DOT11F_WARNED( nStatus ) )
1294 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001295 limLog( pMac, LOGW, FL("There were warnings while packing "
1296 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001297 }
1298 }
1299 else
1300 {
1301 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1302 pFrame + sizeof(tSirMacMgmtHdr),
1303 nPayload, &nPayload );
1304 if ( DOT11F_FAILED( nStatus ) )
1305 {
1306 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001307 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 nStatus );
1309 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1310 return; // allocated!
1311 }
1312 else if ( DOT11F_WARNED( nStatus ) )
1313 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001314 limLog( pMac, LOGW, FL("There were warnings while packing "
1315 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317 }
1318
Abhishek Singh127a8442014-12-15 17:31:27 +05301319 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1320 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001321
1322 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1324 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 )
1326 {
1327 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1328 }
1329
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301330 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1331 psessionEntry->peSessionId,
1332 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 // Queue Addts Response frame in high priority WQ
1334 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1335 HAL_TXRX_FRM_802_11_MGMT,
1336 ANI_TXDIR_TODS,
1337 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1338 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301339 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1340 psessionEntry->peSessionId,
1341 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1343 {
1344 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001345 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 //Pkt will be freed up by the callback
1347 }
1348
1349} // End limSendAddtsReqActionFrame.
1350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351
1352
1353void
1354limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1355 tANI_U16 statusCode,
1356 tANI_U16 aid,
1357 tSirMacAddr peerMacAddr,
1358 tANI_U8 subType,
1359 tpDphHashNode pSta,tpPESession psessionEntry)
1360{
1361 static tDot11fAssocResponse frm;
1362 tANI_U8 *pFrame, *macAddr;
1363 tpSirMacMgmtHdr pMacHdr;
1364 tSirRetStatus nSirStatus;
1365 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1366 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301367 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 void *pPacket;
1369 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301370 tUpdateBeaconParams beaconParams;
1371 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 tANI_U32 addnIEPresent = false;
1373 tANI_U32 addnIELen=0;
1374 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1375 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301376 tANI_U16 addStripoffIELen = 0;
1377 tDot11fIEExtCap extractedExtCap;
1378 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301379 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001380
Chet Lanctot8cecea22014-02-11 19:09:36 -08001381#ifdef WLAN_FEATURE_11W
1382 tANI_U32 retryInterval;
1383 tANI_U32 maxRetries;
1384#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001385
1386 if(NULL == psessionEntry)
1387 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301388 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001389 return;
1390 }
1391
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301392 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001393
1394 limGetQosMode(psessionEntry, &qosMode);
1395 limGetWmeMode(psessionEntry, &wmeMode);
1396
1397 // An Add TS IE is added only if the AP supports it and the requesting
1398 // STA sent a traffic spec.
1399 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1400
1401 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1402
1403 frm.Status.status = statusCode;
1404
1405 frm.AID.associd = aid | LIM_AID_MASK;
1406
1407 if ( NULL == pSta )
1408 {
1409 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1410 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1411 }
1412 else
1413 {
1414 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1415 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1416 }
1417
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1419 {
1420 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1421 {
1422 pAssocReq =
1423 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1425 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1426 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 }
1429 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001430
1431 if ( NULL != pSta )
1432 {
1433 if ( eHAL_SET == qosMode )
1434 {
1435 if ( pSta->lleEnabled )
1436 {
1437 lleMode = 1;
1438 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1439 {
1440 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1441
1442// FramesToDo:...
1443// if ( fAddTS )
1444// {
1445// tANI_U8 *pAf = pBody;
1446// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1447// tANI_U32 tlen;
1448// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1449// &tlen, bufLen - frameLen);
1450// } // End if on Add TS.
1451 }
1452 } // End if on .11e enabled in 'pSta'.
1453 } // End if on QOS Mode on.
1454
1455 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1456 {
1457 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1458 {
1459
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001461
1462 if ( pSta->wsmEnabled )
1463 {
1464 PopulateDot11fWMMCaps(&frm.WMMCaps );
1465 }
1466 }
1467 }
1468
1469 if ( pSta->aniPeer )
1470 {
1471 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1472 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1473 {
1474 edcaInclude = 1;
1475 }
1476
1477 } // End if on Airgo peer.
1478
1479 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001480 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001482 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301483 /*
1484 *Check the STA capability and update the HTCaps accordingly
1485 */
1486 frm.HTCaps.supportedChannelWidthSet =
1487 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1488 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1489
1490 if (!frm.HTCaps.supportedChannelWidthSet)
1491 frm.HTCaps.shortGI40MHz = 0;
1492
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001495
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301496#ifdef WLAN_FEATURE_AP_HT40_24G
1497 /* Populate Overlapping BSS Scan Parameters IEs,
1498 * when operating in HT40 in 2.4GHz.
1499 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301500 if ((pMac->roam.configParam.apHT40_24GEnabled)
1501 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301502 {
1503 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1504 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301505 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1506 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1507 * Mode in 40 MHz bit in HT capablity.
1508 */
1509 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301510 }
1511#endif
1512
1513 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001514#ifdef WLAN_FEATURE_11AC
1515 if( pSta->mlmStaContext.vhtCapability &&
1516 psessionEntry->vhtCapability )
1517 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001518 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301519 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07001520 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation);
1521 }
1522#endif
1523
Chet Lanctot8cecea22014-02-11 19:09:36 -08001524#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301525 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1526 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001527 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1528 &maxRetries ) != eSIR_SUCCESS )
1529 limLog( pMac, LOGE,
1530 FL("Could not retrieve PMF SA Query maximum retries value") );
1531 else
1532 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1533 &retryInterval ) != eSIR_SUCCESS)
1534 limLog( pMac, LOGE,
1535 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301536 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001537 PopulateDot11fTimeoutInterval(
1538 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1539 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301540 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001541#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301542 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001543
Chet Lanctot8cecea22014-02-11 19:09:36 -08001544 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Jeff Johnson295189b2012-06-20 16:38:30 -07001546 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1547 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1548 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
1551 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1552 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1553
1554 beaconParams.bssIdx = psessionEntry->bssIdx;
1555
1556 //Send message to HAL about beacon parameter change.
1557 if(beaconParams.paramChangeBitmap)
1558 {
1559 schSetFixedBeaconFields(pMac,psessionEntry);
1560 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1561 }
1562
Jeff Johnson295189b2012-06-20 16:38:30 -07001563 if ( pAssocReq != NULL )
1564 {
1565 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1566 &addnIEPresent) != eSIR_SUCCESS)
1567 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301568 limLog(pMac, LOGP, FL("Unable to get "
1569 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 return;
1571 }
1572
1573 if (addnIEPresent)
1574 {
1575 //Assoc rsp IE available
1576 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1577 &addnIELen) != eSIR_SUCCESS)
1578 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301579 limLog(pMac, LOGP, FL("Unable to get "
1580 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 return;
1582 }
1583
1584 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1585 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1586 {
1587 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1588 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1589 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301590
1591 vos_mem_set(( tANI_U8* )&extractedExtCap,
1592 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301593 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301594 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1595 &addIE[0],
1596 &addStripoffIELen,
1597 &extractedExtCap );
1598 if(eSIR_SUCCESS != nSirStatus)
1599 {
1600 limLog(pMac, LOG1,
1601 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1602 }
1603 else
1604 {
1605 addnIELen = addStripoffIELen;
1606 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 nBytes = nBytes + addnIELen;
1609 }
1610 }
1611 }
1612 }
1613
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301614 /* merge the ExtCap struct*/
1615 if (extractedExtCapFlag && extractedExtCap.present)
1616 {
1617 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1618 }
1619
c_hpothubcd78652014-04-28 22:31:08 +05301620 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1621 if ( DOT11F_FAILED( nStatus ) )
1622 {
1623 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1624 "or an Association Response (0x%08x)."),
1625 nStatus );
1626 return;
1627 }
1628 else if ( DOT11F_WARNED( nStatus ) )
1629 {
1630 limLog( pMac, LOGW, FL("There were warnings while calculating "
1631 "the packed size for an Association Re"
1632 "sponse (0x%08x)."), nStatus );
1633 }
1634
1635 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1636
Jeff Johnson295189b2012-06-20 16:38:30 -07001637 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1638 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1639 ( void** ) &pPacket );
1640 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1641 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001642 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 return;
1644 }
1645
1646 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301647 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001648
1649 // Next, we fill out the buffer descriptor:
1650 nSirStatus = limPopulateMacHeader( pMac,
1651 pFrame,
1652 SIR_MAC_MGMT_FRAME,
1653 ( LIM_ASSOC == subType ) ?
1654 SIR_MAC_MGMT_ASSOC_RSP :
1655 SIR_MAC_MGMT_REASSOC_RSP,
1656 peerMacAddr,psessionEntry->selfMacAddr);
1657 if ( eSIR_SUCCESS != nSirStatus )
1658 {
1659 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001660 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 nSirStatus );
1662 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1663 ( void* ) pFrame, ( void* ) pPacket );
1664 return;
1665 }
1666
1667 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1668
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1670
1671 nStatus = dot11fPackAssocResponse( pMac, &frm,
1672 pFrame + sizeof( tSirMacMgmtHdr ),
1673 nPayload, &nPayload );
1674 if ( DOT11F_FAILED( nStatus ) )
1675 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301676 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1677 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1679 ( void* ) pFrame, ( void* ) pPacket );
1680 return; // allocated!
1681 }
1682 else if ( DOT11F_WARNED( nStatus ) )
1683 {
1684 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001685 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 }
1687
1688 macAddr = pMacHdr->da;
1689
1690 if (subType == LIM_ASSOC)
1691 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301692 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301694 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 }
1696 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301697 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301699 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301701 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
1703 if ( addnIEPresent )
1704 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301705 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 }
1707
1708 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1710 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 )
1712 {
1713 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1714 }
1715
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301716 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1717 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1718 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1719
1720 txFlag |= HAL_USE_FW_IN_TX_PATH;
1721
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301722 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1723 psessionEntry->peSessionId,
1724 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 /// Queue Association Response frame in high priority WQ
1726 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1727 HAL_TXRX_FRM_802_11_MGMT,
1728 ANI_TXDIR_TODS,
1729 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1730 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301731 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1732 psessionEntry->peSessionId,
1733 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001734 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1735 {
1736 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001737 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001738 nSirStatus);
1739
1740 //Pkt will be freed up by the callback
1741 }
1742
1743 // update the ANI peer station count
1744 //FIXME_PROTECTION : take care of different type of station
1745 // counter inside this function.
1746 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1747
1748} // End limSendAssocRspMgmtFrame.
1749
1750
1751
1752void
1753limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1754 tSirMacAddr peer,
1755 tANI_U16 nStatusCode,
1756 tSirAddtsReqInfo *pAddTS,
1757 tSirMacScheduleIE *pSchedule,
1758 tpPESession psessionEntry)
1759{
1760 tANI_U8 *pFrame;
1761 tpSirMacMgmtHdr pMacHdr;
1762 tDot11fAddTSResponse AddTSRsp;
1763 tDot11fWMMAddTSResponse WMMAddTSRsp;
1764 tSirRetStatus nSirStatus;
1765 tANI_U32 i, nBytes, nPayload, nStatus;
1766 void *pPacket;
1767 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301768 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 if(NULL == psessionEntry)
1771 {
1772 return;
1773 }
1774
1775 if ( ! pAddTS->wmeTspecPresent )
1776 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301777 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1780 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1781 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1782 AddTSRsp.Status.status = nStatusCode;
1783
1784 // The TsDelay information element is only filled in for a specific
1785 // status code:
1786 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1787 {
1788 if ( pAddTS->wsmTspecPresent )
1789 {
1790 AddTSRsp.WMMTSDelay.version = 1;
1791 AddTSRsp.WMMTSDelay.delay = 10;
1792 AddTSRsp.WMMTSDelay.present = 1;
1793 }
1794 else
1795 {
1796 AddTSRsp.TSDelay.delay = 10;
1797 AddTSRsp.TSDelay.present = 1;
1798 }
1799 }
1800
1801 if ( pAddTS->wsmTspecPresent )
1802 {
1803 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1804 }
1805 else
1806 {
1807 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1808 }
1809
1810 if ( pAddTS->wsmTspecPresent )
1811 {
1812 AddTSRsp.num_WMMTCLAS = 0;
1813 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1814 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1815 {
1816 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1817 &AddTSRsp.TCLAS[i] );
1818 }
1819 }
1820 else
1821 {
1822 AddTSRsp.num_TCLAS = 0;
1823 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1824 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1825 {
1826 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1827 &AddTSRsp.WMMTCLAS[i] );
1828 }
1829 }
1830
1831 if ( pAddTS->tclasProcPresent )
1832 {
1833 if ( pAddTS->wsmTspecPresent )
1834 {
1835 AddTSRsp.WMMTCLASPROC.version = 1;
1836 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1837 AddTSRsp.WMMTCLASPROC.present = 1;
1838 }
1839 else
1840 {
1841 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1842 AddTSRsp.TCLASSPROC.present = 1;
1843 }
1844 }
1845
1846 // schedule element is included only if requested in the tspec and we are
1847 // using hcca (or both edca and hcca)
1848 // 11e-D8.0 is inconsistent on whether the schedule element is included
1849 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1850 // pg 46, line 17-18 says something else. So just include it and let the
1851 // sta figure it out
1852 if ((pSchedule != NULL) &&
1853 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1854 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1855 {
1856 if ( pAddTS->wsmTspecPresent )
1857 {
1858 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1859 }
1860 else
1861 {
1862 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1863 }
1864 }
1865
1866 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1867 if ( DOT11F_FAILED( nStatus ) )
1868 {
1869 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001870 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 nStatus );
1872 // We'll fall back on the worst case scenario:
1873 nPayload = sizeof( tDot11fAddTSResponse );
1874 }
1875 else if ( DOT11F_WARNED( nStatus ) )
1876 {
1877 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001878 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001879 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001880 }
1881 }
1882 else
1883 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301884 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885
1886 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1887 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1888 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1889 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1890
1891 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1892
1893 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1894 if ( DOT11F_FAILED( nStatus ) )
1895 {
1896 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001897 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 nStatus );
1899 // We'll fall back on the worst case scenario:
1900 nPayload = sizeof( tDot11fWMMAddTSResponse );
1901 }
1902 else if ( DOT11F_WARNED( nStatus ) )
1903 {
1904 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001905 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001906 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 }
1908 }
1909
1910 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1911
1912 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1913 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1914 {
1915 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001916 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001917 return;
1918 }
1919
1920 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301921 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001922
1923 // Next, we fill out the buffer descriptor:
1924 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1925 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1926 if ( eSIR_SUCCESS != nSirStatus )
1927 {
1928 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001929 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001930 nSirStatus );
1931 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1932 return; // allocated!
1933 }
1934
1935 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1936
1937
1938 #if 0
1939 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1940 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1941 {
1942 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001943 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1945 return; // allocated!
1946 }
1947 #endif //TO SUPPORT BT-AMP
1948 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1949
Chet Lanctot186b5732013-03-18 10:26:30 -07001950#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001951 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001952#endif
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 // That done, pack the struct:
1955 if ( ! pAddTS->wmeTspecPresent )
1956 {
1957 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1958 pFrame + sizeof( tSirMacMgmtHdr ),
1959 nPayload, &nPayload );
1960 if ( DOT11F_FAILED( nStatus ) )
1961 {
1962 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001963 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 nStatus );
1965 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1966 return;
1967 }
1968 else if ( DOT11F_WARNED( nStatus ) )
1969 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001970 limLog( pMac, LOGW, FL("There were warnings while packing "
1971 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 }
1973 }
1974 else
1975 {
1976 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
1977 pFrame + sizeof( tSirMacMgmtHdr ),
1978 nPayload, &nPayload );
1979 if ( DOT11F_FAILED( nStatus ) )
1980 {
1981 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001982 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 nStatus );
1984 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1985 return;
1986 }
1987 else if ( DOT11F_WARNED( nStatus ) )
1988 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001989 limLog( pMac, LOGW, FL("There were warnings while packing "
1990 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 }
1992 }
1993
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301994 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301996 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001997
1998 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2000 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 )
2002 {
2003 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2004 }
2005
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302006 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2007 psessionEntry->peSessionId,
2008 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 // Queue the frame in high priority WQ:
2010 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2011 HAL_TXRX_FRM_802_11_MGMT,
2012 ANI_TXDIR_TODS,
2013 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2014 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302015 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2016 psessionEntry->peSessionId,
2017 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2019 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002020 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 nSirStatus );
2022 //Pkt will be freed up by the callback
2023 }
2024
2025} // End limSendAddtsRspActionFrame.
2026
2027void
2028limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2029 tSirMacAddr peer,
2030 tANI_U8 wmmTspecPresent,
2031 tSirMacTSInfo *pTsinfo,
2032 tSirMacTspecIE *pTspecIe,
2033 tpPESession psessionEntry)
2034{
2035 tANI_U8 *pFrame;
2036 tpSirMacMgmtHdr pMacHdr;
2037 tDot11fDelTS DelTS;
2038 tDot11fWMMDelTS WMMDelTS;
2039 tSirRetStatus nSirStatus;
2040 tANI_U32 nBytes, nPayload, nStatus;
2041 void *pPacket;
2042 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302043 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002044
2045 if(NULL == psessionEntry)
2046 {
2047 return;
2048 }
2049
2050 if ( ! wmmTspecPresent )
2051 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302052 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002053
2054 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2055 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2056 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2057
2058 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2059 if ( DOT11F_FAILED( nStatus ) )
2060 {
2061 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002062 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 nStatus );
2064 // We'll fall back on the worst case scenario:
2065 nPayload = sizeof( tDot11fDelTS );
2066 }
2067 else if ( DOT11F_WARNED( nStatus ) )
2068 {
2069 limLog( pMac, LOGW, FL("There were warnings while calcula"
2070 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002071 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }
2073 }
2074 else
2075 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302076 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002077
2078 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2079 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2080 WMMDelTS.DialogToken.token = 0;
2081 WMMDelTS.StatusCode.statusCode = 0;
2082 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2083 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2084 if ( DOT11F_FAILED( nStatus ) )
2085 {
2086 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002087 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 nStatus );
2089 // We'll fall back on the worst case scenario:
2090 nPayload = sizeof( tDot11fDelTS );
2091 }
2092 else if ( DOT11F_WARNED( nStatus ) )
2093 {
2094 limLog( pMac, LOGW, FL("There were warnings while calcula"
2095 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002096 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 }
2098 }
2099
2100 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2101
2102 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2103 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2104 {
2105 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002106 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002107 return;
2108 }
2109
2110 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302111 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002112
2113 // Next, we fill out the buffer descriptor:
2114 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2115 SIR_MAC_MGMT_ACTION, peer,
2116 psessionEntry->selfMacAddr);
2117 if ( eSIR_SUCCESS != nSirStatus )
2118 {
2119 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002120 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 nSirStatus );
2122 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2123 return; // allocated!
2124 }
2125
2126 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2127
2128 #if 0
2129
2130 cfgLen = SIR_MAC_ADDR_LENGTH;
2131 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2132 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2133 {
2134 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002135 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2137 return; // allocated!
2138 }
2139 #endif //TO SUPPORT BT-AMP
2140 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2141
Chet Lanctot186b5732013-03-18 10:26:30 -07002142#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002143 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002144#endif
2145
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 // That done, pack the struct:
2147 if ( !wmmTspecPresent )
2148 {
2149 nStatus = dot11fPackDelTS( pMac, &DelTS,
2150 pFrame + sizeof( tSirMacMgmtHdr ),
2151 nPayload, &nPayload );
2152 if ( DOT11F_FAILED( nStatus ) )
2153 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002154 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 nStatus );
2156 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2157 return; // allocated!
2158 }
2159 else if ( DOT11F_WARNED( nStatus ) )
2160 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002161 limLog( pMac, LOGW, FL("There were warnings while packing "
2162 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 }
2164 }
2165 else
2166 {
2167 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2168 pFrame + sizeof( tSirMacMgmtHdr ),
2169 nPayload, &nPayload );
2170 if ( DOT11F_FAILED( nStatus ) )
2171 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002172 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 nStatus );
2174 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2175 return; // allocated!
2176 }
2177 else if ( DOT11F_WARNED( nStatus ) )
2178 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002179 limLog( pMac, LOGW, FL("There were warnings while packing "
2180 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
2182 }
2183
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302184 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2185 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002186
2187 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2189 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 )
2191 {
2192 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2193 }
2194
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302195 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2196 psessionEntry->peSessionId,
2197 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2199 HAL_TXRX_FRM_802_11_MGMT,
2200 ANI_TXDIR_TODS,
2201 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2202 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302203 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2204 psessionEntry->peSessionId,
2205 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2207 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002208 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 nSirStatus );
2210 //Pkt will be freed up by the callback
2211 }
2212
2213} // End limSendDeltsReqActionFrame.
2214
2215void
2216limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2217 tLimMlmAssocReq *pMlmAssocReq,
2218 tpPESession psessionEntry)
2219{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002220 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 tANI_U16 caps;
2222 tANI_U8 *pFrame;
2223 tSirRetStatus nSirStatus;
2224 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302225 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2227 void *pPacket;
2228 eHalStatus halstatus;
2229 tANI_U16 nAddIELen;
2230 tANI_U8 *pAddIE;
2231 tANI_U8 *wpsIe = NULL;
2232#if defined WLAN_FEATURE_VOWIFI
2233 tANI_U8 PowerCapsPopulated = FALSE;
2234#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302235 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302236 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002237 tDot11fIEExtCap extractedExtCap;
2238 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302239 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002240
2241 if(NULL == psessionEntry)
2242 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302243 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 return;
2245 }
2246
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 /* check this early to avoid unncessary operation */
2248 if(NULL == psessionEntry->pLimJoinReq)
2249 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302250 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 return;
2252 }
2253 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2254 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2255
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302256 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2257 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002258 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302259 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002260 return;
2261 }
2262
2263
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302264 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
Kalikinkar dhara205da782014-03-21 15:49:32 -07002266 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
2267 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
2268 &nAddIELen,
2269 &extractedExtCap );
2270 if(eSIR_SUCCESS != nSirStatus )
2271 {
2272 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2273 limLog(pMac, LOG1,
2274 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2275 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002276 /* TODO:remove this code once driver provides the call back function
2277 * to supplicant for set_qos_map
2278 */
2279 else
2280 {
2281 if(extractedExtCap.interworkingService)
2282 {
2283 extractedExtCap.qosMap = 1;
2284 }
2285 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002286
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 caps = pMlmAssocReq->capabilityInfo;
2288 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2289 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2290#if defined(FEATURE_WLAN_WAPI)
2291 /* CR: 262463 :
2292 According to WAPI standard:
2293 7.3.1.4 Capability Information field
2294 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2295 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2296 Reassociation management frames. */
2297 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2298 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2299#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002300 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002301
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002302 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2303 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002305 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306
2307 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2308 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2309
2310 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2311 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2312
2313 // We prefer .11e asociations:
2314 if ( fQosEnabled ) fWmeEnabled = false;
2315
2316 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2317 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2318
2319 if ( psessionEntry->lim11hEnable &&
2320 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2321 {
2322#if defined WLAN_FEATURE_VOWIFI
2323 PowerCapsPopulated = TRUE;
2324
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002325 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002326#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002327 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328
2329 }
2330
2331#if defined WLAN_FEATURE_VOWIFI
2332 if( pMac->rrm.rrmPEContext.rrmEnable &&
2333 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2334 {
2335 if (PowerCapsPopulated == FALSE)
2336 {
2337 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002338 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002339 }
2340 }
2341#endif
2342
2343 if ( fQosEnabled &&
2344 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002345 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002346
2347 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002348 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
2350#if defined WLAN_FEATURE_VOWIFI
2351 if( pMac->rrm.rrmPEContext.rrmEnable &&
2352 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2353 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002354 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356#endif
2357 // The join request *should* contain zero or one of the WPA and RSN
2358 // IEs. The payload send along with the request is a
2359 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2360
2361 // typedef struct sSirRSNie
2362 // {
2363 // tANI_U16 length;
2364 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2365 // } tSirRSNie, *tpSirRSNie;
2366
2367 // So, we should be able to make the following two calls harmlessly,
2368 // since they do nothing if they don't find the given IE in the
2369 // bytestream with which they're provided.
2370
2371 // The net effect of this will be to faithfully transmit whatever
2372 // security IE is in the join request.
2373
2374 // *However*, if we're associating for the purpose of WPS
2375 // enrollment, and we've been configured to indicate that by
2376 // eliding the WPA or RSN IE, we just skip this:
2377 if( nAddIELen && pAddIE )
2378 {
2379 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2380 }
2381 if ( NULL == wpsIe )
2382 {
2383 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002384 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002386 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002387#if defined(FEATURE_WLAN_WAPI)
2388 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002389 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002390#endif // defined(FEATURE_WLAN_WAPI)
2391 }
2392
2393 // include WME EDCA IE as well
2394 if ( fWmeEnabled )
2395 {
2396 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2397 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002398 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
2400
2401 if ( fWsmEnabled &&
2402 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2403 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002404 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 }
2406 }
2407
2408 //Populate HT IEs, when operating in 11n or Taurus modes AND
2409 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 pMac->lim.htCapabilityPresentInBeacon)
2412 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002413 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002414#ifdef DISABLE_GF_FOR_INTEROP
2415
2416 /*
2417 * To resolve the interop problem with Broadcom AP,
2418 * where TQ STA could not pass traffic with GF enabled,
2419 * TQ STA will do Greenfield only with TQ AP, for
2420 * everybody else it will be turned off.
2421 */
2422
2423 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2424 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302425 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2426 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002427 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 }
2429#endif
2430
2431 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002432#ifdef WLAN_FEATURE_11AC
2433 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002434 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002435 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002436 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302437 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002438 }
2439#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302440 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441
2442#if defined WLAN_FEATURE_VOWIFI_11R
2443 if (psessionEntry->pLimJoinReq->is11Rconnection)
2444 {
2445#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002446 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2448 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2449 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2450#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302451 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2452 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302454 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 {
2456 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302457 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 }
2459#endif
2460
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002461#ifdef FEATURE_WLAN_ESE
2462 /* For ESE Associations fill the ESE IEs */
2463 if (psessionEntry->isESEconnection &&
2464 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002465 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002466#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002467 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002468#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002469 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 }
2471#endif
2472
c_hpothubcd78652014-04-28 22:31:08 +05302473 /* merge the ExtCap struct*/
2474 if (extractedExtCapFlag && extractedExtCap.present)
2475 {
2476 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2477 }
2478
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002479 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 if ( DOT11F_FAILED( nStatus ) )
2481 {
2482 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002483 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002484 nStatus );
2485 // We'll fall back on the worst case scenario:
2486 nPayload = sizeof( tDot11fAssocRequest );
2487 }
2488 else if ( DOT11F_WARNED( nStatus ) )
2489 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002490 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002491 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002492 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 }
2494
2495 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2496
2497 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2498 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2499 ( void** ) &pPacket );
2500 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2501 {
2502 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002503 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002504
2505 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002506 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002507
2508
2509 /* Update PE session id*/
2510 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2511
2512 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2513
2514 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2515 ( void* ) pFrame, ( void* ) pPacket );
2516
2517 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2518 ( tANI_U32* ) &mlmAssocCnf);
2519
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302520 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 return;
2522 }
2523
2524 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302525 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002526
2527 // Next, we fill out the buffer descriptor:
2528 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2529 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2530 if ( eSIR_SUCCESS != nSirStatus )
2531 {
2532 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002533 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 nSirStatus );
2535 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302536 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 return;
2538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002539
Abhishek Singh57aebef2014-02-03 18:47:44 +05302540 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002541 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002542 sizeof(tSirMacMgmtHdr),
2543 nPayload, &nPayload );
2544 if ( DOT11F_FAILED( nStatus ) )
2545 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302546 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002547 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 nStatus );
2549 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2550 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302551 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return;
2553 }
2554 else if ( DOT11F_WARNED( nStatus ) )
2555 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302556 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2557 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
2559
2560 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002561 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 nBytes );)
2563 // limPrintMacAddr( pMac, bssid, LOG1 );
2564
2565 if( psessionEntry->assocReq != NULL )
2566 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302567 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 psessionEntry->assocReq = NULL;
2569 }
2570
2571 if( nAddIELen )
2572 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302573 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2574 pAddIE,
2575 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 nPayload += nAddIELen;
2577 }
2578
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302579 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2580 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302582 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2583 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
2585 else
2586 {
2587 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302588 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 psessionEntry->assocReqLen = nPayload;
2590 }
2591
2592 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2594 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 )
2596 {
2597 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2598 }
2599
Ganesh K08bce952012-12-13 15:04:41 -08002600 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
2601 {
2602 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2603 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302604
2605 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302606 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2607 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2608 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2609 txFlag |= HAL_USE_FW_IN_TX_PATH;
2610
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302611 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2612 psessionEntry->peSessionId,
2613 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302614
2615 // enable caching
2616 WLANTL_EnableCaching(psessionEntry->staId);
2617
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302618 if( ( psessionEntry->is11Gonly == true ) &&
2619 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2620 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2621 }
2622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2624 HAL_TXRX_FRM_802_11_MGMT,
2625 ANI_TXDIR_TODS,
2626 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2627 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302628 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2629 psessionEntry->peSessionId,
2630 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2632 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002633 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 halstatus );
2635 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302636 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 return;
2638 }
2639
2640 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302641 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002642 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302643 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002644 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645} // End limSendAssocReqMgmtFrame
2646
2647
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002648#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002649/*------------------------------------------------------------------------------------
2650 *
2651 * Send Reassoc Req with FTIEs.
2652 *
2653 *-----------------------------------------------------------------------------------
2654 */
2655void
2656limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2657 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2658{
2659 static tDot11fReAssocRequest frm;
2660 tANI_U16 caps;
2661 tANI_U8 *pFrame;
2662 tSirRetStatus nSirStatus;
2663 tANI_U32 nBytes, nPayload, nStatus;
2664 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2665 void *pPacket;
2666 eHalStatus halstatus;
2667#if defined WLAN_FEATURE_VOWIFI
2668 tANI_U8 PowerCapsPopulated = FALSE;
2669#endif
2670 tANI_U16 ft_ies_length = 0;
2671 tANI_U8 *pBody;
2672 tANI_U16 nAddIELen;
2673 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002674#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 tANI_U8 *wpsIe = NULL;
2676#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302677 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302678 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679
2680 if (NULL == psessionEntry)
2681 {
2682 return;
2683 }
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 /* check this early to avoid unncessary operation */
2686 if(NULL == psessionEntry->pLimReAssocReq)
2687 {
2688 return;
2689 }
2690 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2691 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002692 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2693 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002694
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302695 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002696
2697 caps = pMlmReassocReq->capabilityInfo;
2698 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2699 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2700#if defined(FEATURE_WLAN_WAPI)
2701 /* CR: 262463 :
2702 According to WAPI standard:
2703 7.3.1.4 Capability Information field
2704 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2705 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2706 Reassociation management frames. */
2707 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2708 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2709#endif
2710 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2711
2712 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2713
2714 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302715 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2717
2718 PopulateDot11fSSID2( pMac, &frm.SSID );
2719 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2720 &frm.SuppRates,psessionEntry);
2721
2722 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2723 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2724
2725 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2726 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2727
2728 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2729 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2730
2731 if ( psessionEntry->lim11hEnable &&
2732 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2733 {
2734#if defined WLAN_FEATURE_VOWIFI
2735 PowerCapsPopulated = TRUE;
2736
2737 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2738 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2739#endif
2740 }
2741
2742#if defined WLAN_FEATURE_VOWIFI
2743 if( pMac->rrm.rrmPEContext.rrmEnable &&
2744 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2745 {
2746 if (PowerCapsPopulated == FALSE)
2747 {
2748 PowerCapsPopulated = TRUE;
2749 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2750 }
2751 }
2752#endif
2753
2754 if ( fQosEnabled &&
2755 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2756 {
2757 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2758 }
2759
2760 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2761 &frm.ExtSuppRates, psessionEntry );
2762
2763#if defined WLAN_FEATURE_VOWIFI
2764 if( pMac->rrm.rrmPEContext.rrmEnable &&
2765 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2766 {
2767 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2768 }
2769#endif
2770
2771 // Ideally this should be enabled for 11r also. But 11r does
2772 // not follow the usual norm of using the Opaque object
2773 // for rsnie and fties. Instead we just add
2774 // the rsnie and fties at the end of the pack routine for 11r.
2775 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002776#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 //
2778 // The join request *should* contain zero or one of the WPA and RSN
2779 // IEs. The payload send along with the request is a
2780 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2781
2782 // typedef struct sSirRSNie
2783 // {
2784 // tANI_U16 length;
2785 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2786 // } tSirRSNie, *tpSirRSNie;
2787
2788 // So, we should be able to make the following two calls harmlessly,
2789 // since they do nothing if they don't find the given IE in the
2790 // bytestream with which they're provided.
2791
2792 // The net effect of this will be to faithfully transmit whatever
2793 // security IE is in the join request.
2794
2795 // *However*, if we're associating for the purpose of WPS
2796 // enrollment, and we've been configured to indicate that by
2797 // eliding the WPA or RSN IE, we just skip this:
2798 if (!psessionEntry->is11Rconnection)
2799 {
2800 if( nAddIELen && pAddIE )
2801 {
2802 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2803 }
2804 if ( NULL == wpsIe )
2805 {
2806 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2807 &frm.RSNOpaque );
2808 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2809 &frm.WPAOpaque );
2810 }
2811
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002812#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302813 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002815 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2816 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002818#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 }
2820
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002821#ifdef FEATURE_WLAN_ESE
2822 // For ESE Associations fill the ESE IEs
2823 if (psessionEntry->isESEconnection &&
2824 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002826#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002827 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002828#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002829 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002831#endif //FEATURE_WLAN_ESE
2832#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002833
2834 // include WME EDCA IE as well
2835 if ( fWmeEnabled )
2836 {
2837 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2838 {
2839 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2840 }
2841
2842 if ( fWsmEnabled &&
2843 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2844 {
2845 PopulateDot11fWMMCaps( &frm.WMMCaps );
2846 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002847#ifdef FEATURE_WLAN_ESE
2848 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 {
2850 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2851
2852 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002853 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 {
2855 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002856 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 limGetPhyMode(pMac, &phyMode, psessionEntry);
2858
2859 tsrsIE.tsid = 0;
2860 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2861 {
2862 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2863 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302864 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 {
2866 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2867 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002868 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 }
2870 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302871#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 }
2873
Jeff Johnsone7245742012-09-05 17:12:55 -07002874 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 pMac->lim.htCapabilityPresentInBeacon)
2876 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002877 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 }
2879
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002880#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302881 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2882 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002883#if defined FEATURE_WLAN_ESE
2884 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302885#endif
2886 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002887 {
2888 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2889 }
2890#endif
2891
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002892#ifdef WLAN_FEATURE_11AC
2893 if ( psessionEntry->vhtCapability &&
2894 psessionEntry->vhtCapabilityPresentInBeacon)
2895 {
2896 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302897 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002898 }
2899#endif
Sandeep Puligilla60342762014-01-30 21:05:37 +05302900 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002901
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2903 if ( DOT11F_FAILED( nStatus ) )
2904 {
2905 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002906 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 nStatus );
2908 // We'll fall back on the worst case scenario:
2909 nPayload = sizeof( tDot11fReAssocRequest );
2910 }
2911 else if ( DOT11F_WARNED( nStatus ) )
2912 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002913 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002915 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002916 }
2917
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002918 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002919
2920#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002921 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
2923#endif
2924
2925#if defined WLAN_FEATURE_VOWIFI_11R
2926 if (psessionEntry->is11Rconnection)
2927 {
2928 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
2929 }
2930#endif
2931
2932 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2933 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
2934 ( void** ) &pPacket );
2935 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2936 {
2937 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002938 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002940 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002941 goto end;
2942 }
2943
2944 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302945 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002946
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002947#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002948 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002949#endif
2950 // Next, we fill out the buffer descriptor:
2951 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2952 SIR_MAC_MGMT_REASSOC_REQ,
2953 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
2954 if ( eSIR_SUCCESS != nSirStatus )
2955 {
2956 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002957 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 nSirStatus );
2959 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2960 goto end;
2961 }
2962
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302963 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 // That done, pack the ReAssoc Request:
2965 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
2966 sizeof(tSirMacMgmtHdr),
2967 nPayload, &nPayload );
2968 if ( DOT11F_FAILED( nStatus ) )
2969 {
2970 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002971 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 nStatus );
2973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2974 goto end;
2975 }
2976 else if ( DOT11F_WARNED( nStatus ) )
2977 {
2978 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002979 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
2981
2982 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002983 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 nBytes, nPayload );)
2985 if( psessionEntry->assocReq != NULL )
2986 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302987 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002988 psessionEntry->assocReq = NULL;
2989 }
2990
2991 if( nAddIELen )
2992 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302993 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2994 pAddIE,
2995 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 nPayload += nAddIELen;
2997 }
2998
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302999 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3000 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 {
3002 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003003 }
3004 else
3005 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303007 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003010
3011 if (psessionEntry->is11Rconnection)
3012 {
3013 {
3014 int i = 0;
3015
3016 pBody = pFrame + nBytes;
3017 for (i=0; i<ft_ies_length; i++)
3018 {
3019 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3020 pBody++;
3021 }
3022 }
3023 }
3024
3025#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003026 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3027 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 (tANI_U8 *)pFrame,
3029 (nBytes + ft_ies_length));)
3030#endif
3031
3032
3033 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3035 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 )
3037 {
3038 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3039 }
3040
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003041 if( NULL != psessionEntry->assocReq )
3042 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303043 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003044 psessionEntry->assocReq = NULL;
3045 }
3046
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303047 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3048 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003049 {
3050 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003051 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003052 }
3053 else
3054 {
3055 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303056 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3057 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003058 psessionEntry->assocReqLen = (ft_ies_length);
3059 }
3060
3061
Mihir Shete63561c82014-08-23 16:58:07 +05303062 // Enable TL cahching in case of roaming
3063 WLANTL_EnableCaching(psessionEntry->staId);
3064
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303065 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3066 psessionEntry->peSessionId,
3067 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3069 HAL_TXRX_FRM_802_11_MGMT,
3070 ANI_TXDIR_TODS,
3071 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3072 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303073 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3074 psessionEntry->peSessionId,
3075 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3077 {
3078 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003079 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 nSirStatus );
3081 //Pkt will be freed up by the callback
3082 goto end;
3083 }
3084
3085end:
3086 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303087 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 psessionEntry->pLimMlmReassocReq = NULL;
3089
3090}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003091
3092void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3093 tLimMlmReassocReq *pMlmReassocReq,
3094 tpPESession psessionEntry)
3095{
3096 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3097 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
3098 if(NULL == pTmpMlmReassocReq)
3099 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303100 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3101 if ( NULL == pTmpMlmReassocReq ) goto end;
3102 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3103 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003104 }
3105
3106 // Prepare and send Reassociation request frame
3107 // start reassoc timer.
3108 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3109 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003110 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003111 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3112 != TX_SUCCESS)
3113 {
3114 // Could not start reassoc failure timer.
3115 // Log error
3116 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003117 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003118 // Return Reassoc confirm with
3119 // Resources Unavailable
3120 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3121 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3122 goto end;
3123 }
3124
3125 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3126 return;
3127
3128end:
3129 // Free up buffer allocated for reassocReq
3130 if (pMlmReassocReq != NULL)
3131 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303132 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003133 pMlmReassocReq = NULL;
3134 }
3135 if (pTmpMlmReassocReq != NULL)
3136 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303137 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003138 pTmpMlmReassocReq = NULL;
3139 }
3140 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3141 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3142 /* Update PE sessio Id*/
3143 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3144
3145 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3146}
3147
Jeff Johnson295189b2012-06-20 16:38:30 -07003148#endif /* WLAN_FEATURE_VOWIFI_11R */
3149
3150
3151void
3152limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3153 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3154{
3155 static tDot11fReAssocRequest frm;
3156 tANI_U16 caps;
3157 tANI_U8 *pFrame;
3158 tSirRetStatus nSirStatus;
3159 tANI_U32 nBytes, nPayload, nStatus;
3160 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3161 void *pPacket;
3162 eHalStatus halstatus;
3163 tANI_U16 nAddIELen;
3164 tANI_U8 *pAddIE;
3165 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303166 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003167#if defined WLAN_FEATURE_VOWIFI
3168 tANI_U8 PowerCapsPopulated = FALSE;
3169#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303170 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171
3172 if(NULL == psessionEntry)
3173 {
3174 return;
3175 }
3176
3177 /* check this early to avoid unncessary operation */
3178 if(NULL == psessionEntry->pLimReAssocReq)
3179 {
3180 return;
3181 }
3182 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3183 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3184
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303185 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003186
3187 caps = pMlmReassocReq->capabilityInfo;
3188 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3189 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3190#if defined(FEATURE_WLAN_WAPI)
3191 /* CR: 262463 :
3192 According to WAPI standard:
3193 7.3.1.4 Capability Information field
3194 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3195 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3196 Reassociation management frames. */
3197 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3198 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3199#endif
3200 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3201
3202 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3203
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303204 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3205 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003206
3207 PopulateDot11fSSID2( pMac, &frm.SSID );
3208 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3209 &frm.SuppRates,psessionEntry);
3210
3211 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3212 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3213
3214 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3215 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3216
3217 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3218 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3219
3220
3221 if ( psessionEntry->lim11hEnable &&
3222 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3223 {
3224#if defined WLAN_FEATURE_VOWIFI
3225 PowerCapsPopulated = TRUE;
3226 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3227 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3228#endif
3229 }
3230
3231#if defined WLAN_FEATURE_VOWIFI
3232 if( pMac->rrm.rrmPEContext.rrmEnable &&
3233 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3234 {
3235 if (PowerCapsPopulated == FALSE)
3236 {
3237 PowerCapsPopulated = TRUE;
3238 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3239 }
3240 }
3241#endif
3242
3243 if ( fQosEnabled &&
3244 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3245 {
3246 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3247 }
3248
3249 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3250 &frm.ExtSuppRates, psessionEntry );
3251
3252#if defined WLAN_FEATURE_VOWIFI
3253 if( pMac->rrm.rrmPEContext.rrmEnable &&
3254 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3255 {
3256 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3257 }
3258#endif
3259 // The join request *should* contain zero or one of the WPA and RSN
3260 // IEs. The payload send along with the request is a
3261 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3262
3263 // typedef struct sSirRSNie
3264 // {
3265 // tANI_U16 length;
3266 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3267 // } tSirRSNie, *tpSirRSNie;
3268
3269 // So, we should be able to make the following two calls harmlessly,
3270 // since they do nothing if they don't find the given IE in the
3271 // bytestream with which they're provided.
3272
3273 // The net effect of this will be to faithfully transmit whatever
3274 // security IE is in the join request.
3275
3276 // *However*, if we're associating for the purpose of WPS
3277 // enrollment, and we've been configured to indicate that by
3278 // eliding the WPA or RSN IE, we just skip this:
3279 if( nAddIELen && pAddIE )
3280 {
3281 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3282 }
3283 if ( NULL == wpsIe )
3284 {
3285 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3286 &frm.RSNOpaque );
3287 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3288 &frm.WPAOpaque );
3289#if defined(FEATURE_WLAN_WAPI)
3290 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3291 &frm.WAPIOpaque );
3292#endif // defined(FEATURE_WLAN_WAPI)
3293 }
3294
3295 // include WME EDCA IE as well
3296 if ( fWmeEnabled )
3297 {
3298 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3299 {
3300 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3301 }
3302
3303 if ( fWsmEnabled &&
3304 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3305 {
3306 PopulateDot11fWMMCaps( &frm.WMMCaps );
3307 }
3308 }
3309
Jeff Johnsone7245742012-09-05 17:12:55 -07003310 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 pMac->lim.htCapabilityPresentInBeacon)
3312 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003313 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003315#ifdef WLAN_FEATURE_11AC
3316 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003317 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003318 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003319 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05303320 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps, eSIR_FALSE );
Sandeep Puligilla60342762014-01-30 21:05:37 +05303321 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003322 }
3323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003324
3325 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3326 if ( DOT11F_FAILED( nStatus ) )
3327 {
3328 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003329 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 nStatus );
3331 // We'll fall back on the worst case scenario:
3332 nPayload = sizeof( tDot11fReAssocRequest );
3333 }
3334 else if ( DOT11F_WARNED( nStatus ) )
3335 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003336 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003338 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 }
3340
3341 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3342
3343 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3344 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3345 ( void** ) &pPacket );
3346 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3347 {
3348 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003349 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003351 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 goto end;
3353 }
3354
3355 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303356 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003357
3358 // Next, we fill out the buffer descriptor:
3359 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3360 SIR_MAC_MGMT_REASSOC_REQ,
3361 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3362 if ( eSIR_SUCCESS != nSirStatus )
3363 {
3364 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003365 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 nSirStatus );
3367 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3368 goto end;
3369 }
3370
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303371 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 // That done, pack the Probe Request:
3373 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3374 sizeof(tSirMacMgmtHdr),
3375 nPayload, &nPayload );
3376 if ( DOT11F_FAILED( nStatus ) )
3377 {
3378 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003379 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 nStatus );
3381 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3382 goto end;
3383 }
3384 else if ( DOT11F_WARNED( nStatus ) )
3385 {
3386 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003387 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 }
3389
3390 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003391 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 nBytes );)
3393
3394 if( psessionEntry->assocReq != NULL )
3395 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303396 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 psessionEntry->assocReq = NULL;
3398 }
3399
3400 if( nAddIELen )
3401 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303402 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3403 pAddIE,
3404 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 nPayload += nAddIELen;
3406 }
3407
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303408 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3409 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 {
3411 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003412 }
3413 else
3414 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303416 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003419
3420 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003421 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3422 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 )
3424 {
3425 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3426 }
3427
Gopichand Nakkalad3918dd2012-12-31 16:27:55 -08003428 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003429 {
3430 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3431 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003432
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303433 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3434 psessionEntry->peSessionId,
3435 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303436
3437 // enable caching
3438 WLANTL_EnableCaching(psessionEntry->staId);
3439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3441 HAL_TXRX_FRM_802_11_MGMT,
3442 ANI_TXDIR_TODS,
3443 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3444 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303445 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3446 psessionEntry->peSessionId,
3447 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3449 {
3450 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003451 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 nSirStatus );
3453 //Pkt will be freed up by the callback
3454 goto end;
3455 }
3456
3457end:
3458 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303459 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 psessionEntry->pLimMlmReassocReq = NULL;
3461
3462} // limSendReassocReqMgmtFrame
3463
3464/**
3465 * \brief Send an Authentication frame
3466 *
3467 *
3468 * \param pMac Pointer to Global MAC structure
3469 *
3470 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3471 * to be sent
3472 *
3473 * \param peerMacAddr MAC address of the peer entity to which Authentication
3474 * frame is destined
3475 *
3476 * \param wepBit Indicates whether wep bit to be set in FC while sending
3477 * Authentication frame3
3478 *
3479 *
3480 * This function is called by limProcessMlmMessages(). Authentication frame
3481 * is formatted and sent when this function is called.
3482 *
3483 *
3484 */
3485
3486void
3487limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3488 tpSirMacAuthFrameBody pAuthFrameBody,
3489 tSirMacAddr peerMacAddr,
3490 tANI_U8 wepBit,
3491 tpPESession psessionEntry
3492 )
3493{
3494 tANI_U8 *pFrame, *pBody;
3495 tANI_U32 frameLen = 0, bodyLen = 0;
3496 tpSirMacMgmtHdr pMacHdr;
3497 tANI_U16 i;
3498 void *pPacket;
3499 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303500 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003501
3502 if(NULL == psessionEntry)
3503 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303504 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 return;
3506 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303507
3508 limLog(pMac, LOG1,
3509 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3510 pAuthFrameBody->authTransactionSeqNumber,
3511 pAuthFrameBody->authStatusCode,
3512 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3513 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 if (wepBit == LIM_WEP_IN_FC)
3515 {
3516 /// Auth frame3 to be sent with encrypted framebody
3517 /**
3518 * Allocate buffer for Authenticaton frame of size equal
3519 * to management frame header length plus 2 bytes each for
3520 * auth algorithm number, transaction number, status code,
3521 * 128 bytes for challenge text and 4 bytes each for
3522 * IV & ICV.
3523 */
3524
3525 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3526
3527 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3528 } // if (wepBit == LIM_WEP_IN_FC)
3529 else
3530 {
3531 switch (pAuthFrameBody->authTransactionSeqNumber)
3532 {
3533 case SIR_MAC_AUTH_FRAME_1:
3534 /**
3535 * Allocate buffer for Authenticaton frame of size
3536 * equal to management frame header length plus 2 bytes
3537 * each for auth algorithm number, transaction number
3538 * and status code.
3539 */
3540
3541 frameLen = sizeof(tSirMacMgmtHdr) +
3542 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3543 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3544
3545#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003546 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3547 {
3548 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003550 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003551 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003552 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003554 else
3555 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303556 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3557 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003558 frameLen += (2+SIR_MDIE_SIZE);
3559 }
3560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003561#endif
3562 break;
3563
3564 case SIR_MAC_AUTH_FRAME_2:
3565 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3566 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3567 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3568 {
3569 /**
3570 * Allocate buffer for Authenticaton frame of size
3571 * equal to management frame header length plus
3572 * 2 bytes each for auth algorithm number,
3573 * transaction number and status code.
3574 */
3575
3576 frameLen = sizeof(tSirMacMgmtHdr) +
3577 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3578 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3579 }
3580 else
3581 {
3582 // Shared Key algorithm with challenge text
3583 // to be sent
3584 /**
3585 * Allocate buffer for Authenticaton frame of size
3586 * equal to management frame header length plus
3587 * 2 bytes each for auth algorithm number,
3588 * transaction number, status code and 128 bytes
3589 * for challenge text.
3590 */
3591
3592 frameLen = sizeof(tSirMacMgmtHdr) +
3593 sizeof(tSirMacAuthFrame);
3594 bodyLen = sizeof(tSirMacAuthFrameBody);
3595 }
3596
3597 break;
3598
3599 case SIR_MAC_AUTH_FRAME_3:
3600 /// Auth frame3 to be sent without encrypted framebody
3601 /**
3602 * Allocate buffer for Authenticaton frame of size equal
3603 * to management frame header length plus 2 bytes each
3604 * for auth algorithm number, transaction number and
3605 * status code.
3606 */
3607
3608 frameLen = sizeof(tSirMacMgmtHdr) +
3609 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3610 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3611
3612 break;
3613
3614 case SIR_MAC_AUTH_FRAME_4:
3615 /**
3616 * Allocate buffer for Authenticaton frame of size equal
3617 * to management frame header length plus 2 bytes each
3618 * for auth algorithm number, transaction number and
3619 * status code.
3620 */
3621
3622 frameLen = sizeof(tSirMacMgmtHdr) +
3623 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3624 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3625
3626 break;
3627 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3628 } // end if (wepBit == LIM_WEP_IN_FC)
3629
3630
3631 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3632
3633 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3634 {
3635 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003636 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003637
3638 return;
3639 }
3640
3641 for (i = 0; i < frameLen; i++)
3642 pFrame[i] = 0;
3643
3644 // Prepare BD
3645 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3646 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3647 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303648 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3649 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3651 return;
3652 }
3653
3654 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3655 pMacHdr->fc.wep = wepBit;
3656
3657 // Prepare BSSId
3658 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3659 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303660 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3661 (tANI_U8 *) psessionEntry->bssId,
3662 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 }
3664
3665 /// Prepare Authentication frame body
3666 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3667
3668 if (wepBit == LIM_WEP_IN_FC)
3669 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303670 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303672 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303673 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303675 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303676 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003677
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 }
3679 else
3680 {
3681 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3682 pBody += sizeof(tANI_U16);
3683 bodyLen -= sizeof(tANI_U16);
3684
3685 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3686 pBody += sizeof(tANI_U16);
3687 bodyLen -= sizeof(tANI_U16);
3688
3689 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3690 pBody += sizeof(tANI_U16);
3691 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003692 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3693 sizeof (pAuthFrameBody->length) +
3694 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303695 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003696
3697#if defined WLAN_FEATURE_VOWIFI_11R
3698 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3699 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3700 {
3701
3702 {
3703 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3705 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003706#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003707 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3708 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 (tANI_U8 *)pBody,
3710 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003711#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003712 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3713 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003714 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3715 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003716 }
3717 }
3718 else
3719 {
3720 /* MDID attr is 54*/
3721 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003723 *pBody = SIR_MDIE_SIZE;
3724 pBody++;
3725 for(i=0;i<SIR_MDIE_SIZE;i++)
3726 {
3727 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3728 pBody++;
3729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 }
3731 }
3732 }
3733#endif
3734
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303735 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303736 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 pAuthFrameBody->authTransactionSeqNumber,
3738 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303739 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303740 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 }
3742 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3743
3744 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3746 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003747#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303748 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003749 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 )
3752 {
3753 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3754 }
3755
Ganesh K08bce952012-12-13 15:04:41 -08003756 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE)
3757 {
3758 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3759 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003760
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303761 limLog( pMac, LOG1, FL("Sending Auth Frame over WQ5 to "MAC_ADDRESS_STR
3762 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
3763 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3764
3765 txFlag |= HAL_USE_FW_IN_TX_PATH;
3766
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303767 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3768 psessionEntry->peSessionId,
3769 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303770
3771 if( ( psessionEntry->is11Gonly == true ) &&
3772 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3773 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3774 }
3775
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 /// Queue Authentication frame in high priority WQ
3777 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
3778 HAL_TXRX_FRM_802_11_MGMT,
3779 ANI_TXDIR_TODS,
3780 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3781 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303782 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3783 psessionEntry->peSessionId,
3784 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3786 {
3787 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003788 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 halstatus);
3790
3791 //Pkt will be freed up by the callback
3792 }
3793
3794 return;
3795} /*** end limSendAuthMgmtFrame() ***/
3796
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003797eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
3798{
3799 tANI_U16 aid;
3800 tpDphHashNode pStaDs;
3801 tLimMlmDeauthReq *pMlmDeauthReq;
3802 tLimMlmDeauthCnf mlmDeauthCnf;
3803 tpPESession psessionEntry;
3804
3805 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
3806 if (pMlmDeauthReq)
3807 {
3808 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
3809 {
3810 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
3811 }
3812
3813 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
3814 {
3815
3816 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003817 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003818 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3819 goto end;
3820 }
3821
3822 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3823 if (pStaDs == NULL)
3824 {
3825 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3826 goto end;
3827 }
3828
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003829 /// Receive path cleanup with dummy packet
3830 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303831
3832#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303833 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303834 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303835 PELOGE(limLog(pMac, LOG1,
3836 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303837#ifdef FEATURE_WLAN_ESE
3838 " isESE %d"
3839#endif
3840#ifdef FEATURE_WLAN_LFR
3841 " isLFR %d"
3842#endif
3843 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303844 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303845#ifdef FEATURE_WLAN_ESE
3846 psessionEntry->isESEconnection,
3847#endif
3848#ifdef FEATURE_WLAN_LFR
3849 psessionEntry->isFastRoamIniFeatureEnabled,
3850#endif
3851 psessionEntry->is11Rconnection,
3852 pMlmDeauthReq->reasonCode,
3853 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303854
3855 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05303856 }
3857#endif
3858
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003859 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303860 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003861 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
3862 }
3863 return eHAL_STATUS_SUCCESS;
3864end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303865 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003866 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
3867 sizeof(tSirMacAddr));
3868 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
3869 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
3870 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
3871
3872 // Free up buffer allocated
3873 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303874 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003875
3876 limPostSmeMessage(pMac,
3877 LIM_MLM_DEAUTH_CNF,
3878 (tANI_U32 *) &mlmDeauthCnf);
3879 return eHAL_STATUS_SUCCESS;
3880}
3881
3882eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
3883{
3884 tANI_U16 aid;
3885 tpDphHashNode pStaDs;
3886 tLimMlmDisassocCnf mlmDisassocCnf;
3887 tpPESession psessionEntry;
3888 tLimMlmDisassocReq *pMlmDisassocReq;
3889
3890 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
3891 if (pMlmDisassocReq)
3892 {
3893 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
3894 {
3895 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
3896 }
3897
3898 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
3899 {
3900
3901 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003902 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003903 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3904 goto end;
3905 }
3906
3907 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
3908 if (pStaDs == NULL)
3909 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303910 limLog(pMac, LOGE,
3911 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003912 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
3913 goto end;
3914 }
3915
3916 /// Receive path cleanup with dummy packet
3917 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
3918 {
3919 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05303920 limLog(pMac, LOGE,
3921 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003922 goto end;
3923 }
3924
3925#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003926 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303927 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003928 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003929 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303930 PELOGE(limLog(pMac, LOG1,
3931 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003932#ifdef FEATURE_WLAN_ESE
3933 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003934#endif
3935#ifdef FEATURE_WLAN_LFR
3936 " isLFR %d"
3937#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003938 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303939 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003940#ifdef FEATURE_WLAN_ESE
3941 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08003942#endif
3943#ifdef FEATURE_WLAN_LFR
3944 psessionEntry->isFastRoamIniFeatureEnabled,
3945#endif
3946 psessionEntry->is11Rconnection,
3947 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05303948 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003949 }
3950#endif
3951
3952 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303953 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003954 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3955 return eHAL_STATUS_SUCCESS;
3956 }
3957 else
3958 {
3959 return eHAL_STATUS_SUCCESS;
3960 }
3961end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303962 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003963 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
3964 sizeof(tSirMacAddr));
3965 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
3966 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
3967
3968 /* Update PE session ID*/
3969 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
3970
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003971 if(pMlmDisassocReq != NULL)
3972 {
3973 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303974 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08003975 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
3976 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08003977
3978 limPostSmeMessage(pMac,
3979 LIM_MLM_DISASSOC_CNF,
3980 (tANI_U32 *) &mlmDisassocCnf);
3981 return eHAL_STATUS_SUCCESS;
3982}
3983
3984eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3985{
3986 return limSendDisassocCnf(pMac);
3987}
3988
3989eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, tANI_U32 txCompleteSuccess)
3990{
3991 return limSendDeauthCnf(pMac);
3992}
3993
Jeff Johnson295189b2012-06-20 16:38:30 -07003994/**
3995 * \brief This function is called to send Disassociate frame.
3996 *
3997 *
3998 * \param pMac Pointer to Global MAC structure
3999 *
4000 * \param nReason Indicates the reason that need to be sent in
4001 * Disassociation frame
4002 *
4003 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4004 * sent
4005 *
4006 *
4007 */
4008
4009void
4010limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4011 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004012 tSirMacAddr peer,
4013 tpPESession psessionEntry,
4014 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004015{
4016 tDot11fDisassociation frm;
4017 tANI_U8 *pFrame;
4018 tSirRetStatus nSirStatus;
4019 tpSirMacMgmtHdr pMacHdr;
4020 tANI_U32 nBytes, nPayload, nStatus;
4021 void *pPacket;
4022 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304023 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004024 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 if(NULL == psessionEntry)
4026 {
4027 return;
4028 }
4029
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304030 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004031
4032 frm.Reason.code = nReason;
4033
4034 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4035 if ( DOT11F_FAILED( nStatus ) )
4036 {
4037 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004038 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 nStatus );
4040 // We'll fall back on the worst case scenario:
4041 nPayload = sizeof( tDot11fDisassociation );
4042 }
4043 else if ( DOT11F_WARNED( nStatus ) )
4044 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004045 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004047 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 }
4049
4050 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4051
4052 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4053 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4054 ( void** ) &pPacket );
4055 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4056 {
4057 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004058 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 return;
4060 }
4061
4062 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304063 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004064
4065 // Next, we fill out the buffer descriptor:
4066 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4067 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4068 if ( eSIR_SUCCESS != nSirStatus )
4069 {
4070 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004071 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 nSirStatus );
4073 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4074 ( void* ) pFrame, ( void* ) pPacket );
4075 return; // just allocated...
4076 }
4077
4078 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4079
4080 // Prepare the BSSID
4081 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4082
Chet Lanctot186b5732013-03-18 10:26:30 -07004083#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004084 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004085#endif
4086
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4088 sizeof(tSirMacMgmtHdr),
4089 nPayload, &nPayload );
4090 if ( DOT11F_FAILED( nStatus ) )
4091 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004092 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 nStatus );
4094 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4095 ( void* ) pFrame, ( void* ) pPacket );
4096 return; // allocated!
4097 }
4098 else if ( DOT11F_WARNED( nStatus ) )
4099 {
4100 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004101 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 }
4103
Abhishek Singhcd09b562013-12-24 16:02:20 +05304104 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4105 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4106 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4107 MAC_ADDR_ARRAY(pMacHdr->da),
4108 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004109
4110 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4112 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 )
4114 {
4115 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4116 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004117
Ganesh K08bce952012-12-13 15:04:41 -08004118 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304119 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4120 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004121 {
4122 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4123 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004124
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304125 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4126 {
4127 /* This frame will be sent on air by firmware,
4128 which will ensure that this frame goes out
4129 even though DEL_STA is sent immediately */
4130 /* Without this for DEL_STA command there is
4131 risk of flushing frame in BTQM queue without
4132 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304133 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4134 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4135 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304136 txFlag |= HAL_USE_FW_IN_TX_PATH;
4137 }
4138
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004139 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304141 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4142 psessionEntry->peSessionId,
4143 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004144 // Queue Disassociation frame in high priority WQ
4145 /* get the duration from the request */
4146 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4147 HAL_TXRX_FRM_802_11_MGMT,
4148 ANI_TXDIR_TODS,
4149 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4150 limTxComplete, pFrame, limDisassocTxCompleteCnf,
4151 txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304152 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4153 psessionEntry->peSessionId,
4154 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004155 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004156
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004157 if (tx_timer_change(
4158 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4159 != TX_SUCCESS)
4160 {
4161 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004162 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004163 return;
4164 }
4165 else if(TX_SUCCESS != tx_timer_activate(
4166 &pMac->lim.limTimers.gLimDisassocAckTimer))
4167 {
4168 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004169 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004170 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4171 return;
4172 }
4173 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004174 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004175 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304176 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4177 psessionEntry->peSessionId,
4178 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004179 // Queue Disassociation frame in high priority WQ
4180 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4181 HAL_TXRX_FRM_802_11_MGMT,
4182 ANI_TXDIR_TODS,
4183 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4184 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304185 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4186 psessionEntry->peSessionId,
4187 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004188 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4189 {
4190 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004191 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004192 nSirStatus );
4193 //Pkt will be freed up by the callback
4194 return;
4195 }
4196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004197} // End limSendDisassocMgmtFrame.
4198
4199/**
4200 * \brief This function is called to send a Deauthenticate frame
4201 *
4202 *
4203 * \param pMac Pointer to global MAC structure
4204 *
4205 * \param nReason Indicates the reason that need to be sent in the
4206 * Deauthenticate frame
4207 *
4208 * \param peeer address of the STA to which the frame is to be sent
4209 *
4210 *
4211 */
4212
4213void
4214limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4215 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004216 tSirMacAddr peer,
4217 tpPESession psessionEntry,
4218 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004219{
4220 tDot11fDeAuth frm;
4221 tANI_U8 *pFrame;
4222 tSirRetStatus nSirStatus;
4223 tpSirMacMgmtHdr pMacHdr;
4224 tANI_U32 nBytes, nPayload, nStatus;
4225 void *pPacket;
4226 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304227 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004228 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004229#ifdef FEATURE_WLAN_TDLS
4230 tANI_U16 aid;
4231 tpDphHashNode pStaDs;
4232#endif
4233
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 if(NULL == psessionEntry)
4235 {
4236 return;
4237 }
4238
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304239 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 frm.Reason.code = nReason;
4242
4243 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4244 if ( DOT11F_FAILED( nStatus ) )
4245 {
4246 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004247 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004248 nStatus );
4249 // We'll fall back on the worst case scenario:
4250 nPayload = sizeof( tDot11fDeAuth );
4251 }
4252 else if ( DOT11F_WARNED( nStatus ) )
4253 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004254 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004256 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 }
4258
4259 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4260
4261 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4262 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4263 ( void** ) &pPacket );
4264 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4265 {
4266 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004267 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004268 return;
4269 }
4270
4271 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304272 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004273
4274 // Next, we fill out the buffer descriptor:
4275 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4276 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4277 if ( eSIR_SUCCESS != nSirStatus )
4278 {
4279 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004280 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004281 nSirStatus );
4282 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4283 ( void* ) pFrame, ( void* ) pPacket );
4284 return; // just allocated...
4285 }
4286
4287 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4288
4289 // Prepare the BSSID
4290 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4291
Chet Lanctot186b5732013-03-18 10:26:30 -07004292#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004293 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004294#endif
4295
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4297 sizeof(tSirMacMgmtHdr),
4298 nPayload, &nPayload );
4299 if ( DOT11F_FAILED( nStatus ) )
4300 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004301 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 nStatus );
4303 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4304 ( void* ) pFrame, ( void* ) pPacket );
4305 return;
4306 }
4307 else if ( DOT11F_WARNED( nStatus ) )
4308 {
4309 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004310 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304312 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4313 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4314 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4315 MAC_ADDR_ARRAY(pMacHdr->da),
4316 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004317
4318 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4320 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 )
4322 {
4323 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4324 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004325
Ganesh K08bce952012-12-13 15:04:41 -08004326 if((psessionEntry->pePersona == VOS_P2P_CLIENT_MODE) ||
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304327 (psessionEntry->pePersona == VOS_P2P_GO_MODE) ||
4328 (psessionEntry->pePersona == VOS_STA_SAP_MODE))
Ganesh K08bce952012-12-13 15:04:41 -08004329 {
4330 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
4331 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004332
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304333 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4334 {
4335 /* This frame will be sent on air by firmware,
4336 which will ensure that this frame goes out
4337 even though DEL_STA is sent immediately */
4338 /* Without this for DEL_STA command there is
4339 risk of flushing frame in BTQM queue without
4340 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304341 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4342 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4343 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304344 txFlag |= HAL_USE_FW_IN_TX_PATH;
4345 }
4346
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004347#ifdef FEATURE_WLAN_TDLS
4348 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4349#endif
4350
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004351 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304353 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4354 psessionEntry->peSessionId,
4355 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004356 // Queue Disassociation frame in high priority WQ
4357 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4358 HAL_TXRX_FRM_802_11_MGMT,
4359 ANI_TXDIR_TODS,
4360 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4361 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304362 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4363 psessionEntry->peSessionId,
4364 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304365 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004366 {
4367 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304368 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004369 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004370 //Pkt will be freed up by the callback limTxComplete
4371
4372 /*Call limProcessDeauthAckTimeout which will send
4373 * DeauthCnf for this frame
4374 */
4375 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004376 return;
4377 }
4378
4379 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4380
4381 if (tx_timer_change(
4382 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4383 != TX_SUCCESS)
4384 {
4385 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004386 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004387 return;
4388 }
4389 else if(TX_SUCCESS != tx_timer_activate(
4390 &pMac->lim.limTimers.gLimDeauthAckTimer))
4391 {
4392 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004393 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004394 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4395 return;
4396 }
4397 }
4398 else
4399 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304400 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4401 psessionEntry->peSessionId,
4402 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004403#ifdef FEATURE_WLAN_TDLS
4404 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4405 {
4406 // Queue Disassociation frame in high priority WQ
4407 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004408 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004409 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004410 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4411 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004412 }
4413 else
4414 {
4415#endif
4416 // Queue Disassociation frame in high priority WQ
4417 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4418 HAL_TXRX_FRM_802_11_MGMT,
4419 ANI_TXDIR_TODS,
4420 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4421 limTxComplete, pFrame, txFlag );
4422#ifdef FEATURE_WLAN_TDLS
4423 }
4424#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304425 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4426 psessionEntry->peSessionId,
4427 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004428 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4429 {
4430 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004431 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004432 nSirStatus );
4433 //Pkt will be freed up by the callback
4434 return;
4435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 }
4437
4438} // End limSendDeauthMgmtFrame.
4439
4440
4441#ifdef ANI_SUPPORT_11H
4442/**
4443 * \brief Send a Measurement Report Action frame
4444 *
4445 *
4446 * \param pMac Pointer to the global MAC structure
4447 *
4448 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4449 *
4450 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4451 *
4452 *
4453 */
4454
4455tSirRetStatus
4456limSendMeasReportFrame(tpAniSirGlobal pMac,
4457 tpSirMacMeasReqActionFrame pMeasReqFrame,
4458 tSirMacAddr peer)
4459{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304460 tDot11fMeasurementReport frm;
4461 tANI_U8 *pFrame;
4462 tSirRetStatus nSirStatus;
4463 tpSirMacMgmtHdr pMacHdr;
4464 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4465 void *pPacket;
4466 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304468 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004469
4470 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4471 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4472 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4473
4474 switch ( pMeasReqFrame->measReqIE.measType )
4475 {
4476 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4477 nSirStatus =
4478 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4479 &frm.MeasurementReport );
4480 break;
4481 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4482 nSirStatus =
4483 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4484 &frm.MeasurementReport );
4485 break;
4486 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4487 nSirStatus =
4488 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4489 &frm.MeasurementReport );
4490 break;
4491 default:
4492 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004493 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004494 pMeasReqFrame->measReqIE.measType );
4495 return eSIR_FAILURE;
4496 }
4497
4498 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4499
4500 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4501 if ( DOT11F_FAILED( nStatus ) )
4502 {
4503 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004504 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 nStatus );
4506 // We'll fall back on the worst case scenario:
4507 nPayload = sizeof( tDot11fMeasurementReport );
4508 }
4509 else if ( DOT11F_WARNED( nStatus ) )
4510 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004511 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004513 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 }
4515
4516 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4517
4518 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4519 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4520 {
4521 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004522 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 return eSIR_FAILURE;
4524 }
4525
4526 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304527 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004528
4529 // Next, we fill out the buffer descriptor:
4530 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4531 SIR_MAC_MGMT_ACTION, peer);
4532 if ( eSIR_SUCCESS != nSirStatus )
4533 {
4534 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004535 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 nSirStatus );
4537 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4538 return eSIR_FAILURE; // just allocated...
4539 }
4540
4541 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4542
4543 nCfg = 6;
4544 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4545 if ( eSIR_SUCCESS != nSirStatus )
4546 {
4547 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004548 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 nSirStatus );
4550 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4551 return eSIR_FAILURE; // just allocated...
4552 }
4553
Chet Lanctot186b5732013-03-18 10:26:30 -07004554#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004555 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004556#endif
4557
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4559 sizeof(tSirMacMgmtHdr),
4560 nPayload, &nPayload );
4561 if ( DOT11F_FAILED( nStatus ) )
4562 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004563 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 nStatus );
4565 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4566 return eSIR_FAILURE; // allocated!
4567 }
4568 else if ( DOT11F_WARNED( nStatus ) )
4569 {
4570 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004571 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 }
4573
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304574 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4575 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4576 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4578 HAL_TXRX_FRM_802_11_MGMT,
4579 ANI_TXDIR_TODS,
4580 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4581 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304582 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4583 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4584 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4586 {
4587 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004588 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 nSirStatus );
4590 //Pkt will be freed up by the callback
4591 return eSIR_FAILURE; // just allocated...
4592 }
4593
4594 return eSIR_SUCCESS;
4595
4596} // End limSendMeasReportFrame.
4597
4598
4599/**
4600 * \brief Send a TPC Request Action frame
4601 *
4602 *
4603 * \param pMac Pointer to the global MAC datastructure
4604 *
4605 * \param peer MAC address to which the frame should be sent
4606 *
4607 *
4608 */
4609
4610void
4611limSendTpcRequestFrame(tpAniSirGlobal pMac,
4612 tSirMacAddr peer)
4613{
4614 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304615 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 tSirRetStatus nSirStatus;
4617 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304618 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4619 void *pPacket;
4620 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004621
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304622 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004623
4624 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4625 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4626 frm.DialogToken.token = 1;
4627 frm.TPCRequest.present = 1;
4628
4629 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4630 if ( DOT11F_FAILED( nStatus ) )
4631 {
4632 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004633 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 nStatus );
4635 // We'll fall back on the worst case scenario:
4636 nPayload = sizeof( tDot11fTPCRequest );
4637 }
4638 else if ( DOT11F_WARNED( nStatus ) )
4639 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004640 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004642 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 }
4644
4645 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4646
4647 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4648 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4649 {
4650 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004651 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 return;
4653 }
4654
4655 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304656 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004657
4658 // Next, we fill out the buffer descriptor:
4659 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4660 SIR_MAC_MGMT_ACTION, peer);
4661 if ( eSIR_SUCCESS != nSirStatus )
4662 {
4663 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004664 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 nSirStatus );
4666 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4667 return; // just allocated...
4668 }
4669
4670 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4671
4672 nCfg = 6;
4673 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4674 if ( eSIR_SUCCESS != nSirStatus )
4675 {
4676 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004677 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 nSirStatus );
4679 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4680 return; // just allocated...
4681 }
4682
Chet Lanctot186b5732013-03-18 10:26:30 -07004683#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004684 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004685#endif
4686
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4688 sizeof(tSirMacMgmtHdr),
4689 nPayload, &nPayload );
4690 if ( DOT11F_FAILED( nStatus ) )
4691 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004692 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 nStatus );
4694 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4695 return; // allocated!
4696 }
4697 else if ( DOT11F_WARNED( nStatus ) )
4698 {
4699 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004700 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 }
4702
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304703 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4704 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4705 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4707 HAL_TXRX_FRM_802_11_MGMT,
4708 ANI_TXDIR_TODS,
4709 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4710 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304711 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4712 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4713 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4715 {
4716 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004717 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 nSirStatus );
4719 //Pkt will be freed up by the callback
4720 return;
4721 }
4722
4723} // End limSendTpcRequestFrame.
4724
4725
4726/**
4727 * \brief Send a TPC Report Action frame
4728 *
4729 *
4730 * \param pMac Pointer to the global MAC datastructure
4731 *
4732 * \param pTpcReqFrame Pointer to the received TPC Request
4733 *
4734 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4735 *
4736 *
4737 */
4738
4739tSirRetStatus
4740limSendTpcReportFrame(tpAniSirGlobal pMac,
4741 tpSirMacTpcReqActionFrame pTpcReqFrame,
4742 tSirMacAddr peer)
4743{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304744 tDot11fTPCReport frm;
4745 tANI_U8 *pFrame;
4746 tSirRetStatus nSirStatus;
4747 tpSirMacMgmtHdr pMacHdr;
4748 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4749 void *pPacket;
4750 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004751
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304752 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004753
4754 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4755 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4756 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4757
4758 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4759 // "misplaced this function, need to replace:
4760 // txPower = halGetRateToPwrValue(pMac, staid,
4761 // pMac->lim.gLimCurrentChannelId, 0);
4762 frm.TPCReport.tx_power = 0;
4763 frm.TPCReport.link_margin = 0;
4764 frm.TPCReport.present = 1;
4765
4766 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4767 if ( DOT11F_FAILED( nStatus ) )
4768 {
4769 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004770 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 nStatus );
4772 // We'll fall back on the worst case scenario:
4773 nPayload = sizeof( tDot11fTPCReport );
4774 }
4775 else if ( DOT11F_WARNED( nStatus ) )
4776 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004777 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004779 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004780 }
4781
4782 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4783
4784 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4785 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4786 {
4787 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004788 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 return eSIR_FAILURE;
4790 }
4791
4792 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304793 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004794
4795 // Next, we fill out the buffer descriptor:
4796 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4797 SIR_MAC_MGMT_ACTION, peer);
4798 if ( eSIR_SUCCESS != nSirStatus )
4799 {
4800 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004801 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 nSirStatus );
4803 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4804 return eSIR_FAILURE; // just allocated...
4805 }
4806
4807 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4808
4809 nCfg = 6;
4810 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4811 if ( eSIR_SUCCESS != nSirStatus )
4812 {
4813 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004814 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 nSirStatus );
4816 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4817 return eSIR_FAILURE; // just allocated...
4818 }
4819
Chet Lanctot186b5732013-03-18 10:26:30 -07004820#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004821 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004822#endif
4823
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
4825 sizeof(tSirMacMgmtHdr),
4826 nPayload, &nPayload );
4827 if ( DOT11F_FAILED( nStatus ) )
4828 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004829 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 nStatus );
4831 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4832 return eSIR_FAILURE; // allocated!
4833 }
4834 else if ( DOT11F_WARNED( nStatus ) )
4835 {
4836 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004837 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 }
4839
4840
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304841 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4842 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4843 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004844 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4845 HAL_TXRX_FRM_802_11_MGMT,
4846 ANI_TXDIR_TODS,
4847 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4848 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304849 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4850 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4851 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4853 {
4854 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004855 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 nSirStatus );
4857 //Pkt will be freed up by the callback
4858 return eSIR_FAILURE; // just allocated...
4859 }
4860
4861 return eSIR_SUCCESS;
4862
4863} // End limSendTpcReportFrame.
4864#endif //ANI_SUPPORT_11H
4865
4866
Jeff Johnson295189b2012-06-20 16:38:30 -07004867/**
4868 * \brief Send a Channel Switch Announcement
4869 *
4870 *
4871 * \param pMac Pointer to the global MAC datastructure
4872 *
4873 * \param peer MAC address to which this frame will be sent
4874 *
4875 * \param nMode
4876 *
4877 * \param nNewChannel
4878 *
4879 * \param nCount
4880 *
4881 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4882 *
4883 *
4884 */
4885
4886tSirRetStatus
4887limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
4888 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07004889 tANI_U8 nMode,
4890 tANI_U8 nNewChannel,
4891 tANI_U8 nCount,
4892 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07004893{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304894 tDot11fChannelSwitch frm;
4895 tANI_U8 *pFrame;
4896 tSirRetStatus nSirStatus;
4897 tpSirMacMgmtHdr pMacHdr;
4898 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
4899 void *pPacket;
4900 eHalStatus halstatus;
4901 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004902
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304903 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004904
4905 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4906 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
4907 frm.ChanSwitchAnn.switchMode = nMode;
4908 frm.ChanSwitchAnn.newChannel = nNewChannel;
4909 frm.ChanSwitchAnn.switchCount = nCount;
4910 frm.ChanSwitchAnn.present = 1;
4911
4912 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
4913 if ( DOT11F_FAILED( nStatus ) )
4914 {
4915 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004916 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 nStatus );
4918 // We'll fall back on the worst case scenario:
4919 nPayload = sizeof( tDot11fChannelSwitch );
4920 }
4921 else if ( DOT11F_WARNED( nStatus ) )
4922 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004923 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004925 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 }
4927
4928 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4929
4930 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4931 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4932 {
4933 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004934 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 return eSIR_FAILURE;
4936 }
4937
4938 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304939 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004940
4941 // Next, we fill out the buffer descriptor:
4942 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07004943 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4944 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304945 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
4946 (tANI_U8 *) psessionEntry->bssId,
4947 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 if ( eSIR_SUCCESS != nSirStatus )
4949 {
4950 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004951 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 nSirStatus );
4953 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4954 return eSIR_FAILURE; // just allocated...
4955 }
4956
Jeff Johnsone7245742012-09-05 17:12:55 -07004957#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4959
4960 nCfg = 6;
4961 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4962 if ( eSIR_SUCCESS != nSirStatus )
4963 {
4964 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004965 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 nSirStatus );
4967 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4968 return eSIR_FAILURE; // just allocated...
4969 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004970#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004971
4972#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004973 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004974#endif
4975
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
4977 sizeof(tSirMacMgmtHdr),
4978 nPayload, &nPayload );
4979 if ( DOT11F_FAILED( nStatus ) )
4980 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004981 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 nStatus );
4983 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4984 return eSIR_FAILURE; // allocated!
4985 }
4986 else if ( DOT11F_WARNED( nStatus ) )
4987 {
4988 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004989 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 }
4991
Jeff Johnsone7245742012-09-05 17:12:55 -07004992 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07004993 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4994 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07004995 )
4996 {
4997 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4998 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304999
5000 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5001 psessionEntry->peSessionId,
5002 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5004 HAL_TXRX_FRM_802_11_MGMT,
5005 ANI_TXDIR_TODS,
5006 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005007 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305008 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5009 psessionEntry->peSessionId,
5010 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5012 {
5013 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005014 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 nSirStatus );
5016 //Pkt will be freed up by the callback
5017 return eSIR_FAILURE;
5018 }
5019
5020 return eSIR_SUCCESS;
5021
5022} // End limSendChannelSwitchMgmtFrame.
5023
Jeff Johnson295189b2012-06-20 16:38:30 -07005024
5025
Mohit Khanna4a70d262012-09-11 16:30:12 -07005026#ifdef WLAN_FEATURE_11AC
5027tSirRetStatus
5028limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5029 tSirMacAddr peer,
5030 tANI_U8 nMode,
5031 tpPESession psessionEntry )
5032{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305033 tDot11fOperatingMode frm;
5034 tANI_U8 *pFrame;
5035 tSirRetStatus nSirStatus;
5036 tpSirMacMgmtHdr pMacHdr;
5037 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5038 void *pPacket;
5039 eHalStatus halstatus;
5040 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005041
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305042 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005043
5044 frm.Category.category = SIR_MAC_ACTION_VHT;
5045 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5046 frm.OperatingMode.chanWidth = nMode;
5047 frm.OperatingMode.rxNSS = 0;
5048 frm.OperatingMode.rxNSSType = 0;
5049
5050 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5051 if ( DOT11F_FAILED( nStatus ) )
5052 {
5053 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005054 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005055 nStatus );
5056 // We'll fall back on the worst case scenario:
5057 nPayload = sizeof( tDot11fOperatingMode);
5058 }
5059 else if ( DOT11F_WARNED( nStatus ) )
5060 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005061 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005062 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005063 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005064 }
5065
5066 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5067
5068 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5069 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5070 {
5071 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005072 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005073 return eSIR_FAILURE;
5074 }
5075
5076 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305077 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005078
5079
5080 // Next, we fill out the buffer descriptor:
5081 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5082 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5083 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5084 } else
5085 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5086 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5087 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305088 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5089 (tANI_U8 *) psessionEntry->bssId,
5090 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005091 if ( eSIR_SUCCESS != nSirStatus )
5092 {
5093 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005094 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005095 nSirStatus );
5096 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5097 return eSIR_FAILURE; // just allocated...
5098 }
5099 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5100 sizeof(tSirMacMgmtHdr),
5101 nPayload, &nPayload );
5102 if ( DOT11F_FAILED( nStatus ) )
5103 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005104 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005105 nStatus );
5106 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5107 return eSIR_FAILURE; // allocated!
5108 }
5109 else if ( DOT11F_WARNED( nStatus ) )
5110 {
5111 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005112 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005113 }
5114 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005115 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5116 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005117 )
5118 {
5119 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5120 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305121
5122 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5123 psessionEntry->peSessionId,
5124 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005125 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5126 HAL_TXRX_FRM_802_11_MGMT,
5127 ANI_TXDIR_TODS,
5128 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5129 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305130 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5131 psessionEntry->peSessionId,
5132 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005133 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5134 {
5135 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005136 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005137 nSirStatus );
5138 //Pkt will be freed up by the callback
5139 return eSIR_FAILURE;
5140 }
5141
5142 return eSIR_SUCCESS;
5143}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005144
5145/**
5146 * \brief Send a VHT Channel Switch Announcement
5147 *
5148 *
5149 * \param pMac Pointer to the global MAC datastructure
5150 *
5151 * \param peer MAC address to which this frame will be sent
5152 *
5153 * \param nChanWidth
5154 *
5155 * \param nNewChannel
5156 *
5157 *
5158 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5159 *
5160 *
5161 */
5162
5163tSirRetStatus
5164limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5165 tSirMacAddr peer,
5166 tANI_U8 nChanWidth,
5167 tANI_U8 nNewChannel,
5168 tANI_U8 ncbMode,
5169 tpPESession psessionEntry )
5170{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305171 tDot11fChannelSwitch frm;
5172 tANI_U8 *pFrame;
5173 tSirRetStatus nSirStatus;
5174 tpSirMacMgmtHdr pMacHdr;
5175 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5176 void *pPacket;
5177 eHalStatus halstatus;
5178 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005179
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305180 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005181
5182
5183 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5184 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5185 frm.ChanSwitchAnn.switchMode = 1;
5186 frm.ChanSwitchAnn.newChannel = nNewChannel;
5187 frm.ChanSwitchAnn.switchCount = 1;
5188 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5189 frm.ExtChanSwitchAnn.present = 1;
5190 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5191 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5192 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5193 frm.ChanSwitchAnn.present = 1;
5194 frm.WiderBWChanSwitchAnn.present = 1;
5195
5196 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5197 if ( DOT11F_FAILED( nStatus ) )
5198 {
5199 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005200 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005201 nStatus );
5202 // We'll fall back on the worst case scenario:
5203 nPayload = sizeof( tDot11fChannelSwitch );
5204 }
5205 else if ( DOT11F_WARNED( nStatus ) )
5206 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005207 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005208 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005209 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005210 }
5211
5212 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5213
5214 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5215 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5216 {
5217 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005218 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005219 return eSIR_FAILURE;
5220 }
5221 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305222 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005223
5224 // Next, we fill out the buffer descriptor:
5225 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5226 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5227 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305228 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5229 (tANI_U8 *) psessionEntry->bssId,
5230 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005231 if ( eSIR_SUCCESS != nSirStatus )
5232 {
5233 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005234 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005235 nSirStatus );
5236 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5237 return eSIR_FAILURE; // just allocated...
5238 }
5239 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5240 sizeof(tSirMacMgmtHdr),
5241 nPayload, &nPayload );
5242 if ( DOT11F_FAILED( nStatus ) )
5243 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005244 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005245 nStatus );
5246 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5247 return eSIR_FAILURE; // allocated!
5248 }
5249 else if ( DOT11F_WARNED( nStatus ) )
5250 {
5251 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005252 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005253 }
5254
5255 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005256 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5257 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005258 )
5259 {
5260 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5261 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305262
5263 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5264 psessionEntry->peSessionId,
5265 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005266 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5267 HAL_TXRX_FRM_802_11_MGMT,
5268 ANI_TXDIR_TODS,
5269 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5270 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305271 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5272 psessionEntry->peSessionId,
5273 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005274 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5275 {
5276 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005277 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005278 nSirStatus );
5279 //Pkt will be freed up by the callback
5280 return eSIR_FAILURE;
5281 }
5282
5283 return eSIR_SUCCESS;
5284
5285} // End limSendVHTChannelSwitchMgmtFrame.
5286
5287
5288
Mohit Khanna4a70d262012-09-11 16:30:12 -07005289#endif
5290
Jeff Johnson295189b2012-06-20 16:38:30 -07005291/**
5292 * \brief Send an ADDBA Req Action Frame to peer
5293 *
5294 * \sa limSendAddBAReq
5295 *
5296 * \param pMac The global tpAniSirGlobal object
5297 *
5298 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5299 * the necessary parameters reqd by PE send the ADDBA Req Action
5300 * Frame to the peer
5301 *
5302 * \return eSIR_SUCCESS if setup completes successfully
5303 * eSIR_FAILURE is some problem is encountered
5304 */
5305tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305306 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005307{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305308 tDot11fAddBAReq frmAddBAReq;
5309 tANI_U8 *pAddBAReqBuffer = NULL;
5310 tpSirMacMgmtHdr pMacHdr;
5311 tANI_U32 frameLen = 0, nStatus, nPayload;
5312 tSirRetStatus statusCode;
5313 eHalStatus halStatus;
5314 void *pPacket;
5315 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005316
5317 if(NULL == psessionEntry)
5318 {
5319 return eSIR_FAILURE;
5320 }
5321
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305322 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005323
5324 // Category - 3 (BA)
5325 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5326
5327 // Action - 0 (ADDBA Req)
5328 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5329
5330 // FIXME - Dialog Token, generalize this...
5331 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5332
5333 // Fill the ADDBA Parameter Set
5334 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5335 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5336 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5337
5338 // BA timeout
5339 // 0 - indicates no BA timeout
5340 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5341
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305342 /* Send SSN whatever we get from FW.
5343 */
5344 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005345
5346 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5347
5348 if( DOT11F_FAILED( nStatus ))
5349 {
5350 limLog( pMac, LOGW,
5351 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005352 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 nStatus );
5354
5355 // We'll fall back on the worst case scenario:
5356 nPayload = sizeof( tDot11fAddBAReq );
5357 }
5358 else if( DOT11F_WARNED( nStatus ))
5359 {
5360 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005361 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005362 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 nStatus );
5364 }
5365
5366 // Add the MGMT header to frame length
5367 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5368
5369 // Need to allocate a buffer for ADDBA AF
5370 if( eHAL_STATUS_SUCCESS !=
5371 (halStatus = palPktAlloc( pMac->hHdd,
5372 HAL_TXRX_FRM_802_11_MGMT,
5373 (tANI_U16) frameLen,
5374 (void **) &pAddBAReqBuffer,
5375 (void **) &pPacket )))
5376 {
5377 // Log error
5378 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005379 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005380 frameLen,
5381 halStatus );
5382
5383 statusCode = eSIR_MEM_ALLOC_FAILED;
5384 goto returnAfterError;
5385 }
5386
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305387 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005388
5389 // Copy necessary info to BD
5390 if( eSIR_SUCCESS !=
5391 (statusCode = limPopulateMacHeader( pMac,
5392 pAddBAReqBuffer,
5393 SIR_MAC_MGMT_FRAME,
5394 SIR_MAC_MGMT_ACTION,
5395 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5396 goto returnAfterError;
5397
5398 // Update A3 with the BSSID
5399 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5400
5401 #if 0
5402 cfgLen = SIR_MAC_ADDR_LENGTH;
5403 if( eSIR_SUCCESS != cfgGetStr( pMac,
5404 WNI_CFG_BSSID,
5405 (tANI_U8 *) pMacHdr->bssId,
5406 &cfgLen ))
5407 {
5408 limLog( pMac, LOGP,
5409 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005410 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005411
5412 // FIXME - Need to convert to tSirRetStatus
5413 statusCode = eSIR_FAILURE;
5414 goto returnAfterError;
5415 }
5416 #endif//TO SUPPORT BT-AMP
5417 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5418
Chet Lanctot186b5732013-03-18 10:26:30 -07005419#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005420 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005421#endif
5422
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 // Now, we're ready to "pack" the frames
5424 nStatus = dot11fPackAddBAReq( pMac,
5425 &frmAddBAReq,
5426 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5427 nPayload,
5428 &nPayload );
5429
5430 if( DOT11F_FAILED( nStatus ))
5431 {
5432 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005433 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 nStatus );
5435
5436 // FIXME - Need to convert to tSirRetStatus
5437 statusCode = eSIR_FAILURE;
5438 goto returnAfterError;
5439 }
5440 else if( DOT11F_WARNED( nStatus ))
5441 {
5442 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005443 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5444 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005445 }
5446
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305447 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5448 " tid = %d policy = %d buffsize = %d "
5449 " amsduSupported = %d"),
5450 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5451 frmAddBAReq.AddBAParameterSet.tid,
5452 frmAddBAReq.AddBAParameterSet.policy,
5453 frmAddBAReq.AddBAParameterSet.bufferSize,
5454 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005455
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305456 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5457 frmAddBAReq.BAStartingSequenceControl.ssn,
5458 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5459
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5462 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 )
5464 {
5465 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5466 }
5467
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305468 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5469 psessionEntry->peSessionId,
5470 pMacHdr->fc.subType));
5471 halStatus = halTxFrame( pMac,
5472 pPacket,
5473 (tANI_U16) frameLen,
5474 HAL_TXRX_FRM_802_11_MGMT,
5475 ANI_TXDIR_TODS,
5476 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5477 limTxComplete,
5478 pAddBAReqBuffer, txFlag );
5479 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5480 psessionEntry->peSessionId,
5481 halStatus));
5482 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 {
5484 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005485 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 halStatus );
5487
5488 // FIXME - Need to convert eHalStatus to tSirRetStatus
5489 statusCode = eSIR_FAILURE;
5490 //Pkt will be freed up by the callback
5491 return statusCode;
5492 }
5493 else
5494 return eSIR_SUCCESS;
5495
5496returnAfterError:
5497
5498 // Release buffer, if allocated
5499 if( NULL != pAddBAReqBuffer )
5500 palPktFree( pMac->hHdd,
5501 HAL_TXRX_FRM_802_11_MGMT,
5502 (void *) pAddBAReqBuffer,
5503 (void *) pPacket );
5504
5505 return statusCode;
5506}
5507
5508/**
5509 * \brief Send an ADDBA Rsp Action Frame to peer
5510 *
5511 * \sa limSendAddBARsp
5512 *
5513 * \param pMac The global tpAniSirGlobal object
5514 *
5515 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5516 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5517 * Frame to the peer
5518 *
5519 * \return eSIR_SUCCESS if setup completes successfully
5520 * eSIR_FAILURE is some problem is encountered
5521 */
5522tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5523 tpLimMlmAddBARsp pMlmAddBARsp,
5524 tpPESession psessionEntry)
5525{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305526 tDot11fAddBARsp frmAddBARsp;
5527 tANI_U8 *pAddBARspBuffer = NULL;
5528 tpSirMacMgmtHdr pMacHdr;
5529 tANI_U32 frameLen = 0, nStatus, nPayload;
5530 tSirRetStatus statusCode;
5531 eHalStatus halStatus;
5532 void *pPacket;
5533 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005534
5535 if(NULL == psessionEntry)
5536 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005537 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 return eSIR_FAILURE;
5539 }
5540
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305541 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005542
5543 // Category - 3 (BA)
5544 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5545 // Action - 1 (ADDBA Rsp)
5546 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5547
5548 // Should be same as the one we received in the ADDBA Req
5549 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5550
5551 // ADDBA Req status
5552 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5553
5554 // Fill the ADDBA Parameter Set as provided by caller
5555 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5556 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5557 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005558
5559 if(psessionEntry->isAmsduSupportInAMPDU)
5560 {
5561 frmAddBARsp.AddBAParameterSet.amsduSupported =
5562 psessionEntry->amsduSupportedInBA;
5563 }
5564 else
5565 {
5566 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005568
5569 // BA timeout
5570 // 0 - indicates no BA timeout
5571 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5572
5573 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5574
5575 if( DOT11F_FAILED( nStatus ))
5576 {
5577 limLog( pMac, LOGW,
5578 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005579 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 nStatus );
5581
5582 // We'll fall back on the worst case scenario:
5583 nPayload = sizeof( tDot11fAddBARsp );
5584 }
5585 else if( DOT11F_WARNED( nStatus ))
5586 {
5587 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005588 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005589 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 nStatus );
5591 }
5592
5593 // Need to allocate a buffer for ADDBA AF
5594 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5595
5596 // Allocate shared memory
5597 if( eHAL_STATUS_SUCCESS !=
5598 (halStatus = palPktAlloc( pMac->hHdd,
5599 HAL_TXRX_FRM_802_11_MGMT,
5600 (tANI_U16) frameLen,
5601 (void **) &pAddBARspBuffer,
5602 (void **) &pPacket )))
5603 {
5604 // Log error
5605 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005606 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 frameLen,
5608 halStatus );
5609
5610 statusCode = eSIR_MEM_ALLOC_FAILED;
5611 goto returnAfterError;
5612 }
5613
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305614 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005615
5616 // Copy necessary info to BD
5617 if( eSIR_SUCCESS !=
5618 (statusCode = limPopulateMacHeader( pMac,
5619 pAddBARspBuffer,
5620 SIR_MAC_MGMT_FRAME,
5621 SIR_MAC_MGMT_ACTION,
5622 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5623 goto returnAfterError;
5624
5625 // Update A3 with the BSSID
5626
5627 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5628
5629 #if 0
5630 cfgLen = SIR_MAC_ADDR_LENGTH;
5631 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5632 WNI_CFG_BSSID,
5633 (tANI_U8 *) pMacHdr->bssId,
5634 &cfgLen ))
5635 {
5636 limLog( pMac, LOGP,
5637 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005638 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005639
5640 // FIXME - Need to convert to tSirRetStatus
5641 statusCode = eSIR_FAILURE;
5642 goto returnAfterError;
5643 }
5644 #endif // TO SUPPORT BT-AMP
5645 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5646
Chet Lanctot186b5732013-03-18 10:26:30 -07005647#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005648 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005649#endif
5650
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 // Now, we're ready to "pack" the frames
5652 nStatus = dot11fPackAddBARsp( pMac,
5653 &frmAddBARsp,
5654 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5655 nPayload,
5656 &nPayload );
5657
5658 if( DOT11F_FAILED( nStatus ))
5659 {
5660 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005661 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 nStatus );
5663
5664 // FIXME - Need to convert to tSirRetStatus
5665 statusCode = eSIR_FAILURE;
5666 goto returnAfterError;
5667 }
5668 else if( DOT11F_WARNED( nStatus ))
5669 {
5670 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005671 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5672 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 }
5674
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305675 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5676 " tid = %d policy = %d buffsize = %d"
5677 " amsduSupported = %d status %d"),
5678 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5679 frmAddBARsp.AddBAParameterSet.tid,
5680 frmAddBARsp.AddBAParameterSet.policy,
5681 frmAddBARsp.AddBAParameterSet.bufferSize,
5682 frmAddBARsp.AddBAParameterSet.amsduSupported,
5683 frmAddBARsp.Status.status);
5684
Jeff Johnson295189b2012-06-20 16:38:30 -07005685
5686 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5688 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 )
5690 {
5691 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5692 }
5693
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305694 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5695 psessionEntry->peSessionId,
5696 pMacHdr->fc.subType));
5697 halStatus = halTxFrame( pMac,
5698 pPacket,
5699 (tANI_U16) frameLen,
5700 HAL_TXRX_FRM_802_11_MGMT,
5701 ANI_TXDIR_TODS,
5702 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5703 limTxComplete,
5704 pAddBARspBuffer, txFlag );
5705 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5706 psessionEntry->peSessionId,
5707 halStatus));
5708 if( eHAL_STATUS_SUCCESS != halStatus )
5709 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005711 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 halStatus );
5713
5714 // FIXME - HAL error codes are different from PE error
5715 // codes!! And, this routine is returning tSirRetStatus
5716 statusCode = eSIR_FAILURE;
5717 //Pkt will be freed up by the callback
5718 return statusCode;
5719 }
5720 else
5721 return eSIR_SUCCESS;
5722
5723 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 // Release buffer, if allocated
5725 if( NULL != pAddBARspBuffer )
5726 palPktFree( pMac->hHdd,
5727 HAL_TXRX_FRM_802_11_MGMT,
5728 (void *) pAddBARspBuffer,
5729 (void *) pPacket );
5730
5731 return statusCode;
5732}
5733
5734/**
5735 * \brief Send a DELBA Indication Action Frame to peer
5736 *
5737 * \sa limSendDelBAInd
5738 *
5739 * \param pMac The global tpAniSirGlobal object
5740 *
5741 * \param peerMacAddr MAC Address of peer
5742 *
5743 * \param reasonCode Reason for the DELBA notification
5744 *
5745 * \param pBAParameterSet The DELBA Parameter Set.
5746 * This identifies the TID for which the BA session is
5747 * being deleted.
5748 *
5749 * \return eSIR_SUCCESS if setup completes successfully
5750 * eSIR_FAILURE is some problem is encountered
5751 */
5752tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5753 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5754{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305755 tDot11fDelBAInd frmDelBAInd;
5756 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305758 tpSirMacMgmtHdr pMacHdr;
5759 tANI_U32 frameLen = 0, nStatus, nPayload;
5760 tSirRetStatus statusCode;
5761 eHalStatus halStatus;
5762 void *pPacket;
5763 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005764
5765 if(NULL == psessionEntry)
5766 {
5767 return eSIR_FAILURE;
5768 }
5769
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305770 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005771
5772 // Category - 3 (BA)
5773 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
5774 // Action - 2 (DELBA)
5775 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
5776
5777 // Fill the DELBA Parameter Set as provided by caller
5778 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
5779 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
5780
5781 // BA Starting Sequence Number
5782 // Fragment number will always be zero
5783 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
5784
5785 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
5786
5787 if( DOT11F_FAILED( nStatus ))
5788 {
5789 limLog( pMac, LOGW,
5790 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005791 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 nStatus );
5793
5794 // We'll fall back on the worst case scenario:
5795 nPayload = sizeof( tDot11fDelBAInd );
5796 }
5797 else if( DOT11F_WARNED( nStatus ))
5798 {
5799 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005800 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005801 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 nStatus );
5803 }
5804
5805 // Add the MGMT header to frame length
5806 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5807
5808 // Allocate shared memory
5809 if( eHAL_STATUS_SUCCESS !=
5810 (halStatus = palPktAlloc( pMac->hHdd,
5811 HAL_TXRX_FRM_802_11_MGMT,
5812 (tANI_U16) frameLen,
5813 (void **) &pDelBAIndBuffer,
5814 (void **) &pPacket )))
5815 {
5816 // Log error
5817 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005818 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 frameLen,
5820 halStatus );
5821
5822 statusCode = eSIR_MEM_ALLOC_FAILED;
5823 goto returnAfterError;
5824 }
5825
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305826 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005827
5828 // Copy necessary info to BD
5829 if( eSIR_SUCCESS !=
5830 (statusCode = limPopulateMacHeader( pMac,
5831 pDelBAIndBuffer,
5832 SIR_MAC_MGMT_FRAME,
5833 SIR_MAC_MGMT_ACTION,
5834 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5835 goto returnAfterError;
5836
5837 // Update A3 with the BSSID
5838 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
5839
5840 #if 0
5841 cfgLen = SIR_MAC_ADDR_LENGTH;
5842 if( eSIR_SUCCESS != cfgGetStr( pMac,
5843 WNI_CFG_BSSID,
5844 (tANI_U8 *) pMacHdr->bssId,
5845 &cfgLen ))
5846 {
5847 limLog( pMac, LOGP,
5848 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005849 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005850
5851 // FIXME - Need to convert to tSirRetStatus
5852 statusCode = eSIR_FAILURE;
5853 goto returnAfterError;
5854 }
5855 #endif //TO SUPPORT BT-AMP
5856 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5857
Chet Lanctot186b5732013-03-18 10:26:30 -07005858#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005859 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005860#endif
5861
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 // Now, we're ready to "pack" the frames
5863 nStatus = dot11fPackDelBAInd( pMac,
5864 &frmDelBAInd,
5865 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
5866 nPayload,
5867 &nPayload );
5868
5869 if( DOT11F_FAILED( nStatus ))
5870 {
5871 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005872 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005873 nStatus );
5874
5875 // FIXME - Need to convert to tSirRetStatus
5876 statusCode = eSIR_FAILURE;
5877 goto returnAfterError;
5878 }
5879 else if( DOT11F_WARNED( nStatus ))
5880 {
5881 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005882 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
5883 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884 }
5885
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305886 limLog( pMac, LOG1,
5887 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
5888 " initiator = %d reason = %d" ),
5889 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
5890 frmDelBAInd.DelBAParameterSet.tid,
5891 frmDelBAInd.DelBAParameterSet.initiator,
5892 frmDelBAInd.Reason.code);
5893
Jeff Johnson295189b2012-06-20 16:38:30 -07005894
5895 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5897 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 )
5899 {
5900 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5901 }
5902
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305903 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5904 psessionEntry->peSessionId,
5905 pMacHdr->fc.subType));
5906 halStatus = halTxFrame( pMac,
5907 pPacket,
5908 (tANI_U16) frameLen,
5909 HAL_TXRX_FRM_802_11_MGMT,
5910 ANI_TXDIR_TODS,
5911 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5912 limTxComplete,
5913 pDelBAIndBuffer, txFlag );
5914 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5915 psessionEntry->peSessionId,
5916 halStatus));
5917 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005919 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 statusCode = eSIR_FAILURE;
5921 //Pkt will be freed up by the callback
5922 return statusCode;
5923 }
5924 else
5925 return eSIR_SUCCESS;
5926
5927 returnAfterError:
5928
5929 // Release buffer, if allocated
5930 if( NULL != pDelBAIndBuffer )
5931 palPktFree( pMac->hHdd,
5932 HAL_TXRX_FRM_802_11_MGMT,
5933 (void *) pDelBAIndBuffer,
5934 (void *) pPacket );
5935
5936 return statusCode;
5937}
5938
5939#if defined WLAN_FEATURE_VOWIFI
5940
5941/**
5942 * \brief Send a Neighbor Report Request Action frame
5943 *
5944 *
5945 * \param pMac Pointer to the global MAC structure
5946 *
5947 * \param pNeighborReq Address of a tSirMacNeighborReportReq
5948 *
5949 * \param peer mac address of peer station.
5950 *
5951 * \param psessionEntry address of session entry.
5952 *
5953 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5954 *
5955 *
5956 */
5957
5958tSirRetStatus
5959limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
5960 tpSirMacNeighborReportReq pNeighborReq,
5961 tSirMacAddr peer,
5962 tpPESession psessionEntry
5963 )
5964{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305965 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 tDot11fNeighborReportRequest frm;
5967 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305968 tpSirMacMgmtHdr pMacHdr;
5969 tANI_U32 nBytes, nPayload, nStatus;
5970 void *pPacket;
5971 eHalStatus halstatus;
5972 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005973
5974 if ( psessionEntry == NULL )
5975 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005976 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005977 return eSIR_FAILURE;
5978 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305979 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005980
5981 frm.Category.category = SIR_MAC_ACTION_RRM;
5982 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
5983 frm.DialogToken.token = pNeighborReq->dialogToken;
5984
5985
5986 if( pNeighborReq->ssid_present )
5987 {
5988 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
5989 }
5990
5991 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
5992 if ( DOT11F_FAILED( nStatus ) )
5993 {
5994 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005995 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 nStatus );
5997 // We'll fall back on the worst case scenario:
5998 nPayload = sizeof( tDot11fNeighborReportRequest );
5999 }
6000 else if ( DOT11F_WARNED( nStatus ) )
6001 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006002 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006004 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
6006
6007 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6008
6009 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6010 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6011 {
6012 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006013 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 return eSIR_FAILURE;
6015 }
6016
6017 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306018 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006019
6020 // Copy necessary info to BD
6021 if( eSIR_SUCCESS !=
6022 (statusCode = limPopulateMacHeader( pMac,
6023 pFrame,
6024 SIR_MAC_MGMT_FRAME,
6025 SIR_MAC_MGMT_ACTION,
6026 peer, psessionEntry->selfMacAddr)))
6027 goto returnAfterError;
6028
6029 // Update A3 with the BSSID
6030 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6031
6032 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6033
Chet Lanctot186b5732013-03-18 10:26:30 -07006034#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006035 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006036#endif
6037
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 // Now, we're ready to "pack" the frames
6039 nStatus = dot11fPackNeighborReportRequest( pMac,
6040 &frm,
6041 pFrame + sizeof( tSirMacMgmtHdr ),
6042 nPayload,
6043 &nPayload );
6044
6045 if( DOT11F_FAILED( nStatus ))
6046 {
6047 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006048 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006049 nStatus );
6050
6051 // FIXME - Need to convert to tSirRetStatus
6052 statusCode = eSIR_FAILURE;
6053 goto returnAfterError;
6054 }
6055 else if( DOT11F_WARNED( nStatus ))
6056 {
6057 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006058 FL( "There were warnings while packing Neighbor Report "
6059 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 }
6061
6062 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006063 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 limPrintMacAddr( pMac, peer, LOGW );
6065
6066 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006067 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6068 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 )
6070 {
6071 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6072 }
6073
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306074 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6075 psessionEntry->peSessionId,
6076 pMacHdr->fc.subType));
6077 halstatus = halTxFrame( pMac,
6078 pPacket,
6079 (tANI_U16) nBytes,
6080 HAL_TXRX_FRM_802_11_MGMT,
6081 ANI_TXDIR_TODS,
6082 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6083 limTxComplete,
6084 pFrame, txFlag );
6085 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6086 psessionEntry->peSessionId,
6087 halstatus));
6088 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006090 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 statusCode = eSIR_FAILURE;
6092 //Pkt will be freed up by the callback
6093 return statusCode;
6094 }
6095 else
6096 return eSIR_SUCCESS;
6097
6098returnAfterError:
6099 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6100
6101 return statusCode;
6102} // End limSendNeighborReportRequestFrame.
6103
6104/**
6105 * \brief Send a Link Report Action frame
6106 *
6107 *
6108 * \param pMac Pointer to the global MAC structure
6109 *
6110 * \param pLinkReport Address of a tSirMacLinkReport
6111 *
6112 * \param peer mac address of peer station.
6113 *
6114 * \param psessionEntry address of session entry.
6115 *
6116 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6117 *
6118 *
6119 */
6120
6121tSirRetStatus
6122limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6123 tpSirMacLinkReport pLinkReport,
6124 tSirMacAddr peer,
6125 tpPESession psessionEntry
6126 )
6127{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306128 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006129 tDot11fLinkMeasurementReport frm;
6130 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306131 tpSirMacMgmtHdr pMacHdr;
6132 tANI_U32 nBytes, nPayload, nStatus;
6133 void *pPacket;
6134 eHalStatus halstatus;
6135 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006136
6137
6138 if ( psessionEntry == NULL )
6139 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006140 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 return eSIR_FAILURE;
6142 }
6143
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306144 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006145
6146 frm.Category.category = SIR_MAC_ACTION_RRM;
6147 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6148 frm.DialogToken.token = pLinkReport->dialogToken;
6149
6150
6151 //IEEE Std. 802.11 7.3.2.18. for the report element.
6152 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6153 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6154 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6155 //such case this way than changing the frame parser.
6156 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6157 frm.TPCEleLen.TPCLen = 2;
6158 frm.TxPower.txPower = pLinkReport->txPower;
6159 frm.LinkMargin.linkMargin = 0;
6160
6161 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6162 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6163 frm.RCPI.rcpi = pLinkReport->rcpi;
6164 frm.RSNI.rsni = pLinkReport->rsni;
6165
6166 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6167 if ( DOT11F_FAILED( nStatus ) )
6168 {
6169 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006170 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 nStatus );
6172 // We'll fall back on the worst case scenario:
6173 nPayload = sizeof( tDot11fLinkMeasurementReport );
6174 }
6175 else if ( DOT11F_WARNED( nStatus ) )
6176 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006177 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006179 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006180 }
6181
6182 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6183
6184 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6185 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6186 {
6187 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006188 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 return eSIR_FAILURE;
6190 }
6191
6192 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306193 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006194
6195 // Copy necessary info to BD
6196 if( eSIR_SUCCESS !=
6197 (statusCode = limPopulateMacHeader( pMac,
6198 pFrame,
6199 SIR_MAC_MGMT_FRAME,
6200 SIR_MAC_MGMT_ACTION,
6201 peer, psessionEntry->selfMacAddr)))
6202 goto returnAfterError;
6203
6204 // Update A3 with the BSSID
6205 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6206
6207 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6208
Chet Lanctot186b5732013-03-18 10:26:30 -07006209#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006210 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006211#endif
6212
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 // Now, we're ready to "pack" the frames
6214 nStatus = dot11fPackLinkMeasurementReport( pMac,
6215 &frm,
6216 pFrame + sizeof( tSirMacMgmtHdr ),
6217 nPayload,
6218 &nPayload );
6219
6220 if( DOT11F_FAILED( nStatus ))
6221 {
6222 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006223 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 nStatus );
6225
6226 // FIXME - Need to convert to tSirRetStatus
6227 statusCode = eSIR_FAILURE;
6228 goto returnAfterError;
6229 }
6230 else if( DOT11F_WARNED( nStatus ))
6231 {
6232 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006233 FL( "There were warnings while packing Link Report (0x%08x)." ),
6234 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 }
6236
6237 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006238 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 limPrintMacAddr( pMac, peer, LOGW );
6240
6241 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6243 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 )
6245 {
6246 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6247 }
6248
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306249 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6250 psessionEntry->peSessionId,
6251 pMacHdr->fc.subType));
6252 halstatus = halTxFrame( pMac,
6253 pPacket,
6254 (tANI_U16) nBytes,
6255 HAL_TXRX_FRM_802_11_MGMT,
6256 ANI_TXDIR_TODS,
6257 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6258 limTxComplete,
6259 pFrame, txFlag );
6260 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6261 psessionEntry->peSessionId,
6262 halstatus));
6263 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006265 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006266 statusCode = eSIR_FAILURE;
6267 //Pkt will be freed up by the callback
6268 return statusCode;
6269 }
6270 else
6271 return eSIR_SUCCESS;
6272
6273returnAfterError:
6274 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6275
6276 return statusCode;
6277} // End limSendLinkReportActionFrame.
6278
6279/**
6280 * \brief Send a Beacon Report Action frame
6281 *
6282 *
6283 * \param pMac Pointer to the global MAC structure
6284 *
6285 * \param dialog_token dialog token to be used in the action frame.
6286 *
6287 * \param num_report number of reports in pRRMReport.
6288 *
6289 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6290 *
6291 * \param peer mac address of peer station.
6292 *
6293 * \param psessionEntry address of session entry.
6294 *
6295 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6296 *
6297 *
6298 */
6299
6300tSirRetStatus
6301limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6302 tANI_U8 dialog_token,
6303 tANI_U8 num_report,
6304 tpSirMacRadioMeasureReport pRRMReport,
6305 tSirMacAddr peer,
6306 tpPESession psessionEntry
6307 )
6308{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306309 tSirRetStatus statusCode = eSIR_SUCCESS;
6310 tANI_U8 *pFrame;
6311 tpSirMacMgmtHdr pMacHdr;
6312 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306314 eHalStatus halstatus;
6315 tANI_U8 i;
6316 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006317
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006318 tDot11fRadioMeasurementReport *frm =
6319 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6320 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006321 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006322 return eSIR_FAILURE;
6323 }
6324
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 if ( psessionEntry == NULL )
6326 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006327 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006328 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 return eSIR_FAILURE;
6330 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306331 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006332
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006333 frm->Category.category = SIR_MAC_ACTION_RRM;
6334 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6335 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006336
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006337 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 -07006338
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006339 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006341 frm->MeasurementReport[i].type = pRRMReport[i].type;
6342 frm->MeasurementReport[i].token = pRRMReport[i].token;
6343 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 switch( pRRMReport[i].type )
6345 {
6346 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006347 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6348 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6349 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6350 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 break;
6352 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306353 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6354 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006355 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 break;
6357 }
6358 }
6359
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006360 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 if ( DOT11F_FAILED( nStatus ) )
6362 {
6363 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006364 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 nStatus );
6366 // We'll fall back on the worst case scenario:
6367 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006368 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 return eSIR_FAILURE;
6370 }
6371 else if ( DOT11F_WARNED( nStatus ) )
6372 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006373 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006375 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 }
6377
6378 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6379
6380 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6381 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6382 {
6383 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006384 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006385 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 return eSIR_FAILURE;
6387 }
6388
6389 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306390 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006391
6392 // Copy necessary info to BD
6393 if( eSIR_SUCCESS !=
6394 (statusCode = limPopulateMacHeader( pMac,
6395 pFrame,
6396 SIR_MAC_MGMT_FRAME,
6397 SIR_MAC_MGMT_ACTION,
6398 peer, psessionEntry->selfMacAddr)))
6399 goto returnAfterError;
6400
6401 // Update A3 with the BSSID
6402 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6403
6404 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6405
Chet Lanctot186b5732013-03-18 10:26:30 -07006406#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006407 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006408#endif
6409
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 // Now, we're ready to "pack" the frames
6411 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006412 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 pFrame + sizeof( tSirMacMgmtHdr ),
6414 nPayload,
6415 &nPayload );
6416
6417 if( DOT11F_FAILED( nStatus ))
6418 {
6419 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006420 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 nStatus );
6422
6423 // FIXME - Need to convert to tSirRetStatus
6424 statusCode = eSIR_FAILURE;
6425 goto returnAfterError;
6426 }
6427 else if( DOT11F_WARNED( nStatus ))
6428 {
6429 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006430 FL( "There were warnings while packing Radio "
6431 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006432 }
6433
6434 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006435 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 limPrintMacAddr( pMac, peer, LOGW );
6437
6438 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006439 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6440 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 )
6442 {
6443 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6444 }
6445
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306446 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6447 psessionEntry->peSessionId,
6448 pMacHdr->fc.subType));
6449 halstatus = halTxFrame( pMac,
6450 pPacket,
6451 (tANI_U16) nBytes,
6452 HAL_TXRX_FRM_802_11_MGMT,
6453 ANI_TXDIR_TODS,
6454 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6455 limTxComplete,
6456 pFrame, txFlag );
6457 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6458 psessionEntry->peSessionId,
6459 halstatus));
6460 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006461 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006462 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 statusCode = eSIR_FAILURE;
6464 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006465 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006466 return statusCode;
6467 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006468 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006469 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006470 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006472
6473returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006474 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 return statusCode;
6477} // End limSendBeaconReportActionFrame.
6478
6479#endif
6480
6481#ifdef WLAN_FEATURE_11W
6482/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006483 * \brief Send SA query request action frame to peer
6484 *
6485 * \sa limSendSaQueryRequestFrame
6486 *
6487 *
6488 * \param pMac The global tpAniSirGlobal object
6489 *
6490 * \param transId Transaction identifier
6491 *
6492 * \param peer The Mac address of the station to which this action frame is addressed
6493 *
6494 * \param psessionEntry The PE session entry
6495 *
6496 * \return eSIR_SUCCESS if setup completes successfully
6497 * eSIR_FAILURE is some problem is encountered
6498 */
6499
6500tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6501 tSirMacAddr peer, tpPESession psessionEntry )
6502{
6503
6504 tDot11fSaQueryReq frm; // SA query request action frame
6505 tANI_U8 *pFrame;
6506 tSirRetStatus nSirStatus;
6507 tpSirMacMgmtHdr pMacHdr;
6508 tANI_U32 nBytes, nPayload, nStatus;
6509 void *pPacket;
6510 eHalStatus halstatus;
6511 tANI_U8 txFlag = 0;
6512
6513 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6514 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6515 /* 11w action field is :
6516 action: 0 --> SA Query Request action frame
6517 action: 1 --> SA Query Response action frame */
6518 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6519 /* 11w SA Query Request transId */
6520 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6521
6522 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6523 if ( DOT11F_FAILED( nStatus ) )
6524 {
6525 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6526 "for an SA Query Request (0x%08x)."),
6527 nStatus );
6528 // We'll fall back on the worst case scenario:
6529 nPayload = sizeof( tDot11fSaQueryReq );
6530 }
6531 else if ( DOT11F_WARNED( nStatus ) )
6532 {
6533 limLog( pMac, LOGW, FL("There were warnings while calculating "
6534 "the packed size for an SA Query Request"
6535 " (0x%08x)."), nStatus );
6536 }
6537
6538 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6539 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6540 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6541 {
6542 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6543 "action frame"), nBytes );
6544 return eSIR_FAILURE;
6545 }
6546
6547 // Paranoia:
6548 vos_mem_set( pFrame, nBytes, 0 );
6549
6550 // Copy necessary info to BD
6551 nSirStatus = limPopulateMacHeader( pMac,
6552 pFrame,
6553 SIR_MAC_MGMT_FRAME,
6554 SIR_MAC_MGMT_ACTION,
6555 peer, psessionEntry->selfMacAddr );
6556 if ( eSIR_SUCCESS != nSirStatus )
6557 goto returnAfterError;
6558
6559 // Update A3 with the BSSID
6560 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6561
6562 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6563
6564 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6565 // in the FC
6566 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6567
6568 // Pack 11w SA Query Request frame
6569 nStatus = dot11fPackSaQueryReq( pMac,
6570 &frm,
6571 pFrame + sizeof( tSirMacMgmtHdr ),
6572 nPayload,
6573 &nPayload );
6574
6575 if ( DOT11F_FAILED( nStatus ))
6576 {
6577 limLog( pMac, LOGE,
6578 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6579 nStatus );
6580 // FIXME - Need to convert to tSirRetStatus
6581 nSirStatus = eSIR_FAILURE;
6582 goto returnAfterError;
6583 }
6584 else if ( DOT11F_WARNED( nStatus ))
6585 {
6586 limLog( pMac, LOGW,
6587 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6588 nStatus);
6589 }
6590
6591 limLog( pMac, LOG1,
6592 FL( "Sending an SA Query Request to " ));
6593 limPrintMacAddr( pMac, peer, LOG1 );
6594 limPrintMacAddr( pMac, peer, LOGE );
6595 limLog( pMac, LOGE,
6596 FL( "Sending an SA Query Request from " ));
6597 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6598
6599 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6600#ifdef WLAN_FEATURE_P2P
6601 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6602 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6603#endif
6604 )
6605 {
6606 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6607 }
6608
6609 halstatus = halTxFrame( pMac,
6610 pPacket,
6611 (tANI_U16) nBytes,
6612 HAL_TXRX_FRM_802_11_MGMT,
6613 ANI_TXDIR_TODS,
6614 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6615 limTxComplete,
6616 pFrame, txFlag );
6617 if ( eHAL_STATUS_SUCCESS != halstatus )
6618 {
6619 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6620 nSirStatus = eSIR_FAILURE;
6621 //Pkt will be freed up by the callback
6622 return nSirStatus;
6623 }
6624 else {
6625 return eSIR_SUCCESS;
6626 }
6627
6628returnAfterError:
6629 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6630 return nSirStatus;
6631} // End limSendSaQueryRequestFrame
6632
6633/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 * \brief Send SA query response action frame to peer
6635 *
6636 * \sa limSendSaQueryResponseFrame
6637 *
6638 *
6639 * \param pMac The global tpAniSirGlobal object
6640 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006641 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006643 * \param peer The Mac address of the AP to which this action frame is addressed
6644 *
6645 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 *
6647 * \return eSIR_SUCCESS if setup completes successfully
6648 * eSIR_FAILURE is some problem is encountered
6649 */
6650
Chet Lanctot186b5732013-03-18 10:26:30 -07006651tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006652tSirMacAddr peer,tpPESession psessionEntry)
6653{
6654
Chet Lanctot186b5732013-03-18 10:26:30 -07006655 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 tANI_U8 *pFrame;
6657 tSirRetStatus nSirStatus;
6658 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006659 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 void *pPacket;
6661 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306662 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006663
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306664 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006665 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6666 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 action: 0 --> SA query request action frame
6668 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006669 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6670 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006672 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006673
Chet Lanctot186b5732013-03-18 10:26:30 -07006674 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6675 if ( DOT11F_FAILED( nStatus ) )
6676 {
6677 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6678 "or a SA Query Response (0x%08x)."),
6679 nStatus );
6680 // We'll fall back on the worst case scenario:
6681 nPayload = sizeof( tDot11fSaQueryRsp );
6682 }
6683 else if ( DOT11F_WARNED( nStatus ) )
6684 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006685 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006686 "the packed size for an SA Query Response"
6687 " (0x%08x)."), nStatus );
6688 }
6689
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6691 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6692 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6693 {
6694 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006695 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 return eSIR_FAILURE;
6697 }
6698
6699 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306700 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006701
Chet Lanctot186b5732013-03-18 10:26:30 -07006702 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006703 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006704 pFrame,
6705 SIR_MAC_MGMT_FRAME,
6706 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006707 peer, psessionEntry->selfMacAddr );
6708 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006709 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006710
Chet Lanctot186b5732013-03-18 10:26:30 -07006711 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6713
Chet Lanctot186b5732013-03-18 10:26:30 -07006714 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006715
Chet Lanctot186b5732013-03-18 10:26:30 -07006716 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6717 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006718 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719
Chet Lanctot186b5732013-03-18 10:26:30 -07006720 // Pack 11w SA query response frame
6721 nStatus = dot11fPackSaQueryRsp( pMac,
6722 &frm,
6723 pFrame + sizeof( tSirMacMgmtHdr ),
6724 nPayload,
6725 &nPayload );
6726
6727 if ( DOT11F_FAILED( nStatus ))
6728 {
6729 limLog( pMac, LOGE,
6730 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6731 nStatus );
6732 // FIXME - Need to convert to tSirRetStatus
6733 nSirStatus = eSIR_FAILURE;
6734 goto returnAfterError;
6735 }
6736 else if ( DOT11F_WARNED( nStatus ))
6737 {
6738 limLog( pMac, LOGW,
6739 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6740 nStatus);
6741 }
6742
6743 limLog( pMac, LOG1,
6744 FL( "Sending a SA Query Response to " ));
6745 limPrintMacAddr( pMac, peer, LOGW );
6746
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006747 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006748#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006749 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6750 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006751#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006752 )
6753 {
6754 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6755 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006756
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306757 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6758 psessionEntry->peSessionId,
6759 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006760 halstatus = halTxFrame( pMac,
6761 pPacket,
6762 (tANI_U16) nBytes,
6763 HAL_TXRX_FRM_802_11_MGMT,
6764 ANI_TXDIR_TODS,
6765 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6766 limTxComplete,
6767 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306768 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6769 psessionEntry->peSessionId,
6770 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006771 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006772 {
6773 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6774 nSirStatus = eSIR_FAILURE;
6775 //Pkt will be freed up by the callback
6776 return nSirStatus;
6777 }
6778 else {
6779 return eSIR_SUCCESS;
6780 }
6781
6782returnAfterError:
6783 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6784 return nSirStatus;
6785} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07006786#endif