blob: 6e6951540b74730c8b47e79392b1b8f035e615e5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Satyanarayana Dash6f438272015-03-03 18:01:06 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
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
Satyanarayana Dash6f438272015-03-03 18:01:06 +053056#include "wniCfg.h"
Chet Lanctot8cecea22014-02-11 19:09:36 -080057#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 Singh33f76ea2015-06-04 12:27:30 +0530429 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps,
430 psessionEntry->currentOperChannel , eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700431 }
432 } else {
433 if (IS_DOT11_MODE_VHT(dot11mode))
434 {
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530435 PopulateDot11fVHTCaps( pMac, &pr.VHTCaps, nChannelNum, eSIR_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -0700436 }
437 }
438#endif
439
Jeff Johnson295189b2012-06-20 16:38:30 -0700440
441 // That's it-- now we pack it. First, how much space are we going to
442 // need?
443 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
444 if ( DOT11F_FAILED( nStatus ) )
445 {
446 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700447 "or a Probe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 // We'll fall back on the worst case scenario:
449 nPayload = sizeof( tDot11fProbeRequest );
450 }
451 else if ( DOT11F_WARNED( nStatus ) )
452 {
453 limLog( pMac, LOGW, FL("There were warnings while calculating"
454 "the packed size for a Probe Request ("
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700455 "0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
457
458 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAdditionalIELen;
459
460 // Ok-- try to allocate some memory:
461 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
462 ( tANI_U16 )nBytes, ( void** ) &pFrame,
463 ( void** ) &pPacket );
464 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
465 {
466 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700467 "be Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return eSIR_MEM_ALLOC_FAILED;
469 }
470
471 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530472 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700473
474 // Next, we fill out the buffer descriptor:
475 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530476 SIR_MAC_MGMT_PROBE_REQ, bssid, SelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 if ( eSIR_SUCCESS != nSirStatus )
478 {
479 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700480 "tor for a Probe Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 nSirStatus );
482 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
483 ( void* ) pFrame, ( void* ) pPacket );
484 return nSirStatus; // allocated!
485 }
486
487 // That done, pack the Probe Request:
488 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
489 sizeof( tSirMacMgmtHdr ),
490 nPayload, &nPayload );
491 if ( DOT11F_FAILED( nStatus ) )
492 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700493 limLog( pMac, LOGE, FL("Failed to pack a Probe Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 nStatus );
495 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
496 return eSIR_FAILURE; // allocated!
497 }
498 else if ( DOT11F_WARNED( nStatus ) )
499 {
500 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -0800501 "robe Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 }
503
504 // Append any AddIE if present.
505 if( nAdditionalIELen )
506 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530507 vos_mem_copy( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 pAdditionalIE, nAdditionalIELen );
509 nPayload += nAdditionalIELen;
510 }
511
512 /* If this probe request is sent during P2P Search State, then we need
513 * to send it at OFDM rate.
514 */
515 if( ( SIR_BAND_5_GHZ == limGetRFBand(nChannelNum))
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 || (( pMac->lim.gpLimMlmScanReq != NULL) &&
517 pMac->lim.gpLimMlmScanReq->p2pSearch )
Gopichand Nakkala67967212013-02-15 17:31:15 +0530518 /* For unicast probe req mgmt from Join function
519 we don't set above variables. So we need to add
520 one more check whether it is pePersona is P2P_CLIENT or not */
521 || ( ( psessionEntry != NULL ) &&
522 ( VOS_P2P_CLIENT_MODE == psessionEntry->pePersona ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 )
524 {
525 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
526 }
527
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +0530528 if( ( psessionEntry != NULL ) && ( psessionEntry->is11Gonly == true ) &&
529 ( !IS_BROADCAST_MAC(bssid) ) ){
530 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
531 }
532
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) sizeof(tSirMacMgmtHdr) + nPayload,
534 HAL_TXRX_FRM_802_11_MGMT,
535 ANI_TXDIR_TODS,
536 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
537 limTxComplete, pFrame, txFlag );
538 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
539 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700540 limLog( pMac, LOGE, FL("could not send Probe Request frame!" ));
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 //Pkt will be freed up by the callback
542 return eSIR_FAILURE;
543 }
544
545 return eSIR_SUCCESS;
546} // End limSendProbeReqMgmtFrame.
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548tSirRetStatus limGetAddnIeForProbeResp(tpAniSirGlobal pMac,
549 tANI_U8* addIE, tANI_U16 *addnIELen,
550 tANI_U8 probeReqP2pIe)
551{
552 /* If Probe request doesn't have P2P IE, then take out P2P IE
553 from additional IE */
554 if(!probeReqP2pIe)
555 {
556 tANI_U8* tempbuf = NULL;
557 tANI_U16 tempLen = 0;
558 int left = *addnIELen;
559 v_U8_t *ptr = addIE;
560 v_U8_t elem_id, elem_len;
561
562 if(NULL == addIE)
563 {
564 PELOGE(limLog(pMac, LOGE,
565 FL(" NULL addIE pointer"));)
566 return eSIR_FAILURE;
567 }
568
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530569 tempbuf = vos_mem_malloc(left);
570 if ( NULL == tempbuf )
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
572 PELOGE(limLog(pMac, LOGE,
573 FL("Unable to allocate memory to store addn IE"));)
574 return eSIR_MEM_ALLOC_FAILED;
575 }
576
577 while(left >= 2)
578 {
579 elem_id = ptr[0];
580 elem_len = ptr[1];
581 left -= 2;
582 if(elem_len > left)
583 {
584 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700585 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 elem_id,elem_len,left);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530587 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return eSIR_FAILURE;
589 }
590 if ( !( (SIR_MAC_EID_VENDOR == elem_id) &&
591 (memcmp(&ptr[2], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE)==0) ) )
592 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530593 vos_mem_copy (tempbuf + tempLen, &ptr[0], elem_len + 2);
Jeff Johnson295189b2012-06-20 16:38:30 -0700594 tempLen += (elem_len + 2);
595 }
596 left -= elem_len;
597 ptr += (elem_len + 2);
598 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530599 vos_mem_copy (addIE, tempbuf, tempLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 *addnIELen = tempLen;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530601 vos_mem_free(tempbuf);
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 }
603 return eSIR_SUCCESS;
604}
Jeff Johnson295189b2012-06-20 16:38:30 -0700605
606void
607limSendProbeRspMgmtFrame(tpAniSirGlobal pMac,
608 tSirMacAddr peerMacAddr,
609 tpAniSSID pSsid,
610 short nStaId,
611 tANI_U8 nKeepAlive,
612 tpPESession psessionEntry,
613 tANI_U8 probeReqP2pIe)
614{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700615 tDot11fProbeResponse *pFrm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530616 tSirRetStatus nSirStatus;
c_hpothubcd78652014-04-28 22:31:08 +0530617 tANI_U32 cfg, nPayload, nStatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530618 tpSirMacMgmtHdr pMacHdr;
619 tANI_U8 *pFrame;
620 void *pPacket;
621 eHalStatus halstatus;
622 tANI_U32 addnIEPresent;
623 tANI_U32 addnIE1Len=0;
624 tANI_U32 addnIE2Len=0;
625 tANI_U32 addnIE3Len=0;
626 tANI_U16 totalAddnIeLen = 0;
627 tANI_U32 wpsApEnable=0, tmp;
628 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 tANI_U8 *addIE = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530630 tANI_U8 *pP2pIe = NULL;
631 tANI_U8 noaLen = 0;
632 tANI_U8 total_noaLen = 0;
633 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 + SIR_P2P_IE_HEADER_LEN];
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +0530635 tANI_U8 noaIe[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Kalikinkar dhara205da782014-03-21 15:49:32 -0700636 tDot11fIEExtCap extractedExtCap;
637 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +0530638 tANI_U32 nBytes = 0;
639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(pMac->gDriverType == eDRIVER_TYPE_MFG) // We don't answer requests
641 {
642 return; // in this case.
643 }
644
645 if(NULL == psessionEntry)
646 {
647 return;
648 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530649
650 pFrm = vos_mem_malloc(sizeof(tDot11fProbeResponse));
651 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700652 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530653 limLog(pMac, LOGE, FL("Unable to allocate memory in limSendProbeRspMgmtFrame") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700654 return;
655 }
656
Girish Gowli0e826792014-05-17 17:56:44 +0530657 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
658
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 // Fill out 'frm', after which we'll just hand the struct off to
660 // 'dot11fPackProbeResponse'.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530661 vos_mem_set(( tANI_U8* )pFrm, sizeof( tDot11fProbeResponse ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700662
663 // Timestamp to be updated by TFP, below.
664
665 // Beacon Interval:
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
667 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700668 pFrm->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 }
670 else
671 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800672 nSirStatus = wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &cfg);
673 if (eSIR_SUCCESS != nSirStatus)
674 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700675 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BEACON_INTERVAL from CFG (%d)."),
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800676 nSirStatus );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530677 vos_mem_free(pFrm);
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800678 return;
679 }
680 pFrm->BeaconInterval.interval = ( tANI_U16 ) cfg;
Madan Mohan Koyyalamudic0d1b3f2012-11-13 10:41:07 -0800681 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700682
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700683 PopulateDot11fCapabilities( pMac, &pFrm->Capabilities, psessionEntry );
684 PopulateDot11fSSID( pMac, ( tSirMacSSid* )pSsid, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700686 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700687
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700688 PopulateDot11fDSParams( pMac, &pFrm->DSParams, psessionEntry->currentOperChannel,psessionEntry);
689 PopulateDot11fIBSSParams( pMac, &pFrm->IBSSParams, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
693 {
694 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
695 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700696 PopulateDot11fProbeResWPSIEs(pMac, &pFrm->WscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 }
699 else
700 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800701 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700702 limLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700703
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800704 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800706 if (wpsApEnable)
707 {
708 PopulateDot11fWscInProbeRes(pMac, &pFrm->WscProbeRes);
709 }
710
711 if (pMac->lim.wscIeInfo.probeRespWscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
712 {
713 PopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
714 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
715 }
716
717 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
718 {
719 DePopulateDot11fWscRegistrarInfoInProbeRes(pMac, &pFrm->WscProbeRes);
720 pMac->lim.wscIeInfo.probeRespWscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
721 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700723
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700724 PopulateDot11fCountry( pMac, &pFrm->Country, psessionEntry);
725 PopulateDot11fEDCAParamSet( pMac, &pFrm->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727
728 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700729 PopulateDot11fERPInfo( pMac, &pFrm->ERPInfo, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700730
731
732 // N.B. In earlier implementations, the RSN IE would be placed in
733 // the frame here, before the WPA IE, if 'RSN_BEFORE_WPA' was defined.
734 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700735 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700736
737 //Populate HT IEs, when operating in 11n or Taurus modes.
Jeff Johnsone7245742012-09-05 17:12:55 -0700738 if ( psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700740 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700741 PopulateDot11fHTInfo( pMac, &pFrm->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530743
744#ifdef WLAN_FEATURE_AP_HT40_24G
745 /* Populate Overlapping BSS Scan Parameters IEs,
746 * when operating in HT40 in 2.4GHz.
747 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530748 if ((pMac->roam.configParam.apHT40_24GEnabled)
749 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530750 {
751 PopulateDot11fOBSSScanParameters( pMac, &pFrm->OBSSScanParameters,
752 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530753 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
754 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
755 * Mode in 40 MHz bit in HT capablity.
756 */
757 pFrm->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530758 }
759#endif
760
761 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
762
Jeff Johnsone7245742012-09-05 17:12:55 -0700763#ifdef WLAN_FEATURE_11AC
764 if(psessionEntry->vhtCapability)
765 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -0800766 limLog( pMac, LOG1, FL("Populate VHT IE in Probe Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530767 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
768 psessionEntry->currentOperChannel, eSIR_TRUE );
769 PopulateDot11fVHTOperation( pMac, &pFrm->VHTOperation ,
770 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700771 // we do not support multi users yet
772 //PopulateDot11fVHTExtBssLoad( pMac, &frm.VHTExtBssLoad );
773 }
774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700775
Sandeep Puligilla60342762014-01-30 21:05:37 +0530776
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530777 if ( psessionEntry->pLimStartBssReq )
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 {
779 PopulateDot11fWPA( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700780 &pFrm->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700781 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
782 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 }
784
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700785 PopulateDot11fWMM( pMac, &pFrm->WMMInfoAp, &pFrm->WMMParams, &pFrm->WMMCaps, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700786
787#if defined(FEATURE_WLAN_WAPI)
788 if( psessionEntry->pLimStartBssReq )
789 {
790 PopulateDot11fWAPI( pMac, &( psessionEntry->pLimStartBssReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700791 &pFrm->WAPI );
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 }
793
794#endif // defined(FEATURE_WLAN_WAPI)
795
Jeff Johnson295189b2012-06-20 16:38:30 -0700796 addnIEPresent = false;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 if( pMac->lim.gpLimRemainOnChanReq )
798 {
799 nBytes += (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq ) );
800 }
801 //Only use CFG for non-listen mode. This CFG is not working for concurrency
802 //In listening mode, probe rsp IEs is passed in the message from SME to PE
803 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 {
805
806 if (wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_ADDNIE_FLAG,
807 &addnIEPresent) != eSIR_SUCCESS)
808 {
809 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_FLAG"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530810 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 return;
812 }
813 }
814
815 if (addnIEPresent)
816 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530817
818 addIE = vos_mem_malloc(WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN*3);
819 if ( NULL == addIE )
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
821 PELOGE(limLog(pMac, LOGE,
822 FL("Unable to allocate memory to store addn IE"));)
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530823 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700824 return;
825 }
826
827 //Probe rsp IE available
828 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
829 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addnIE1Len) )
830 {
831 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530832 vos_mem_free(addIE);
833 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 return;
835 }
836 if (addnIE1Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA1_LEN && addnIE1Len &&
837 (nBytes + addnIE1Len) <= SIR_MAX_PACKET_SIZE)
838 {
839 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
840 WNI_CFG_PROBE_RSP_ADDNIE_DATA1, &addIE[0],
841 &addnIE1Len) )
842 {
843 limLog(pMac, LOGP,
844 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA1 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530845 vos_mem_free(addIE);
846 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 return;
848 }
849 }
850
851 //Probe rsp IE available
852 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
853 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addnIE2Len) )
854 {
855 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530856 vos_mem_free(addIE);
857 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700858 return;
859 }
860 if (addnIE2Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA2_LEN && addnIE2Len &&
861 (nBytes + addnIE2Len) <= SIR_MAX_PACKET_SIZE)
862 {
863 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
864 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, &addIE[addnIE1Len],
865 &addnIE2Len) )
866 {
867 limLog(pMac, LOGP,
868 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA2 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530869 vos_mem_free(addIE);
870 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 return;
872 }
873 }
874
875 //Probe rsp IE available
876 if ( eSIR_SUCCESS != wlan_cfgGetStrLen(pMac,
877 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, &addnIE3Len) )
878 {
879 limLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 length"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530880 vos_mem_free(addIE);
881 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 return;
883 }
884 if (addnIE3Len <= WNI_CFG_PROBE_RSP_ADDNIE_DATA3_LEN && addnIE3Len &&
885 (nBytes + addnIE3Len) <= SIR_MAX_PACKET_SIZE)
886 {
887 if ( eSIR_SUCCESS != wlan_cfgGetStr(pMac,
888 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
889 &addIE[addnIE1Len + addnIE2Len],
890 &addnIE3Len) )
891 {
892 limLog(pMac, LOGP,
893 FL("Unable to get WNI_CFG_PROBE_RSP_ADDNIE_DATA3 String"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530894 vos_mem_free(addIE);
895 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 return;
897 }
898 }
899 totalAddnIeLen = addnIE1Len + addnIE2Len + addnIE3Len;
900
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 if(eSIR_SUCCESS != limGetAddnIeForProbeResp(pMac, addIE, &totalAddnIeLen, probeReqP2pIe))
902 {
903 limLog(pMac, LOGP,
904 FL("Unable to get final Additional IE for Probe Req"));
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530905 vos_mem_free(addIE);
906 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 return;
908 }
Kalikinkar dhara205da782014-03-21 15:49:32 -0700909
Kalikinkar dhara205da782014-03-21 15:49:32 -0700910 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
911 addIE,
912 &totalAddnIeLen,
913 &extractedExtCap );
914 if(eSIR_SUCCESS != nSirStatus )
915 {
916 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
917 limLog(pMac, LOG1,
918 FL("Unable to Stripoff ExtCap IE from Probe Rsp"));
919 }
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 nBytes = nBytes + totalAddnIeLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530922 limLog(pMac, LOG1,
923 FL("probe rsp packet size is %d "), nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700924 if (probeReqP2pIe)
925 {
926 pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], totalAddnIeLen);
927 if (pP2pIe != NULL)
928 {
929 //get NoA attribute stream P2P IE
930 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
931 if (noaLen != 0)
932 {
933 total_noaLen = limBuildP2pIe(pMac, &noaIe[0],
934 &noaStream[0], noaLen);
935 nBytes = nBytes + total_noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530936 limLog(pMac, LOG1,
937 FL("p2p probe rsp packet size is %d, noalength is %d"),
938 nBytes, total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 }
940 }
941 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700942 }
943
c_hpothubcd78652014-04-28 22:31:08 +0530944 /*merge ExtCap IE*/
945 if (extractedExtCapFlag && extractedExtCap.present)
946 {
947 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
948 }
949
950 nStatus = dot11fGetPackedProbeResponseSize( pMac, pFrm, &nPayload );
951 if ( DOT11F_FAILED( nStatus ) )
952 {
953 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
954 "or a Probe Response (0x%08x)."),
955 nStatus );
956 // We'll fall back on the worst case scenario:
957 nPayload = sizeof( tDot11fProbeResponse );
958 }
959 else if ( DOT11F_WARNED( nStatus ) )
960 {
961 limLog( pMac, LOGW, FL("There were warnings while calculating"
962 "the packed size for a Probe Response "
963 "(0x%08x)."), nStatus );
964 }
965
966 nBytes += nPayload + sizeof( tSirMacMgmtHdr );
967
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
969 ( tANI_U16 )nBytes, ( void** ) &pFrame,
970 ( void** ) &pPacket );
971 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
972 {
973 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Pro"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700974 "be Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 if ( addIE != NULL )
976 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530977 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530979 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -0700980 return;
981 }
982
983 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530984 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -0700985
986 // Next, we fill out the buffer descriptor:
987 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
988 SIR_MAC_MGMT_PROBE_RSP, peerMacAddr,psessionEntry->selfMacAddr);
989 if ( eSIR_SUCCESS != nSirStatus )
990 {
991 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -0700992 "tor for a Probe Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -0700993 nSirStatus );
994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
995 ( void* ) pFrame, ( void* ) pPacket );
996 if ( addIE != NULL )
997 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +0530998 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301000 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 return;
1002 }
1003
1004 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1005
1006 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1007
1008 // That done, pack the Probe Response:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001009 nStatus = dot11fPackProbeResponse( pMac, pFrm, pFrame + sizeof(tSirMacMgmtHdr),
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 nPayload, &nPayload );
1011 if ( DOT11F_FAILED( nStatus ) )
1012 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001013 limLog( pMac, LOGE, FL("Failed to pack a Probe Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 nStatus );
1015 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1016 if ( addIE != NULL )
1017 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301018 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301020 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return; // allocated!
1022 }
1023 else if ( DOT11F_WARNED( nStatus ) )
1024 {
1025 limLog( pMac, LOGW, FL("There were warnings while packing a P"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001026 "robe Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001027 }
1028
1029 PELOG3(limLog( pMac, LOG3, FL("Sending Probe Response frame to ") );
1030 limPrintMacAddr( pMac, peerMacAddr, LOG3 );)
1031
1032 pMac->sys.probeRespond++;
1033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 if( pMac->lim.gpLimRemainOnChanReq )
1035 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301036 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload,
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 pMac->lim.gpLimRemainOnChanReq->probeRspIe, (pMac->lim.gpLimRemainOnChanReq->length - sizeof( tSirRemainOnChnReq )) );
1038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001039
1040 if ( addnIEPresent )
1041 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301042 vos_mem_copy(pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], totalAddnIeLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if (noaLen != 0)
1045 {
Krunal Soni81b24262013-05-15 17:46:41 -07001046 if (total_noaLen > (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN))
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 {
1048 limLog(pMac, LOGE,
Kaushik, Sushant96ac9d72013-12-11 19:28:10 +05301049 FL("Not able to insert NoA because of length constraint."
1050 "Total Length is :%d"),total_noaLen);
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301051 vos_mem_free(addIE);
1052 vos_mem_free(pFrm);
Krunal Soni81b24262013-05-15 17:46:41 -07001053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1054 ( void* ) pFrame, ( void* ) pPacket );
1055 return;
1056 }
1057 else
1058 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301059 vos_mem_copy( &pFrame[nBytes - (total_noaLen)],
Krunal Soni81b24262013-05-15 17:46:41 -07001060 &noaIe[0], total_noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 }
1062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001063
1064 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1066 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 )
1068 {
1069 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1070 }
1071
1072 // Queue Probe Response frame in high priority WQ
1073 halstatus = halTxFrame( ( tHalHandle ) pMac, pPacket,
1074 ( tANI_U16 ) nBytes,
1075 HAL_TXRX_FRM_802_11_MGMT,
1076 ANI_TXDIR_TODS,
1077 7,//SMAC_SWBD_TX_TID_MGMT_LOW,
1078 limTxComplete, pFrame, txFlag );
1079 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1080 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001081 limLog( pMac, LOGE, FL("Could not send Probe Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 //Pkt will be freed up by the callback
1083 }
1084
1085 if ( addIE != NULL )
1086 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301087 vos_mem_free(addIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
1089
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301090 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07001091 return;
1092
1093
Jeff Johnson295189b2012-06-20 16:38:30 -07001094} // End limSendProbeRspMgmtFrame.
1095
1096void
1097limSendAddtsReqActionFrame(tpAniSirGlobal pMac,
1098 tSirMacAddr peerMacAddr,
1099 tSirAddtsReqInfo *pAddTS,
1100 tpPESession psessionEntry)
1101{
1102 tANI_U16 i;
1103 tANI_U8 *pFrame;
1104 tSirRetStatus nSirStatus;
1105 tDot11fAddTSRequest AddTSReq;
1106 tDot11fWMMAddTSRequest WMMAddTSReq;
1107 tANI_U32 nPayload, nBytes, nStatus;
1108 tpSirMacMgmtHdr pMacHdr;
1109 void *pPacket;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001110#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 tANI_U32 phyMode;
1112#endif
1113 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301114 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
1116 if(NULL == psessionEntry)
1117 {
1118 return;
1119 }
1120
1121 if ( ! pAddTS->wmeTspecPresent )
1122 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301123 vos_mem_set(( tANI_U8* )&AddTSReq, sizeof( AddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001124
1125 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1126 AddTSReq.DialogToken.token = pAddTS->dialogToken;
1127 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1128 if ( pAddTS->lleTspecPresent )
1129 {
1130 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSReq.TSPEC );
1131 }
1132 else
1133 {
1134 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSReq.WMMTSPEC );
1135 }
1136
1137 if ( pAddTS->lleTspecPresent )
1138 {
1139 AddTSReq.num_WMMTCLAS = 0;
1140 AddTSReq.num_TCLAS = pAddTS->numTclas;
1141 for ( i = 0; i < pAddTS->numTclas; ++i)
1142 {
1143 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1144 &AddTSReq.TCLAS[i] );
1145 }
1146 }
1147 else
1148 {
1149 AddTSReq.num_TCLAS = 0;
1150 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
1151 for ( i = 0; i < pAddTS->numTclas; ++i)
1152 {
1153 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1154 &AddTSReq.WMMTCLAS[i] );
1155 }
1156 }
1157
1158 if ( pAddTS->tclasProcPresent )
1159 {
1160 if ( pAddTS->lleTspecPresent )
1161 {
1162 AddTSReq.TCLASSPROC.processing = pAddTS->tclasProc;
1163 AddTSReq.TCLASSPROC.present = 1;
1164 }
1165 else
1166 {
1167 AddTSReq.WMMTCLASPROC.version = 1;
1168 AddTSReq.WMMTCLASPROC.processing = pAddTS->tclasProc;
1169 AddTSReq.WMMTCLASPROC.present = 1;
1170 }
1171 }
1172
1173 nStatus = dot11fGetPackedAddTSRequestSize( pMac, &AddTSReq, &nPayload );
1174 if ( DOT11F_FAILED( nStatus ) )
1175 {
1176 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001177 "or an Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001178 nStatus );
1179 // We'll fall back on the worst case scenario:
1180 nPayload = sizeof( tDot11fAddTSRequest );
1181 }
1182 else if ( DOT11F_WARNED( nStatus ) )
1183 {
1184 limLog( pMac, LOGW, FL("There were warnings while calculating"
1185 "the packed size for an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001186 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 }
1188 }
1189 else
1190 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301191 vos_mem_set(( tANI_U8* )&WMMAddTSReq, sizeof( WMMAddTSReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
1194 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
1195 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
1196
1197 // WMM spec 2.2.10 - status code is only filled in for ADDTS response
1198 WMMAddTSReq.StatusCode.statusCode = 0;
1199
1200 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSReq.WMMTSPEC );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001202 limGetPhyMode(pMac, &phyMode, psessionEntry);
1203
1204 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
1205 {
1206 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
1207 }
1208 else
1209 {
1210 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
1211 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001212 PopulateDot11TSRSIE(pMac,&pAddTS->tsrsIE, &WMMAddTSReq.ESETrafStrmRateSet,sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07001213#endif
1214 // fillWmeTspecIE
1215
1216 nStatus = dot11fGetPackedWMMAddTSRequestSize( pMac, &WMMAddTSReq, &nPayload );
1217 if ( DOT11F_FAILED( nStatus ) )
1218 {
1219 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001220 "or a WMM Add TS Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 nStatus );
1222 // We'll fall back on the worst case scenario:
1223 nPayload = sizeof( tDot11fAddTSRequest );
1224 }
1225 else if ( DOT11F_WARNED( nStatus ) )
1226 {
1227 limLog( pMac, LOGW, FL("There were warnings while calculating"
1228 "the packed size for a WMM Add TS Requ"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001229 "est (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 }
1231 }
1232
1233 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1234
1235 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1236 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1237 ( void** ) &pPacket );
1238 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1239 {
1240 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001241 "d TS Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 return;
1243 }
1244
1245 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301246 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001247
1248 // Next, we fill out the buffer descriptor:
1249 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1250 SIR_MAC_MGMT_ACTION, peerMacAddr,psessionEntry->selfMacAddr);
1251 if ( eSIR_SUCCESS != nSirStatus )
1252 {
1253 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001254 "tor for an Add TS Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 nSirStatus );
1256 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1257 ( void* ) pFrame, ( void* ) pPacket );
1258 return;
1259 }
1260
1261 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1262
1263 #if 0
1264 cfgLen = SIR_MAC_ADDR_LENGTH;
1265 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1266 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1267 {
1268 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001269 "e sending an Add TS Request.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1271 ( void* ) pFrame, ( void* ) pPacket );
1272 return;
1273 }
1274 #endif //TO SUPPORT BT-AMP
1275
1276 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1277
Chet Lanctot186b5732013-03-18 10:26:30 -07001278#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001279 limSetProtectedBit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001280#endif
1281
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 // That done, pack the struct:
1283 if ( ! pAddTS->wmeTspecPresent )
1284 {
1285 nStatus = dot11fPackAddTSRequest( pMac, &AddTSReq,
1286 pFrame + sizeof(tSirMacMgmtHdr),
1287 nPayload, &nPayload );
1288 if ( DOT11F_FAILED( nStatus ) )
1289 {
1290 limLog( pMac, LOGE, FL("Failed to pack an Add TS Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001291 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 nStatus );
1293 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1294 return; // allocated!
1295 }
1296 else if ( DOT11F_WARNED( nStatus ) )
1297 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001298 limLog( pMac, LOGW, FL("There were warnings while packing "
1299 "an Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001300 }
1301 }
1302 else
1303 {
1304 nStatus = dot11fPackWMMAddTSRequest( pMac, &WMMAddTSReq,
1305 pFrame + sizeof(tSirMacMgmtHdr),
1306 nPayload, &nPayload );
1307 if ( DOT11F_FAILED( nStatus ) )
1308 {
1309 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001310 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 nStatus );
1312 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1313 return; // allocated!
1314 }
1315 else if ( DOT11F_WARNED( nStatus ) )
1316 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001317 limLog( pMac, LOGW, FL("There were warnings while packing "
1318 "a WMM Add TS Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001319 }
1320 }
1321
Abhishek Singh127a8442014-12-15 17:31:27 +05301322 limLog( pMac, LOG1, FL("Sending an Add TS Request frame to ") );
1323 limPrintMacAddr( pMac, peerMacAddr, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001324
1325 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1327 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 )
1329 {
1330 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1331 }
1332
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301333 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1334 psessionEntry->peSessionId,
1335 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 // Queue Addts Response frame in high priority WQ
1337 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1338 HAL_TXRX_FRM_802_11_MGMT,
1339 ANI_TXDIR_TODS,
1340 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1341 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301342 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1343 psessionEntry->peSessionId,
1344 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1346 {
1347 limLog( pMac, LOGE, FL( "*** Could not send an Add TS Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001348 " (%X) ***" ), halstatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 //Pkt will be freed up by the callback
1350 }
1351
1352} // End limSendAddtsReqActionFrame.
1353
Jeff Johnson295189b2012-06-20 16:38:30 -07001354
1355
1356void
1357limSendAssocRspMgmtFrame(tpAniSirGlobal pMac,
1358 tANI_U16 statusCode,
1359 tANI_U16 aid,
1360 tSirMacAddr peerMacAddr,
1361 tANI_U8 subType,
1362 tpDphHashNode pSta,tpPESession psessionEntry)
1363{
1364 static tDot11fAssocResponse frm;
1365 tANI_U8 *pFrame, *macAddr;
1366 tpSirMacMgmtHdr pMacHdr;
1367 tSirRetStatus nSirStatus;
1368 tANI_U8 lleMode = 0, fAddTS, edcaInclude = 0;
1369 tHalBitVal qosMode, wmeMode;
c_hpothubcd78652014-04-28 22:31:08 +05301370 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001371 void *pPacket;
1372 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301373 tUpdateBeaconParams beaconParams;
1374 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 tANI_U32 addnIEPresent = false;
1376 tANI_U32 addnIELen=0;
1377 tANI_U8 addIE[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1378 tpSirAssocReq pAssocReq = NULL;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301379 tANI_U16 addStripoffIELen = 0;
1380 tDot11fIEExtCap extractedExtCap;
1381 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_FALSE;
c_hpothubcd78652014-04-28 22:31:08 +05301382 tANI_U32 nBytes = 0;
Kalikinkar dhara205da782014-03-21 15:49:32 -07001383
Chet Lanctot8cecea22014-02-11 19:09:36 -08001384#ifdef WLAN_FEATURE_11W
1385 tANI_U32 retryInterval;
1386 tANI_U32 maxRetries;
1387#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 if(NULL == psessionEntry)
1390 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301391 limLog( pMac, LOGE, FL("psessionEntry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 return;
1393 }
1394
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301395 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001396
1397 limGetQosMode(psessionEntry, &qosMode);
1398 limGetWmeMode(psessionEntry, &wmeMode);
1399
1400 // An Add TS IE is added only if the AP supports it and the requesting
1401 // STA sent a traffic spec.
1402 fAddTS = ( qosMode && pSta && pSta->qos.addtsPresent ) ? 1 : 0;
1403
1404 PopulateDot11fCapabilities( pMac, &frm.Capabilities, psessionEntry );
1405
1406 frm.Status.status = statusCode;
1407
1408 frm.AID.associd = aid | LIM_AID_MASK;
1409
1410 if ( NULL == pSta )
1411 {
1412 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.SuppRates,psessionEntry);
1413 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &frm.ExtSuppRates, psessionEntry );
1414 }
1415 else
1416 {
1417 PopulateDot11fAssocRspRates( pMac, &frm.SuppRates, &frm.ExtSuppRates,
1418 pSta->supportedRates.llbRates, pSta->supportedRates.llaRates );
1419 }
1420
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
1422 {
1423 if( pSta != NULL && eSIR_SUCCESS == statusCode )
1424 {
1425 pAssocReq =
1426 (tpSirAssocReq) psessionEntry->parsedAssocReq[pSta->assocId];
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 /* populate P2P IE in AssocRsp when assocReq from the peer includes P2P IE */
1428 if( pAssocReq != NULL && pAssocReq->addIEPresent ) {
1429 PopulateDot11AssocResP2PIE(pMac, &frm.P2PAssocRes, pAssocReq);
1430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 }
1432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001433
1434 if ( NULL != pSta )
1435 {
1436 if ( eHAL_SET == qosMode )
1437 {
1438 if ( pSta->lleEnabled )
1439 {
1440 lleMode = 1;
1441 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) )
1442 {
1443 PopulateDot11fEDCAParamSet( pMac, &frm.EDCAParamSet, psessionEntry);
1444
1445// FramesToDo:...
1446// if ( fAddTS )
1447// {
1448// tANI_U8 *pAf = pBody;
1449// *pAf++ = SIR_MAC_QOS_ACTION_EID;
1450// tANI_U32 tlen;
1451// status = sirAddtsRspFill(pMac, pAf, statusCode, &pSta->qos.addts, NULL,
1452// &tlen, bufLen - frameLen);
1453// } // End if on Add TS.
1454 }
1455 } // End if on .11e enabled in 'pSta'.
1456 } // End if on QOS Mode on.
1457
1458 if ( ( ! lleMode ) && ( eHAL_SET == wmeMode ) && pSta->wmeEnabled )
1459 {
1460 if ( ( ! pSta->aniPeer ) || ( ! PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1461 {
1462
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 PopulateDot11fWMMParams( pMac, &frm.WMMParams, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07001464
1465 if ( pSta->wsmEnabled )
1466 {
1467 PopulateDot11fWMMCaps(&frm.WMMCaps );
1468 }
1469 }
1470 }
1471
1472 if ( pSta->aniPeer )
1473 {
1474 if ( ( lleMode && PROP_CAPABILITY_GET( 11EQOS, pSta->propCapability ) ) ||
1475 ( pSta->wmeEnabled && PROP_CAPABILITY_GET( WME, pSta->propCapability ) ) )
1476 {
1477 edcaInclude = 1;
1478 }
1479
1480 } // End if on Airgo peer.
1481
1482 if ( pSta->mlmStaContext.htCapability &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001483 psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05301485 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Response"));
Jeff Johnsone7245742012-09-05 17:12:55 -07001486 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Sachin Ahujac3a26232014-09-23 22:27:30 +05301487 /*
1488 *Check the STA capability and update the HTCaps accordingly
1489 */
1490 frm.HTCaps.supportedChannelWidthSet =
1491 (pSta->htSupportedChannelWidthSet < psessionEntry->htSupportedChannelWidthSet) ?
1492 pSta->htSupportedChannelWidthSet : psessionEntry->htSupportedChannelWidthSet ;
1493
1494 if (!frm.HTCaps.supportedChannelWidthSet)
1495 frm.HTCaps.shortGI40MHz = 0;
1496
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 PopulateDot11fHTInfo( pMac, &frm.HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07001498 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05301499 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
1500 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
1501 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
1502 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
1503 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
1504
1505
Jeff Johnsone7245742012-09-05 17:12:55 -07001506
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301507#ifdef WLAN_FEATURE_AP_HT40_24G
1508 /* Populate Overlapping BSS Scan Parameters IEs,
1509 * when operating in HT40 in 2.4GHz.
1510 */
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +05301511 if ((pMac->roam.configParam.apHT40_24GEnabled)
1512 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301513 {
1514 PopulateDot11fOBSSScanParameters( pMac, &frm.OBSSScanParameters,
1515 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +05301516 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
1517 * a 20/40 MHz BSS may generate DSSS/CCK transmissions.Set DSSS/CCK
1518 * Mode in 40 MHz bit in HT capablity.
1519 */
1520 frm.HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301521 }
1522#endif
1523
1524 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07001525#ifdef WLAN_FEATURE_11AC
1526 if( pSta->mlmStaContext.vhtCapability &&
1527 psessionEntry->vhtCapability )
1528 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08001529 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Response"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05301530 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
1531 psessionEntry->currentOperChannel, eSIR_TRUE );
1532 PopulateDot11fVHTOperation( pMac, &frm.VHTOperation,
1533 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -07001534 }
1535#endif
1536
Chet Lanctot8cecea22014-02-11 19:09:36 -08001537#ifdef WLAN_FEATURE_11W
Dino Myclea7f18452014-04-24 08:55:31 +05301538 if( eSIR_MAC_TRY_AGAIN_LATER == statusCode )
1539 {
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001540 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1541 &maxRetries ) != eSIR_SUCCESS )
1542 limLog( pMac, LOGE,
1543 FL("Could not retrieve PMF SA Query maximum retries value") );
1544 else
1545 if ( wlan_cfgGetInt(pMac, WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1546 &retryInterval ) != eSIR_SUCCESS)
1547 limLog( pMac, LOGE,
1548 FL("Could not retrieve PMF SA Query timer interval value") );
Dino Myclea7f18452014-04-24 08:55:31 +05301549 else
Chet Lanctotfadc8e32014-04-24 14:50:52 -07001550 PopulateDot11fTimeoutInterval(
1551 pMac, &frm.TimeoutInterval, SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1552 (maxRetries - pSta->pmfSaQueryRetryCount) * retryInterval );
Dino Myclea7f18452014-04-24 08:55:31 +05301553 }
Chet Lanctot8cecea22014-02-11 19:09:36 -08001554#endif
Dino Myclea7f18452014-04-24 08:55:31 +05301555 } // End if on non-NULL 'pSta'.
Jeff Johnson295189b2012-06-20 16:38:30 -07001556
Chet Lanctot8cecea22014-02-11 19:09:36 -08001557 vos_mem_set(( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 if( psessionEntry->limSystemRole == eLIM_AP_ROLE ){
1560 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
1561 limDecideApProtection(pMac, peerMacAddr, &beaconParams,psessionEntry);
1562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001563
1564 limUpdateShortPreamble(pMac, peerMacAddr, &beaconParams, psessionEntry);
1565 limUpdateShortSlotTime(pMac, peerMacAddr, &beaconParams, psessionEntry);
1566
1567 beaconParams.bssIdx = psessionEntry->bssIdx;
1568
1569 //Send message to HAL about beacon parameter change.
1570 if(beaconParams.paramChangeBitmap)
1571 {
1572 schSetFixedBeaconFields(pMac,psessionEntry);
1573 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
1574 }
1575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if ( pAssocReq != NULL )
1577 {
1578 if (wlan_cfgGetInt(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_FLAG,
1579 &addnIEPresent) != eSIR_SUCCESS)
1580 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301581 limLog(pMac, LOGP, FL("Unable to get "
1582 "WNI_CFG_ASSOC_RSP_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 return;
1584 }
1585
1586 if (addnIEPresent)
1587 {
1588 //Assoc rsp IE available
1589 if (wlan_cfgGetStrLen(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1590 &addnIELen) != eSIR_SUCCESS)
1591 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301592 limLog(pMac, LOGP, FL("Unable to get "
1593 "WNI_CFG_ASSOC_RSP_ADDNIE_DATA length"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001594 return;
1595 }
1596
1597 if (addnIELen <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN && addnIELen &&
1598 (nBytes + addnIELen) <= SIR_MAX_PACKET_SIZE)
1599 {
1600 if (wlan_cfgGetStr(pMac, WNI_CFG_ASSOC_RSP_ADDNIE_DATA,
1601 &addIE[0], &addnIELen) == eSIR_SUCCESS)
1602 {
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301603
1604 vos_mem_set(( tANI_U8* )&extractedExtCap,
1605 sizeof( tDot11fIEExtCap ), 0);
Mahesh A Saptasagare00ff532014-10-17 19:05:14 +05301606 addStripoffIELen = addnIELen;
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301607 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac,
1608 &addIE[0],
1609 &addStripoffIELen,
1610 &extractedExtCap );
1611 if(eSIR_SUCCESS != nSirStatus)
1612 {
1613 limLog(pMac, LOG1,
1614 FL("Unable to Stripoff ExtCap IE from Assoc Rsp"));
1615 }
1616 else
1617 {
1618 addnIELen = addStripoffIELen;
1619 extractedExtCapFlag = eANI_BOOLEAN_TRUE;
1620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 nBytes = nBytes + addnIELen;
1622 }
1623 }
1624 }
1625 }
1626
Mahesh A Saptasagar38c177e2014-10-17 18:55:48 +05301627 /* merge the ExtCap struct*/
1628 if (extractedExtCapFlag && extractedExtCap.present)
1629 {
1630 limMergeExtCapIEStruct(&(frm.ExtCap), &extractedExtCap);
1631 }
1632
c_hpothubcd78652014-04-28 22:31:08 +05301633 nStatus = dot11fGetPackedAssocResponseSize( pMac, &frm, &nPayload );
1634 if ( DOT11F_FAILED( nStatus ) )
1635 {
1636 limLog( pMac, LOGE, FL("Failed to calculate the packed size f"
1637 "or an Association Response (0x%08x)."),
1638 nStatus );
1639 return;
1640 }
1641 else if ( DOT11F_WARNED( nStatus ) )
1642 {
1643 limLog( pMac, LOGW, FL("There were warnings while calculating "
1644 "the packed size for an Association Re"
1645 "sponse (0x%08x)."), nStatus );
1646 }
1647
1648 nBytes += sizeof( tSirMacMgmtHdr ) + nPayload;
1649
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1651 ( tANI_U16 )nBytes, ( void** ) &pFrame,
1652 ( void** ) &pPacket );
1653 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1654 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001655 limLog(pMac, LOGP, FL("Call to bufAlloc failed for RE/ASSOC RSP."));
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 return;
1657 }
1658
1659 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301660 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661
1662 // Next, we fill out the buffer descriptor:
1663 nSirStatus = limPopulateMacHeader( pMac,
1664 pFrame,
1665 SIR_MAC_MGMT_FRAME,
1666 ( LIM_ASSOC == subType ) ?
1667 SIR_MAC_MGMT_ASSOC_RSP :
1668 SIR_MAC_MGMT_REASSOC_RSP,
1669 peerMacAddr,psessionEntry->selfMacAddr);
1670 if ( eSIR_SUCCESS != nSirStatus )
1671 {
1672 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001673 "tor for an Association Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 nSirStatus );
1675 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1676 ( void* ) pFrame, ( void* ) pPacket );
1677 return;
1678 }
1679
1680 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1681
Jeff Johnson295189b2012-06-20 16:38:30 -07001682 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1683
1684 nStatus = dot11fPackAssocResponse( pMac, &frm,
1685 pFrame + sizeof( tSirMacMgmtHdr ),
1686 nPayload, &nPayload );
1687 if ( DOT11F_FAILED( nStatus ) )
1688 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05301689 limLog( pMac, LOGE, FL("Failed to pack an Association Response"
1690 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
1692 ( void* ) pFrame, ( void* ) pPacket );
1693 return; // allocated!
1694 }
1695 else if ( DOT11F_WARNED( nStatus ) )
1696 {
1697 limLog( pMac, LOGW, FL("There were warnings while packing an "
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001698 "Association Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 }
1700
1701 macAddr = pMacHdr->da;
1702
1703 if (subType == LIM_ASSOC)
1704 {
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301705 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 FL("*** Sending Assoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301707 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001708 }
1709 else{
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301710 limLog(pMac, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 FL("*** Sending ReAssoc Resp status %d aid %d to "),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301712 statusCode, aid);
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 }
Abhishek Singh3cbf6052014-12-15 16:46:42 +05301714 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07001715
1716 if ( addnIEPresent )
1717 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301718 vos_mem_copy ( pFrame+sizeof(tSirMacMgmtHdr)+nPayload, &addIE[0], addnIELen ) ;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 }
1720
1721 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07001722 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
1723 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07001724 )
1725 {
1726 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1727 }
1728
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05301729 limLog( pMac, LOG1, FL("Sending Assoc resp over WQ5 to "MAC_ADDRESS_STR
1730 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
1731 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
1732
1733 txFlag |= HAL_USE_FW_IN_TX_PATH;
1734
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301735 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
1736 psessionEntry->peSessionId,
1737 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05301738
1739 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
1740 {
1741 limLog(pMac, LOG1, FL("Re/AssocRsp - txBdToken %u"), pMac->lim.txBdToken);
1742 /// Queue Association Response frame in high priority WQ
1743 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
1744 HAL_TXRX_FRM_802_11_MGMT,
1745 ANI_TXDIR_TODS,
1746 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1747 limTxComplete, pFrame, limTxBdComplete,
1748 txFlag, pMac->lim.txBdToken );
1749 pMac->lim.txBdToken++;
1750 }
1751 else
1752 {
1753 /// Queue Association Response frame in high priority WQ
1754 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
1755 HAL_TXRX_FRM_802_11_MGMT,
1756 ANI_TXDIR_TODS,
1757 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
1758 limTxComplete, pFrame, txFlag );
1759 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05301760 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
1761 psessionEntry->peSessionId,
1762 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1764 {
1765 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001766 FL("*** Could not Send Re/AssocRsp, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 nSirStatus);
1768
1769 //Pkt will be freed up by the callback
1770 }
1771
1772 // update the ANI peer station count
1773 //FIXME_PROTECTION : take care of different type of station
1774 // counter inside this function.
1775 limUtilCountStaAdd(pMac, pSta, psessionEntry);
1776
1777} // End limSendAssocRspMgmtFrame.
1778
1779
1780
1781void
1782limSendAddtsRspActionFrame(tpAniSirGlobal pMac,
1783 tSirMacAddr peer,
1784 tANI_U16 nStatusCode,
1785 tSirAddtsReqInfo *pAddTS,
1786 tSirMacScheduleIE *pSchedule,
1787 tpPESession psessionEntry)
1788{
1789 tANI_U8 *pFrame;
1790 tpSirMacMgmtHdr pMacHdr;
1791 tDot11fAddTSResponse AddTSRsp;
1792 tDot11fWMMAddTSResponse WMMAddTSRsp;
1793 tSirRetStatus nSirStatus;
1794 tANI_U32 i, nBytes, nPayload, nStatus;
1795 void *pPacket;
1796 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05301797 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001798
1799 if(NULL == psessionEntry)
1800 {
1801 return;
1802 }
1803
1804 if ( ! pAddTS->wmeTspecPresent )
1805 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301806 vos_mem_set( ( tANI_U8* )&AddTSRsp, sizeof( AddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001807
1808 AddTSRsp.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1809 AddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1810 AddTSRsp.DialogToken.token = pAddTS->dialogToken;
1811 AddTSRsp.Status.status = nStatusCode;
1812
1813 // The TsDelay information element is only filled in for a specific
1814 // status code:
1815 if ( eSIR_MAC_TS_NOT_CREATED_STATUS == nStatusCode )
1816 {
1817 if ( pAddTS->wsmTspecPresent )
1818 {
1819 AddTSRsp.WMMTSDelay.version = 1;
1820 AddTSRsp.WMMTSDelay.delay = 10;
1821 AddTSRsp.WMMTSDelay.present = 1;
1822 }
1823 else
1824 {
1825 AddTSRsp.TSDelay.delay = 10;
1826 AddTSRsp.TSDelay.present = 1;
1827 }
1828 }
1829
1830 if ( pAddTS->wsmTspecPresent )
1831 {
1832 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &AddTSRsp.WMMTSPEC );
1833 }
1834 else
1835 {
1836 PopulateDot11fTSPEC( &pAddTS->tspec, &AddTSRsp.TSPEC );
1837 }
1838
1839 if ( pAddTS->wsmTspecPresent )
1840 {
1841 AddTSRsp.num_WMMTCLAS = 0;
1842 AddTSRsp.num_TCLAS = pAddTS->numTclas;
1843 for ( i = 0; i < AddTSRsp.num_TCLAS; ++i)
1844 {
1845 PopulateDot11fTCLAS( pMac, &pAddTS->tclasInfo[i],
1846 &AddTSRsp.TCLAS[i] );
1847 }
1848 }
1849 else
1850 {
1851 AddTSRsp.num_TCLAS = 0;
1852 AddTSRsp.num_WMMTCLAS = pAddTS->numTclas;
1853 for ( i = 0; i < AddTSRsp.num_WMMTCLAS; ++i)
1854 {
1855 PopulateDot11fWMMTCLAS( pMac, &pAddTS->tclasInfo[i],
1856 &AddTSRsp.WMMTCLAS[i] );
1857 }
1858 }
1859
1860 if ( pAddTS->tclasProcPresent )
1861 {
1862 if ( pAddTS->wsmTspecPresent )
1863 {
1864 AddTSRsp.WMMTCLASPROC.version = 1;
1865 AddTSRsp.WMMTCLASPROC.processing = pAddTS->tclasProc;
1866 AddTSRsp.WMMTCLASPROC.present = 1;
1867 }
1868 else
1869 {
1870 AddTSRsp.TCLASSPROC.processing = pAddTS->tclasProc;
1871 AddTSRsp.TCLASSPROC.present = 1;
1872 }
1873 }
1874
1875 // schedule element is included only if requested in the tspec and we are
1876 // using hcca (or both edca and hcca)
1877 // 11e-D8.0 is inconsistent on whether the schedule element is included
1878 // based on tspec schedule bit or not. Sec 7.4.2.2. says one thing but
1879 // pg 46, line 17-18 says something else. So just include it and let the
1880 // sta figure it out
1881 if ((pSchedule != NULL) &&
1882 ((pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
1883 (pAddTS->tspec.tsinfo.traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH)))
1884 {
1885 if ( pAddTS->wsmTspecPresent )
1886 {
1887 PopulateDot11fWMMSchedule( pSchedule, &AddTSRsp.WMMSchedule );
1888 }
1889 else
1890 {
1891 PopulateDot11fSchedule( pSchedule, &AddTSRsp.Schedule );
1892 }
1893 }
1894
1895 nStatus = dot11fGetPackedAddTSResponseSize( pMac, &AddTSRsp, &nPayload );
1896 if ( DOT11F_FAILED( nStatus ) )
1897 {
1898 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001899 "ze for an Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 nStatus );
1901 // We'll fall back on the worst case scenario:
1902 nPayload = sizeof( tDot11fAddTSResponse );
1903 }
1904 else if ( DOT11F_WARNED( nStatus ) )
1905 {
1906 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001907 "ting the packed size for an Add TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001908 " Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001909 }
1910 }
1911 else
1912 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301913 vos_mem_set( ( tANI_U8* )&WMMAddTSRsp, sizeof( WMMAddTSRsp ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001914
1915 WMMAddTSRsp.Category.category = SIR_MAC_ACTION_WME;
1916 WMMAddTSRsp.Action.action = SIR_MAC_QOS_ADD_TS_RSP;
1917 WMMAddTSRsp.DialogToken.token = pAddTS->dialogToken;
1918 WMMAddTSRsp.StatusCode.statusCode = (tANI_U8)nStatusCode;
1919
1920 PopulateDot11fWMMTSPEC( &pAddTS->tspec, &WMMAddTSRsp.WMMTSPEC );
1921
1922 nStatus = dot11fGetPackedWMMAddTSResponseSize( pMac, &WMMAddTSRsp, &nPayload );
1923 if ( DOT11F_FAILED( nStatus ) )
1924 {
1925 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001926 "ze for a WMM Add TS Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001927 nStatus );
1928 // We'll fall back on the worst case scenario:
1929 nPayload = sizeof( tDot11fWMMAddTSResponse );
1930 }
1931 else if ( DOT11F_WARNED( nStatus ) )
1932 {
1933 limLog( pMac, LOGW, FL("There were warnings while calcula"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001934 "ting the packed size for a WMM Add"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001935 "TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001936 }
1937 }
1938
1939 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
1940
1941 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
1942 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
1943 {
1944 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001945 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 return;
1947 }
1948
1949 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05301950 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07001951
1952 // Next, we fill out the buffer descriptor:
1953 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
1954 SIR_MAC_MGMT_ACTION, peer,psessionEntry->selfMacAddr);
1955 if ( eSIR_SUCCESS != nSirStatus )
1956 {
1957 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001958 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 nSirStatus );
1960 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1961 return; // allocated!
1962 }
1963
1964 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
1965
1966
1967 #if 0
1968 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
1969 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
1970 {
1971 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001972 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07001973 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1974 return; // allocated!
1975 }
1976 #endif //TO SUPPORT BT-AMP
1977 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
1978
Chet Lanctot186b5732013-03-18 10:26:30 -07001979#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07001980 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07001981#endif
1982
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 // That done, pack the struct:
1984 if ( ! pAddTS->wmeTspecPresent )
1985 {
1986 nStatus = dot11fPackAddTSResponse( pMac, &AddTSRsp,
1987 pFrame + sizeof( tSirMacMgmtHdr ),
1988 nPayload, &nPayload );
1989 if ( DOT11F_FAILED( nStatus ) )
1990 {
1991 limLog( pMac, LOGE, FL("Failed to pack an Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07001992 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07001993 nStatus );
1994 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
1995 return;
1996 }
1997 else if ( DOT11F_WARNED( nStatus ) )
1998 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08001999 limLog( pMac, LOGW, FL("There were warnings while packing "
2000 "an Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 }
2003 else
2004 {
2005 nStatus = dot11fPackWMMAddTSResponse( pMac, &WMMAddTSRsp,
2006 pFrame + sizeof( tSirMacMgmtHdr ),
2007 nPayload, &nPayload );
2008 if ( DOT11F_FAILED( nStatus ) )
2009 {
2010 limLog( pMac, LOGE, FL("Failed to pack a WMM Add TS Response "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002011 "(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 nStatus );
2013 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2014 return;
2015 }
2016 else if ( DOT11F_WARNED( nStatus ) )
2017 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002018 limLog( pMac, LOGW, FL("There were warnings while packing "
2019 "a WMM Add TS Response (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002020 }
2021 }
2022
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302023 limLog( pMac, LOG1, FL("Sending an Add TS Response (status %d) to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 nStatusCode );
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302025 limPrintMacAddr( pMac, pMacHdr->da, LOG1 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002026
2027 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2029 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 )
2031 {
2032 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2033 }
2034
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302035 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2036 psessionEntry->peSessionId,
2037 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 // Queue the frame in high priority WQ:
2039 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2040 HAL_TXRX_FRM_802_11_MGMT,
2041 ANI_TXDIR_TODS,
2042 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2043 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302044 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2045 psessionEntry->peSessionId,
2046 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2048 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002049 limLog( pMac, LOGE, FL("Failed to send Add TS Response (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 nSirStatus );
2051 //Pkt will be freed up by the callback
2052 }
2053
2054} // End limSendAddtsRspActionFrame.
2055
2056void
2057limSendDeltsReqActionFrame(tpAniSirGlobal pMac,
2058 tSirMacAddr peer,
2059 tANI_U8 wmmTspecPresent,
2060 tSirMacTSInfo *pTsinfo,
2061 tSirMacTspecIE *pTspecIe,
2062 tpPESession psessionEntry)
2063{
2064 tANI_U8 *pFrame;
2065 tpSirMacMgmtHdr pMacHdr;
2066 tDot11fDelTS DelTS;
2067 tDot11fWMMDelTS WMMDelTS;
2068 tSirRetStatus nSirStatus;
2069 tANI_U32 nBytes, nPayload, nStatus;
2070 void *pPacket;
2071 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302072 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002073
2074 if(NULL == psessionEntry)
2075 {
2076 return;
2077 }
2078
2079 if ( ! wmmTspecPresent )
2080 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302081 vos_mem_set( ( tANI_U8* )&DelTS, sizeof( DelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002082
2083 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
2084 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2085 PopulateDot11fTSInfo( pTsinfo, &DelTS.TSInfo );
2086
2087 nStatus = dot11fGetPackedDelTSSize( pMac, &DelTS, &nPayload );
2088 if ( DOT11F_FAILED( nStatus ) )
2089 {
2090 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002091 "ze for a Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 nStatus );
2093 // We'll fall back on the worst case scenario:
2094 nPayload = sizeof( tDot11fDelTS );
2095 }
2096 else if ( DOT11F_WARNED( nStatus ) )
2097 {
2098 limLog( pMac, LOGW, FL("There were warnings while calcula"
2099 "ting the packed size for a Del TS"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002100 " (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 }
2102 }
2103 else
2104 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302105 vos_mem_set( ( tANI_U8* )&WMMDelTS, sizeof( WMMDelTS ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002106
2107 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
2108 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
2109 WMMDelTS.DialogToken.token = 0;
2110 WMMDelTS.StatusCode.statusCode = 0;
2111 PopulateDot11fWMMTSPEC( pTspecIe, &WMMDelTS.WMMTSPEC );
2112 nStatus = dot11fGetPackedWMMDelTSSize( pMac, &WMMDelTS, &nPayload );
2113 if ( DOT11F_FAILED( nStatus ) )
2114 {
2115 limLog( pMac, LOGP, FL("Failed to calculate the packed si"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002116 "ze for a WMM Del TS (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 nStatus );
2118 // We'll fall back on the worst case scenario:
2119 nPayload = sizeof( tDot11fDelTS );
2120 }
2121 else if ( DOT11F_WARNED( nStatus ) )
2122 {
2123 limLog( pMac, LOGW, FL("There were warnings while calcula"
2124 "ting the packed size for a WMM De"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002125 "l TS (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002126 }
2127 }
2128
2129 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
2130
2131 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
2132 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2133 {
2134 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an Ad"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002135 "d TS Response."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002136 return;
2137 }
2138
2139 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302140 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002141
2142 // Next, we fill out the buffer descriptor:
2143 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2144 SIR_MAC_MGMT_ACTION, peer,
2145 psessionEntry->selfMacAddr);
2146 if ( eSIR_SUCCESS != nSirStatus )
2147 {
2148 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002149 "tor for an Add TS Response (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 nSirStatus );
2151 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2152 return; // allocated!
2153 }
2154
2155 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
2156
2157 #if 0
2158
2159 cfgLen = SIR_MAC_ADDR_LENGTH;
2160 if ( eSIR_SUCCESS != wlan_cfgGetStr( pMac, WNI_CFG_BSSID,
2161 ( tANI_U8* )pMacHdr->bssId, &cfgLen ) )
2162 {
2163 limLog( pMac, LOGP, FL("Failed to retrieve WNI_CFG_BSSID whil"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002164 "e sending an Add TS Response.") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2166 return; // allocated!
2167 }
2168 #endif //TO SUPPORT BT-AMP
2169 sirCopyMacAddr(pMacHdr->bssId, psessionEntry->bssId);
2170
Chet Lanctot186b5732013-03-18 10:26:30 -07002171#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002172 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07002173#endif
2174
Jeff Johnson295189b2012-06-20 16:38:30 -07002175 // That done, pack the struct:
2176 if ( !wmmTspecPresent )
2177 {
2178 nStatus = dot11fPackDelTS( pMac, &DelTS,
2179 pFrame + sizeof( tSirMacMgmtHdr ),
2180 nPayload, &nPayload );
2181 if ( DOT11F_FAILED( nStatus ) )
2182 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002183 limLog( pMac, LOGE, FL("Failed to pack a Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 nStatus );
2185 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2186 return; // allocated!
2187 }
2188 else if ( DOT11F_WARNED( nStatus ) )
2189 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002190 limLog( pMac, LOGW, FL("There were warnings while packing "
2191 "a Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 }
2193 }
2194 else
2195 {
2196 nStatus = dot11fPackWMMDelTS( pMac, &WMMDelTS,
2197 pFrame + sizeof( tSirMacMgmtHdr ),
2198 nPayload, &nPayload );
2199 if ( DOT11F_FAILED( nStatus ) )
2200 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002201 limLog( pMac, LOGE, FL("Failed to pack a WMM Del TS frame (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 nStatus );
2203 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
2204 return; // allocated!
2205 }
2206 else if ( DOT11F_WARNED( nStatus ) )
2207 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002208 limLog( pMac, LOGW, FL("There were warnings while packing "
2209 "a WMM Del TS frame (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 }
2211 }
2212
Abhishek Singh3cbf6052014-12-15 16:46:42 +05302213 limLog(pMac, LOG1, FL("Sending DELTS REQ (size %d) to "), nBytes);
2214 limPrintMacAddr(pMac, pMacHdr->da, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07002215
2216 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2218 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 )
2220 {
2221 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2222 }
2223
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302224 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2225 psessionEntry->peSessionId,
2226 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
2228 HAL_TXRX_FRM_802_11_MGMT,
2229 ANI_TXDIR_TODS,
2230 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2231 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302232 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2233 psessionEntry->peSessionId,
2234 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2236 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002237 limLog( pMac, LOGE, FL("Failed to send Del TS (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 nSirStatus );
2239 //Pkt will be freed up by the callback
2240 }
2241
2242} // End limSendDeltsReqActionFrame.
2243
2244void
2245limSendAssocReqMgmtFrame(tpAniSirGlobal pMac,
2246 tLimMlmAssocReq *pMlmAssocReq,
2247 tpPESession psessionEntry)
2248{
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002249 tDot11fAssocRequest *pFrm;
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 tANI_U16 caps;
2251 tANI_U8 *pFrame;
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302252 tSirRetStatus nSirStatus = eSIR_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 tLimMlmAssocCnf mlmAssocCnf;
c_hpothubcd78652014-04-28 22:31:08 +05302254 tANI_U32 nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2256 void *pPacket;
2257 eHalStatus halstatus;
2258 tANI_U16 nAddIELen;
2259 tANI_U8 *pAddIE;
2260 tANI_U8 *wpsIe = NULL;
2261#if defined WLAN_FEATURE_VOWIFI
2262 tANI_U8 PowerCapsPopulated = FALSE;
2263#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302264 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302265 tpSirMacMgmtHdr pMacHdr;
Kalikinkar dhara205da782014-03-21 15:49:32 -07002266 tDot11fIEExtCap extractedExtCap;
2267 tANI_BOOLEAN extractedExtCapFlag = eANI_BOOLEAN_TRUE;
c_hpothubcd78652014-04-28 22:31:08 +05302268 tANI_U32 nBytes = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002269
2270 if(NULL == psessionEntry)
2271 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302272 limLog(pMac, LOGE, FL("psessionEntry is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 return;
2274 }
2275
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 /* check this early to avoid unncessary operation */
2277 if(NULL == psessionEntry->pLimJoinReq)
2278 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302279 limLog(pMac, LOGE, FL("psessionEntry->pLimJoinReq is NULL") );
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 return;
2281 }
2282 nAddIELen = psessionEntry->pLimJoinReq->addIEAssoc.length;
2283 pAddIE = psessionEntry->pLimJoinReq->addIEAssoc.addIEdata;
2284
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302285 pFrm = vos_mem_malloc(sizeof(tDot11fAssocRequest));
2286 if ( NULL == pFrm )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002287 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302288 limLog(pMac, LOGE, FL("Unable to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002289 return;
2290 }
2291
2292
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302293 vos_mem_set( ( tANI_U8* )pFrm, sizeof( tDot11fAssocRequest ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
Kalikinkar dhara205da782014-03-21 15:49:32 -07002295 vos_mem_set(( tANI_U8* )&extractedExtCap, sizeof( tDot11fIEExtCap ), 0);
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302296 if (psessionEntry->is_ext_caps_present)
2297 {
2298 nSirStatus = limStripOffExtCapIEAndUpdateStruct(pMac, pAddIE,
Kalikinkar dhara205da782014-03-21 15:49:32 -07002299 &nAddIELen,
2300 &extractedExtCap );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302301 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002302 if(eSIR_SUCCESS != nSirStatus )
2303 {
2304 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2305 limLog(pMac, LOG1,
2306 FL("Unable to Stripoff ExtCap IE from Assoc Req"));
2307 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002308 /* TODO:remove this code once driver provides the call back function
2309 * to supplicant for set_qos_map
2310 */
2311 else
2312 {
2313 if(extractedExtCap.interworkingService)
2314 {
2315 extractedExtCap.qosMap = 1;
2316 }
Abhishek Singh15d95602015-03-24 15:52:57 +05302317 /* No need to merge the EXT Cap from Supplicant
2318 * if interworkingService is not set, as currently
2319 * driver is only interested in interworkingService
2320 * capability from supplicant. if in
2321 * future any other EXT Cap info is required from
2322 * supplicant it needs to be handled here.
2323 */
2324 else
2325 {
2326 extractedExtCapFlag = eANI_BOOLEAN_FALSE;
2327 }
Leela Venkata Kiran Kumar Reddy Chirala2f9b5712014-05-06 00:09:42 -07002328 }
Kalikinkar dhara205da782014-03-21 15:49:32 -07002329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 caps = pMlmAssocReq->capabilityInfo;
2331 if ( PROP_CAPABILITY_GET( 11EQOS, psessionEntry->limCurrentBssPropCap ) )
2332 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2333#if defined(FEATURE_WLAN_WAPI)
2334 /* CR: 262463 :
2335 According to WAPI standard:
2336 7.3.1.4 Capability Information field
2337 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2338 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2339 Reassociation management frames. */
2340 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2341 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2342#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002343 swapBitField16(caps, ( tANI_U16* )&pFrm->Capabilities );
Jeff Johnson295189b2012-06-20 16:38:30 -07002344
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002345 pFrm->ListenInterval.interval = pMlmAssocReq->listenInterval;
2346 PopulateDot11fSSID2( pMac, &pFrm->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002348 &pFrm->SuppRates,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002349
2350 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2351 SIR_MAC_GET_QOS( psessionEntry->limCurrentBssCaps );
2352
2353 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2354 LIM_BSS_CAPS_GET( WME, psessionEntry->limCurrentBssQosCaps );
2355
2356 // We prefer .11e asociations:
2357 if ( fQosEnabled ) fWmeEnabled = false;
2358
2359 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2360 LIM_BSS_CAPS_GET( WSM, psessionEntry->limCurrentBssQosCaps );
2361
2362 if ( psessionEntry->lim11hEnable &&
2363 psessionEntry->pLimJoinReq->spectrumMgtIndicator == eSIR_TRUE )
2364 {
2365#if defined WLAN_FEATURE_VOWIFI
2366 PowerCapsPopulated = TRUE;
2367
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002368 PopulateDot11fPowerCaps( pMac, &pFrm->PowerCaps, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369#endif
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002370 PopulateDot11fSuppChannels( pMac, &pFrm->SuppChannels, LIM_ASSOC,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
2372 }
2373
2374#if defined WLAN_FEATURE_VOWIFI
2375 if( pMac->rrm.rrmPEContext.rrmEnable &&
2376 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2377 {
2378 if (PowerCapsPopulated == FALSE)
2379 {
2380 PowerCapsPopulated = TRUE;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002381 PopulateDot11fPowerCaps(pMac, &pFrm->PowerCaps, LIM_ASSOC, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 }
2383 }
2384#endif
2385
2386 if ( fQosEnabled &&
2387 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limCurrentBssPropCap)))
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002388 PopulateDot11fQOSCapsStation( pMac, &pFrm->QOSCapsStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002389
2390 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002391 &pFrm->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002392
2393#if defined WLAN_FEATURE_VOWIFI
2394 if( pMac->rrm.rrmPEContext.rrmEnable &&
2395 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2396 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002397 PopulateDot11fRRMIe( pMac, &pFrm->RRMEnabledCap, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -07002398 }
2399#endif
2400 // The join request *should* contain zero or one of the WPA and RSN
2401 // IEs. The payload send along with the request is a
2402 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2403
2404 // typedef struct sSirRSNie
2405 // {
2406 // tANI_U16 length;
2407 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2408 // } tSirRSNie, *tpSirRSNie;
2409
2410 // So, we should be able to make the following two calls harmlessly,
2411 // since they do nothing if they don't find the given IE in the
2412 // bytestream with which they're provided.
2413
2414 // The net effect of this will be to faithfully transmit whatever
2415 // security IE is in the join request.
2416
2417 // *However*, if we're associating for the purpose of WPS
2418 // enrollment, and we've been configured to indicate that by
2419 // eliding the WPA or RSN IE, we just skip this:
2420 if( nAddIELen && pAddIE )
2421 {
2422 wpsIe = limGetWscIEPtr (pMac, pAddIE, nAddIELen);
2423 }
2424 if ( NULL == wpsIe )
2425 {
2426 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002427 &pFrm->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002429 &pFrm->WPAOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002430#if defined(FEATURE_WLAN_WAPI)
2431 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimJoinReq->rsnIE ),
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002432 &pFrm->WAPIOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002433#endif // defined(FEATURE_WLAN_WAPI)
2434 }
2435
2436 // include WME EDCA IE as well
2437 if ( fWmeEnabled )
2438 {
2439 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limCurrentBssPropCap ) )
2440 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002441 PopulateDot11fWMMInfoStation( pMac, &pFrm->WMMInfoStation );
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 }
2443
2444 if ( fWsmEnabled &&
2445 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limCurrentBssPropCap )))
2446 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002447 PopulateDot11fWMMCaps( &pFrm->WMMCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 }
2449 }
2450
2451 //Populate HT IEs, when operating in 11n or Taurus modes AND
2452 //when AP is also operating in 11n mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002453 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 pMac->lim.htCapabilityPresentInBeacon)
2455 {
Krishna Kumaar Natarajan025a8602015-08-04 16:31:36 +05302456 limLog(pMac, LOG1, FL("Populate HT IEs in Assoc Request"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002457 PopulateDot11fHTCaps( pMac, psessionEntry, &pFrm->HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002458#ifdef DISABLE_GF_FOR_INTEROP
2459
2460 /*
2461 * To resolve the interop problem with Broadcom AP,
2462 * where TQ STA could not pass traffic with GF enabled,
2463 * TQ STA will do Greenfield only with TQ AP, for
2464 * everybody else it will be turned off.
2465 */
2466
2467 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2468 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302469 limLog( pMac, LOG1, FL("Sending Assoc Req to Non-TQ AP,"
2470 " Turning off Greenfield"));
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002471 pFrm->HTCaps.greenField = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 }
2473#endif
2474
2475 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302476
2477 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2478 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2479 pFrm->HTCaps.supportedChannelWidthSet, pFrm->HTCaps.mimoPowerSave,
2480 pFrm->HTCaps.greenField, pFrm->HTCaps.shortGI20MHz, pFrm->HTCaps.shortGI40MHz,
2481 pFrm->HTCaps.dsssCckMode40MHz, pFrm->HTCaps.maxRxAMPDUFactor);
2482
2483
Jeff Johnsone7245742012-09-05 17:12:55 -07002484#ifdef WLAN_FEATURE_11AC
2485 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002486 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07002487 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002488 limLog( pMac, LOG1, FL("Populate VHT IEs in Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302489 PopulateDot11fVHTCaps( pMac, &pFrm->VHTCaps,
2490 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302491
Jeff Johnsone7245742012-09-05 17:12:55 -07002492 }
2493#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302494 if (psessionEntry->is_ext_caps_present)
2495 PopulateDot11fExtCap( pMac, &pFrm->ExtCap, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002496
2497#if defined WLAN_FEATURE_VOWIFI_11R
2498 if (psessionEntry->pLimJoinReq->is11Rconnection)
2499 {
2500#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002501 limLog( pMac, LOG1, FL("mdie = %02x %02x %02x"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[0],
2503 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[1],
2504 (unsigned int)psessionEntry->pLimJoinReq->bssDescription.mdie[2]);
2505#endif
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302506 PopulateMDIE( pMac, &pFrm->MobilityDomain,
2507 psessionEntry->pLimJoinReq->bssDescription.mdie);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302509 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002510 {
2511 // No 11r IEs dont send any MDIE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302512 limLog( pMac, LOG1, FL("MDIE not present"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 }
2514#endif
2515
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002516#ifdef FEATURE_WLAN_ESE
2517 /* For ESE Associations fill the ESE IEs */
2518 if (psessionEntry->isESEconnection &&
2519 psessionEntry->pLimJoinReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002521#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002522 PopulateDot11fESERadMgmtCap(&pFrm->ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002523#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002524 PopulateDot11fESEVersion(&pFrm->ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 }
2526#endif
2527
c_hpothubcd78652014-04-28 22:31:08 +05302528 /* merge the ExtCap struct*/
2529 if (extractedExtCapFlag && extractedExtCap.present)
2530 {
2531 limMergeExtCapIEStruct(&pFrm->ExtCap, &extractedExtCap);
2532 }
2533
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002534 nStatus = dot11fGetPackedAssocRequestSize( pMac, pFrm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 if ( DOT11F_FAILED( nStatus ) )
2536 {
2537 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002538 "or an Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002539 nStatus );
2540 // We'll fall back on the worst case scenario:
2541 nPayload = sizeof( tDot11fAssocRequest );
2542 }
2543 else if ( DOT11F_WARNED( nStatus ) )
2544 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002545 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 "the packed size for an Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002547 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 }
2549
2550 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
2551
2552 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2553 ( tANI_U16 )nBytes, ( void** ) &pFrame,
2554 ( void** ) &pPacket );
2555 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2556 {
2557 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for an As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002558 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07002559
2560 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002561 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07002562
2563
2564 /* Update PE session id*/
2565 mlmAssocCnf.sessionId = psessionEntry->peSessionId;
2566
2567 mlmAssocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2568
2569 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2570 ( void* ) pFrame, ( void* ) pPacket );
2571
2572 limPostSmeMessage( pMac, LIM_MLM_ASSOC_CNF,
2573 ( tANI_U32* ) &mlmAssocCnf);
2574
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302575 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 return;
2577 }
2578
2579 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302580 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002581
2582 // Next, we fill out the buffer descriptor:
2583 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
2584 SIR_MAC_MGMT_ASSOC_REQ, psessionEntry->bssId,psessionEntry->selfMacAddr);
2585 if ( eSIR_SUCCESS != nSirStatus )
2586 {
2587 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002588 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 nSirStatus );
2590 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302591 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 return;
2593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002594
Abhishek Singh57aebef2014-02-03 18:47:44 +05302595 // That done, pack the Assoc Request:
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002596 nStatus = dot11fPackAssocRequest( pMac, pFrm, pFrame +
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 sizeof(tSirMacMgmtHdr),
2598 nPayload, &nPayload );
2599 if ( DOT11F_FAILED( nStatus ) )
2600 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302601 limLog( pMac, LOGE, FL("Failed to pack a Assoc Request (0x%0"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002602 "8x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 nStatus );
2604 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
2605 ( void* ) pFrame, ( void* ) pPacket );
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302606 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 return;
2608 }
2609 else if ( DOT11F_WARNED( nStatus ) )
2610 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302611 limLog( pMac, LOGW, FL("There were warnings while packing a Assoc"
2612 "Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 }
2614
2615 PELOG1(limLog( pMac, LOG1, FL("*** Sending Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002616 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 nBytes );)
2618 // limPrintMacAddr( pMac, bssid, LOG1 );
2619
2620 if( psessionEntry->assocReq != NULL )
2621 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302622 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 psessionEntry->assocReq = NULL;
2624 }
2625
2626 if( nAddIELen )
2627 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302628 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
2629 pAddIE,
2630 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 nPayload += nAddIELen;
2632 }
2633
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302634 psessionEntry->assocReq = vos_mem_malloc(nPayload);
2635 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05302637 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store "
2638 "assoc request"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 }
2640 else
2641 {
2642 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302643 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 psessionEntry->assocReqLen = nPayload;
2645 }
2646
2647 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
2649 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 )
2651 {
2652 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2653 }
2654
Sushant Kaushike8681d22015-04-21 12:08:25 +05302655 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
2656 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08002657 {
2658 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2659 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05302660#ifdef FEATURE_WLAN_DIAG_SUPPORT
2661 limDiagEventReport(pMac, WLAN_PE_DIAG_ASSOC_START_EVENT, psessionEntry,
2662 eSIR_SUCCESS, eSIR_SUCCESS);
2663#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302664 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05302665 limLog( pMac, LOG1, FL("Sending Assoc req over WQ5 to "MAC_ADDRESS_STR
2666 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
2667 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2668 txFlag |= HAL_USE_FW_IN_TX_PATH;
2669
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302670 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
2671 psessionEntry->peSessionId,
2672 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05302673
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05302674 if( ( psessionEntry->is11Gonly == true ) &&
2675 ( !IS_BROADCAST_MAC(pMlmAssocReq->peerMacAddr) ) ){
2676 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2677 }
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05302678 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
2679 {
2680 limLog(pMac, LOG1, FL("Assoc Req - txBdToken %u"), pMac->lim.txBdToken);
2681 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
2682 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2683 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2684 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2685 limTxComplete, pFrame, limTxBdComplete, txFlag,
2686 pMac->lim.txBdToken);
2687 pMac->lim.txBdToken++;
2688 }
2689 else
2690 {
2691 halstatus = halTxFrame( pMac, pPacket,
2692 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
2693 HAL_TXRX_FRM_802_11_MGMT,
2694 ANI_TXDIR_TODS,
2695 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
2696 limTxComplete, pFrame, txFlag );
2697 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302698 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
2699 psessionEntry->peSessionId,
2700 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
2702 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002703 limLog( pMac, LOGE, FL("Failed to send Association Request (%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 halstatus );
2705 //Pkt will be freed up by the callback
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302706 vos_mem_free(pFrm);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 return;
2708 }
2709
Katya Nigamccaeda72015-04-20 18:51:22 +05302710 //Enable caching only if Assoc Request is successfully submitted to the h/w
2711 WLANTL_EnableCaching(psessionEntry->staId);
2712
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302714 vos_mem_free(pMlmAssocReq);
Leela Venkata Kiran Kumar Reddy Chiralad6c0fe22013-12-11 19:10:50 -08002715 pMlmAssocReq = NULL;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302716 vos_mem_free(pFrm);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -07002717 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002718} // End limSendAssocReqMgmtFrame
2719
2720
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002721#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002722/*------------------------------------------------------------------------------------
2723 *
2724 * Send Reassoc Req with FTIEs.
2725 *
2726 *-----------------------------------------------------------------------------------
2727 */
2728void
2729limSendReassocReqWithFTIEsMgmtFrame(tpAniSirGlobal pMac,
2730 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
2731{
2732 static tDot11fReAssocRequest frm;
2733 tANI_U16 caps;
2734 tANI_U8 *pFrame;
2735 tSirRetStatus nSirStatus;
2736 tANI_U32 nBytes, nPayload, nStatus;
2737 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
2738 void *pPacket;
2739 eHalStatus halstatus;
2740#if defined WLAN_FEATURE_VOWIFI
2741 tANI_U8 PowerCapsPopulated = FALSE;
2742#endif
2743 tANI_U16 ft_ies_length = 0;
2744 tANI_U8 *pBody;
2745 tANI_U16 nAddIELen;
2746 tANI_U8 *pAddIE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002747#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 tANI_U8 *wpsIe = NULL;
2749#endif
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05302750 tANI_U32 txFlag = 0;
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05302751 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
2753 if (NULL == psessionEntry)
2754 {
2755 return;
2756 }
2757
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 /* check this early to avoid unncessary operation */
2759 if(NULL == psessionEntry->pLimReAssocReq)
2760 {
2761 return;
2762 }
2763 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
2764 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08002765 limLog( pMac, LOG1, FL("limSendReassocReqWithFTIEsMgmtFrame received in "
2766 "state (%d)."), psessionEntry->limMlmState);
Jeff Johnson295189b2012-06-20 16:38:30 -07002767
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302768 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07002769
2770 caps = pMlmReassocReq->capabilityInfo;
2771 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
2772 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
2773#if defined(FEATURE_WLAN_WAPI)
2774 /* CR: 262463 :
2775 According to WAPI standard:
2776 7.3.1.4 Capability Information field
2777 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
2778 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
2779 Reassociation management frames. */
2780 if ( psessionEntry->encryptType == eSIR_ED_WPI)
2781 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
2782#endif
2783 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
2784
2785 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
2786
2787 // Get the old bssid of the older AP.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05302788 vos_mem_copy( ( tANI_U8* )frm.CurrentAPAddress.mac,
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 pMac->ft.ftPEContext.pFTPreAuthReq->currbssId, 6);
2790
2791 PopulateDot11fSSID2( pMac, &frm.SSID );
2792 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2793 &frm.SuppRates,psessionEntry);
2794
2795 fQosEnabled = ( psessionEntry->limQosEnabled) &&
2796 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
2797
2798 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
2799 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
2800
2801 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
2802 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
2803
2804 if ( psessionEntry->lim11hEnable &&
2805 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
2806 {
2807#if defined WLAN_FEATURE_VOWIFI
2808 PowerCapsPopulated = TRUE;
2809
2810 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
2811 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
2812#endif
2813 }
2814
2815#if defined WLAN_FEATURE_VOWIFI
2816 if( pMac->rrm.rrmPEContext.rrmEnable &&
2817 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
2818 {
2819 if (PowerCapsPopulated == FALSE)
2820 {
2821 PowerCapsPopulated = TRUE;
2822 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
2823 }
2824 }
2825#endif
2826
2827 if ( fQosEnabled &&
2828 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
2829 {
2830 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
2831 }
2832
2833 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
2834 &frm.ExtSuppRates, psessionEntry );
2835
2836#if defined WLAN_FEATURE_VOWIFI
2837 if( pMac->rrm.rrmPEContext.rrmEnable &&
2838 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
2839 {
2840 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
2841 }
2842#endif
2843
2844 // Ideally this should be enabled for 11r also. But 11r does
2845 // not follow the usual norm of using the Opaque object
2846 // for rsnie and fties. Instead we just add
2847 // the rsnie and fties at the end of the pack routine for 11r.
2848 // This should ideally! be fixed.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002849#if defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 //
2851 // The join request *should* contain zero or one of the WPA and RSN
2852 // IEs. The payload send along with the request is a
2853 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
2854
2855 // typedef struct sSirRSNie
2856 // {
2857 // tANI_U16 length;
2858 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
2859 // } tSirRSNie, *tpSirRSNie;
2860
2861 // So, we should be able to make the following two calls harmlessly,
2862 // since they do nothing if they don't find the given IE in the
2863 // bytestream with which they're provided.
2864
2865 // The net effect of this will be to faithfully transmit whatever
2866 // security IE is in the join request.
2867
2868 // *However*, if we're associating for the purpose of WPS
2869 // enrollment, and we've been configured to indicate that by
2870 // eliding the WPA or RSN IE, we just skip this:
2871 if (!psessionEntry->is11Rconnection)
2872 {
2873 if( nAddIELen && pAddIE )
2874 {
2875 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
2876 }
2877 if ( NULL == wpsIe )
2878 {
2879 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2880 &frm.RSNOpaque );
2881 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
2882 &frm.WPAOpaque );
2883 }
2884
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002885#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302886 if (psessionEntry->pLimReAssocReq->cckmIE.length)
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002888 PopulateDot11fESECckmOpaque( pMac, &( psessionEntry->pLimReAssocReq->cckmIE ),
2889 &frm.ESECckmOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002891#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 }
2893
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002894#ifdef FEATURE_WLAN_ESE
2895 // For ESE Associations fill the ESE IEs
2896 if (psessionEntry->isESEconnection &&
2897 psessionEntry->pLimReAssocReq->isESEFeatureIniEnabled)
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 {
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002899#ifndef FEATURE_DISABLE_RM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002900 PopulateDot11fESERadMgmtCap(&frm.ESERadMgmtCap);
Varun Reddy Yeturu30779b42013-04-09 09:57:16 -07002901#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002902 PopulateDot11fESEVersion(&frm.ESEVersion);
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002904#endif //FEATURE_WLAN_ESE
2905#endif //FEATURE_WLAN_ESE || FEATURE_WLAN_LFR
Jeff Johnson295189b2012-06-20 16:38:30 -07002906
2907 // include WME EDCA IE as well
2908 if ( fWmeEnabled )
2909 {
2910 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
2911 {
2912 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
2913 }
2914
2915 if ( fWsmEnabled &&
2916 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
2917 {
2918 PopulateDot11fWMMCaps( &frm.WMMCaps );
2919 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002920#ifdef FEATURE_WLAN_ESE
2921 if (psessionEntry->isESEconnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 {
2923 PopulateDot11fReAssocTspec(pMac, &frm, psessionEntry);
2924
2925 // Populate the TSRS IE if TSPEC is included in the reassoc request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002926 if (psessionEntry->pLimReAssocReq->eseTspecInfo.numTspecs)
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 {
2928 tANI_U32 phyMode;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002929 tSirMacESETSRSIE tsrsIE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 limGetPhyMode(pMac, &phyMode, psessionEntry);
2931
2932 tsrsIE.tsid = 0;
2933 if( phyMode == WNI_CFG_PHY_MODE_11G || phyMode == WNI_CFG_PHY_MODE_11A)
2934 {
2935 tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
2936 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302937 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 {
2939 tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
2940 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002941 PopulateDot11TSRSIE(pMac,&tsrsIE, &frm.ESETrafStrmRateSet, sizeof(tANI_U8));
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 }
2943 }
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05302944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 }
2946
Jeff Johnsone7245742012-09-05 17:12:55 -07002947 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 pMac->lim.htCapabilityPresentInBeacon)
2949 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002950 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05302952 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
2953 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
2954 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
2955 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
2956 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002957#if defined WLAN_FEATURE_VOWIFI_11R
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +05302958 if ( psessionEntry->pLimReAssocReq->bssDescription.mdiePresent &&
2959 (pMac->ft.ftSmeContext.addMDIE == TRUE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002960#if defined FEATURE_WLAN_ESE
2961 && !psessionEntry->isESEconnection
Gopichand Nakkala0ac55062013-04-08 14:43:07 +05302962#endif
2963 )
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08002964 {
2965 PopulateMDIE( pMac, &frm.MobilityDomain, psessionEntry->pLimReAssocReq->bssDescription.mdie);
2966 }
2967#endif
2968
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002969#ifdef WLAN_FEATURE_11AC
2970 if ( psessionEntry->vhtCapability &&
2971 psessionEntry->vhtCapabilityPresentInBeacon)
2972 {
2973 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05302974 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
2975 psessionEntry->currentOperChannel, eSIR_FALSE );
Abhishek Singhe038dc62015-05-22 11:36:45 +05302976
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002977 }
2978#endif
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05302979 if (psessionEntry->is_ext_caps_present)
2980 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Chet Lanctotf19c1f62013-12-13 13:56:21 -08002981
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
2983 if ( DOT11F_FAILED( nStatus ) )
2984 {
2985 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002986 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07002987 nStatus );
2988 // We'll fall back on the worst case scenario:
2989 nPayload = sizeof( tDot11fReAssocRequest );
2990 }
2991 else if ( DOT11F_WARNED( nStatus ) )
2992 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08002993 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07002995 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 }
2997
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07002998 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002999
3000#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003001 limLog( pMac, LOG1, FL("FT IE Reassoc Req (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003002 pMac->ft.ftSmeContext.reassoc_ft_ies_length);
3003#endif
3004
3005#if defined WLAN_FEATURE_VOWIFI_11R
3006 if (psessionEntry->is11Rconnection)
3007 {
3008 ft_ies_length = pMac->ft.ftSmeContext.reassoc_ft_ies_length;
3009 }
3010#endif
3011
3012 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3013 ( tANI_U16 )nBytes+ft_ies_length, ( void** ) &pFrame,
3014 ( void** ) &pPacket );
3015 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3016 {
3017 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003018 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003019 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003020 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 goto end;
3022 }
3023
3024 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303025 vos_mem_set( pFrame, nBytes + ft_ies_length, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003026
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003027#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08003028 limPrintMacAddr(pMac, psessionEntry->limReAssocbssId, LOG1);
Jeff Johnson295189b2012-06-20 16:38:30 -07003029#endif
3030 // Next, we fill out the buffer descriptor:
3031 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3032 SIR_MAC_MGMT_REASSOC_REQ,
3033 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3034 if ( eSIR_SUCCESS != nSirStatus )
3035 {
3036 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003037 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 nSirStatus );
3039 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3040 goto end;
3041 }
3042
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303043 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 // That done, pack the ReAssoc Request:
3045 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3046 sizeof(tSirMacMgmtHdr),
3047 nPayload, &nPayload );
3048 if ( DOT11F_FAILED( nStatus ) )
3049 {
3050 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003051 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 nStatus );
3053 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3054 goto end;
3055 }
3056 else if ( DOT11F_WARNED( nStatus ) )
3057 {
3058 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003059 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 }
3061
3062 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003063 FL("*** Sending Re-Association Request length %d %d to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 nBytes, nPayload );)
3065 if( psessionEntry->assocReq != NULL )
3066 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303067 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 psessionEntry->assocReq = NULL;
3069 }
3070
3071 if( nAddIELen )
3072 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303073 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3074 pAddIE,
3075 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 nPayload += nAddIELen;
3077 }
3078
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303079 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3080 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 {
3082 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003083 }
3084 else
3085 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303087 vos_mem_copy( psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003090
3091 if (psessionEntry->is11Rconnection)
3092 {
3093 {
3094 int i = 0;
3095
3096 pBody = pFrame + nBytes;
3097 for (i=0; i<ft_ies_length; i++)
3098 {
3099 *pBody = pMac->ft.ftSmeContext.reassoc_ft_ies[i];
3100 pBody++;
3101 }
3102 }
3103 }
3104
3105#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003106 PELOGE(limLog(pMac, LOG1, FL("Re-assoc Req Frame is: "));
3107 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 (tANI_U8 *)pFrame,
3109 (nBytes + ft_ies_length));)
3110#endif
3111
3112
3113 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3115 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003116 )
3117 {
3118 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3119 }
3120
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003121 if( NULL != psessionEntry->assocReq )
3122 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303123 vos_mem_free(psessionEntry->assocReq);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003124 psessionEntry->assocReq = NULL;
3125 }
3126
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303127 psessionEntry->assocReq = vos_mem_malloc(ft_ies_length);
3128 if ( NULL == psessionEntry->assocReq )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003129 {
3130 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003131 psessionEntry->assocReqLen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003132 }
3133 else
3134 {
3135 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303136 vos_mem_copy( psessionEntry->assocReq, pMac->ft.ftSmeContext.reassoc_ft_ies,
3137 (ft_ies_length));
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003138 psessionEntry->assocReqLen = (ft_ies_length);
3139 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303140#ifdef FEATURE_WLAN_DIAG_SUPPORT
3141 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3142 eSIR_SUCCESS, eSIR_SUCCESS);
3143#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303144 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3145 psessionEntry->peSessionId,
3146 pMacHdr->fc.subType));
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303147 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3148 {
3149 limLog( pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3150 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3151 ( tANI_U16 ) (nBytes + ft_ies_length),
3152 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3153 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3154 limTxComplete, pFrame, limTxBdComplete, txFlag,
3155 pMac->lim.txBdToken);
3156 pMac->lim.txBdToken++;
3157 }
3158 else
3159 {
3160 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (nBytes + ft_ies_length),
3161 HAL_TXRX_FRM_802_11_MGMT,
3162 ANI_TXDIR_TODS,
3163 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3164 limTxComplete, pFrame, txFlag );
3165 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303166 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3167 psessionEntry->peSessionId,
3168 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3170 {
3171 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003172 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 nSirStatus );
3174 //Pkt will be freed up by the callback
3175 goto end;
3176 }
3177
Katya Nigamccaeda72015-04-20 18:51:22 +05303178 // Enable TL cahching in case of roaming
3179 WLANTL_EnableCaching(psessionEntry->staId);
3180
Jeff Johnson295189b2012-06-20 16:38:30 -07003181end:
3182 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303183 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 psessionEntry->pLimMlmReassocReq = NULL;
3185
3186}
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003187
3188void limSendRetryReassocReqFrame(tpAniSirGlobal pMac,
3189 tLimMlmReassocReq *pMlmReassocReq,
3190 tpPESession psessionEntry)
3191{
3192 tLimMlmReassocCnf mlmReassocCnf; // keep sme
3193 tLimMlmReassocReq *pTmpMlmReassocReq = NULL;
Sachin Ahuja07a43012015-01-30 17:04:38 +05303194#ifdef FEATURE_WLAN_ESE
3195 tANI_U32 val=0;
3196#endif
3197 if (pMlmReassocReq == NULL)
3198 {
3199 limLog(pMac, LOGE,
3200 FL("Invalid pMlmReassocReq"));
3201 goto end;
3202 }
Hema Aparna Medicharla43d0f7b2015-02-12 17:07:59 +05303203
3204 pTmpMlmReassocReq = vos_mem_malloc(sizeof(tLimMlmReassocReq));
3205 if ( NULL == pTmpMlmReassocReq ) goto end;
3206 vos_mem_set( pTmpMlmReassocReq, sizeof(tLimMlmReassocReq), 0);
3207 vos_mem_copy( pTmpMlmReassocReq, pMlmReassocReq, sizeof(tLimMlmReassocReq));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003208
3209 // Prepare and send Reassociation request frame
3210 // start reassoc timer.
Sachin Ahuja07a43012015-01-30 17:04:38 +05303211#ifdef FEATURE_WLAN_ESE
3212 /*
3213 * In case of Ese Reassociation, change the reassoc timer
3214 * value.
3215 */
3216 val = pMlmReassocReq->reassocFailureTimeout;
3217 if (psessionEntry->isESEconnection)
3218 {
3219 val = val/LIM_MAX_REASSOC_RETRY_LIMIT;
3220 }
3221 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer) !=
3222 TX_SUCCESS)
3223 {
3224 limLog(pMac, LOGP,
3225 FL("unable to deactivate Reassoc failure timer"));
3226 }
3227 val = SYS_MS_TO_TICKS(val);
3228 if (tx_timer_change(&pMac->lim.limTimers.gLimReassocFailureTimer,
3229 val, 0) != TX_SUCCESS)
3230 {
3231 limLog(pMac, LOGP,
3232 FL("unable to change Reassociation failure timer"));
3233 }
3234#endif
3235
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003236 pMac->lim.limTimers.gLimReassocFailureTimer.sessionId = psessionEntry->peSessionId;
3237 // Start reassociation failure timer
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08003238 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_REASSOC_FAIL_TIMER));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003239 if (tx_timer_activate(&pMac->lim.limTimers.gLimReassocFailureTimer)
3240 != TX_SUCCESS)
3241 {
3242 // Could not start reassoc failure timer.
3243 // Log error
3244 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003245 FL("could not start Reassociation failure timer"));
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003246 // Return Reassoc confirm with
3247 // Resources Unavailable
3248 mlmReassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
3249 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3250 goto end;
3251 }
3252
3253 limSendReassocReqWithFTIEsMgmtFrame(pMac, pTmpMlmReassocReq, psessionEntry);
3254 return;
3255
3256end:
3257 // Free up buffer allocated for reassocReq
3258 if (pMlmReassocReq != NULL)
3259 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303260 vos_mem_free(pMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003261 pMlmReassocReq = NULL;
3262 }
3263 if (pTmpMlmReassocReq != NULL)
3264 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303265 vos_mem_free(pTmpMlmReassocReq);
Madan Mohan Koyyalamudi61bc5662012-11-02 14:33:10 -07003266 pTmpMlmReassocReq = NULL;
3267 }
3268 mlmReassocCnf.resultCode = eSIR_SME_FT_REASSOC_FAILURE;
3269 mlmReassocCnf.protStatusCode = eSIR_MAC_UNSPEC_FAILURE_STATUS;
3270 /* Update PE sessio Id*/
3271 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
3272
3273 limPostSmeMessage(pMac, LIM_MLM_REASSOC_CNF, (tANI_U32 *) &mlmReassocCnf);
3274}
3275
Jeff Johnson295189b2012-06-20 16:38:30 -07003276#endif /* WLAN_FEATURE_VOWIFI_11R */
3277
3278
3279void
3280limSendReassocReqMgmtFrame(tpAniSirGlobal pMac,
3281 tLimMlmReassocReq *pMlmReassocReq,tpPESession psessionEntry)
3282{
3283 static tDot11fReAssocRequest frm;
3284 tANI_U16 caps;
3285 tANI_U8 *pFrame;
3286 tSirRetStatus nSirStatus;
3287 tANI_U32 nBytes, nPayload, nStatus;
3288 tANI_U8 fQosEnabled, fWmeEnabled, fWsmEnabled;
3289 void *pPacket;
3290 eHalStatus halstatus;
3291 tANI_U16 nAddIELen;
3292 tANI_U8 *pAddIE;
3293 tANI_U8 *wpsIe = NULL;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303294 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003295#if defined WLAN_FEATURE_VOWIFI
3296 tANI_U8 PowerCapsPopulated = FALSE;
3297#endif
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303298 tpSirMacMgmtHdr pMacHdr;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299
3300 if(NULL == psessionEntry)
3301 {
3302 return;
3303 }
3304
3305 /* check this early to avoid unncessary operation */
3306 if(NULL == psessionEntry->pLimReAssocReq)
3307 {
3308 return;
3309 }
3310 nAddIELen = psessionEntry->pLimReAssocReq->addIEAssoc.length;
3311 pAddIE = psessionEntry->pLimReAssocReq->addIEAssoc.addIEdata;
3312
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303313 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003314
3315 caps = pMlmReassocReq->capabilityInfo;
3316 if (PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap))
3317 ((tSirMacCapabilityInfo *) &caps)->qos = 0;
3318#if defined(FEATURE_WLAN_WAPI)
3319 /* CR: 262463 :
3320 According to WAPI standard:
3321 7.3.1.4 Capability Information field
3322 In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0 in transmitted
3323 Association or Reassociation management frames. APs ignore the Privacy subfield within received Association and
3324 Reassociation management frames. */
3325 if ( psessionEntry->encryptType == eSIR_ED_WPI)
3326 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
3327#endif
3328 swapBitField16(caps, ( tANI_U16* )&frm.Capabilities );
3329
3330 frm.ListenInterval.interval = pMlmReassocReq->listenInterval;
3331
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303332 vos_mem_copy(( tANI_U8* )frm.CurrentAPAddress.mac,
3333 ( tANI_U8* )psessionEntry->bssId, 6 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
3335 PopulateDot11fSSID2( pMac, &frm.SSID );
3336 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3337 &frm.SuppRates,psessionEntry);
3338
3339 fQosEnabled = ( psessionEntry->limQosEnabled ) &&
3340 SIR_MAC_GET_QOS( psessionEntry->limReassocBssCaps );
3341
3342 fWmeEnabled = ( psessionEntry->limWmeEnabled ) &&
3343 LIM_BSS_CAPS_GET( WME, psessionEntry->limReassocBssQosCaps );
3344
3345 fWsmEnabled = ( psessionEntry->limWsmEnabled ) && fWmeEnabled &&
3346 LIM_BSS_CAPS_GET( WSM, psessionEntry->limReassocBssQosCaps );
3347
3348
3349 if ( psessionEntry->lim11hEnable &&
3350 psessionEntry->pLimReAssocReq->spectrumMgtIndicator == eSIR_TRUE )
3351 {
3352#if defined WLAN_FEATURE_VOWIFI
3353 PowerCapsPopulated = TRUE;
3354 PopulateDot11fPowerCaps( pMac, &frm.PowerCaps, LIM_REASSOC,psessionEntry);
3355 PopulateDot11fSuppChannels( pMac, &frm.SuppChannels, LIM_REASSOC,psessionEntry);
3356#endif
3357 }
3358
3359#if defined WLAN_FEATURE_VOWIFI
3360 if( pMac->rrm.rrmPEContext.rrmEnable &&
3361 SIR_MAC_GET_RRM( psessionEntry->limCurrentBssCaps ) )
3362 {
3363 if (PowerCapsPopulated == FALSE)
3364 {
3365 PowerCapsPopulated = TRUE;
3366 PopulateDot11fPowerCaps(pMac, &frm.PowerCaps, LIM_REASSOC, psessionEntry);
3367 }
3368 }
3369#endif
3370
3371 if ( fQosEnabled &&
3372 ( ! PROP_CAPABILITY_GET(11EQOS, psessionEntry->limReassocBssPropCap ) ))
3373 {
3374 PopulateDot11fQOSCapsStation( pMac, &frm.QOSCapsStation );
3375 }
3376
3377 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
3378 &frm.ExtSuppRates, psessionEntry );
3379
3380#if defined WLAN_FEATURE_VOWIFI
3381 if( pMac->rrm.rrmPEContext.rrmEnable &&
3382 SIR_MAC_GET_RRM( psessionEntry->limReassocBssCaps ) )
3383 {
3384 PopulateDot11fRRMIe( pMac, &frm.RRMEnabledCap, psessionEntry );
3385 }
3386#endif
3387 // The join request *should* contain zero or one of the WPA and RSN
3388 // IEs. The payload send along with the request is a
3389 // 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
3390
3391 // typedef struct sSirRSNie
3392 // {
3393 // tANI_U16 length;
3394 // tANI_U8 rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
3395 // } tSirRSNie, *tpSirRSNie;
3396
3397 // So, we should be able to make the following two calls harmlessly,
3398 // since they do nothing if they don't find the given IE in the
3399 // bytestream with which they're provided.
3400
3401 // The net effect of this will be to faithfully transmit whatever
3402 // security IE is in the join request.
3403
3404 // *However*, if we're associating for the purpose of WPS
3405 // enrollment, and we've been configured to indicate that by
3406 // eliding the WPA or RSN IE, we just skip this:
3407 if( nAddIELen && pAddIE )
3408 {
3409 wpsIe = limGetWscIEPtr(pMac, pAddIE, nAddIELen);
3410 }
3411 if ( NULL == wpsIe )
3412 {
3413 PopulateDot11fRSNOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3414 &frm.RSNOpaque );
3415 PopulateDot11fWPAOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3416 &frm.WPAOpaque );
3417#if defined(FEATURE_WLAN_WAPI)
3418 PopulateDot11fWAPIOpaque( pMac, &( psessionEntry->pLimReAssocReq->rsnIE ),
3419 &frm.WAPIOpaque );
3420#endif // defined(FEATURE_WLAN_WAPI)
3421 }
3422
3423 // include WME EDCA IE as well
3424 if ( fWmeEnabled )
3425 {
3426 if ( ! PROP_CAPABILITY_GET( WME, psessionEntry->limReassocBssPropCap ) )
3427 {
3428 PopulateDot11fWMMInfoStation( pMac, &frm.WMMInfoStation );
3429 }
3430
3431 if ( fWsmEnabled &&
3432 ( ! PROP_CAPABILITY_GET(WSM, psessionEntry->limReassocBssPropCap )))
3433 {
3434 PopulateDot11fWMMCaps( &frm.WMMCaps );
3435 }
3436 }
3437
Jeff Johnsone7245742012-09-05 17:12:55 -07003438 if ( psessionEntry->htCapability &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 pMac->lim.htCapabilityPresentInBeacon)
3440 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003441 PopulateDot11fHTCaps( pMac, psessionEntry, &frm.HTCaps );
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 }
Agrawal Ashishb10d0392015-08-06 16:18:20 +05303443 limLog(pMac, LOG1, FL("SupportedChnlWidth: %d, mimoPS: %d, GF: %d,"
3444 "shortGI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x"),
3445 frm.HTCaps.supportedChannelWidthSet, frm.HTCaps.mimoPowerSave,
3446 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz, frm.HTCaps.shortGI40MHz,
3447 frm.HTCaps.dsssCckMode40MHz, frm.HTCaps.maxRxAMPDUFactor);
Jeff Johnsone7245742012-09-05 17:12:55 -07003448#ifdef WLAN_FEATURE_11AC
3449 if ( psessionEntry->vhtCapability &&
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003450 psessionEntry->vhtCapabilityPresentInBeacon)
Jeff Johnsone7245742012-09-05 17:12:55 -07003451 {
Chet Lanctotf19c1f62013-12-13 13:56:21 -08003452 limLog( pMac, LOG1, FL("Populate VHT IEs in Re-Assoc Request"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +05303453 PopulateDot11fVHTCaps( pMac, &frm.VHTCaps,
3454 psessionEntry->currentOperChannel, eSIR_FALSE );
Agrawal Ashish5ac89da2015-10-26 19:08:47 +05303455 if (psessionEntry->is_ext_caps_present)
3456 PopulateDot11fExtCap( pMac, &frm.ExtCap, psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003457 }
3458#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003459
3460 nStatus = dot11fGetPackedReAssocRequestSize( pMac, &frm, &nPayload );
3461 if ( DOT11F_FAILED( nStatus ) )
3462 {
3463 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003464 "or a Re-Association Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 nStatus );
3466 // We'll fall back on the worst case scenario:
3467 nPayload = sizeof( tDot11fReAssocRequest );
3468 }
3469 else if ( DOT11F_WARNED( nStatus ) )
3470 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003471 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 "the packed size for a Re-Association Re "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003473 "quest(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 }
3475
3476 nBytes = nPayload + sizeof( tSirMacMgmtHdr ) + nAddIELen;
3477
3478 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
3479 ( tANI_U16 )nBytes, ( void** ) &pFrame,
3480 ( void** ) &pPacket );
3481 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3482 {
3483 psessionEntry->limMlmState = psessionEntry->limPrevMlmState;
Jeff Johnsone7245742012-09-05 17:12:55 -07003484 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Re-As"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003486 "sociation Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 goto end;
3488 }
3489
3490 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303491 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07003492
3493 // Next, we fill out the buffer descriptor:
3494 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
3495 SIR_MAC_MGMT_REASSOC_REQ,
3496 psessionEntry->limReAssocbssId,psessionEntry->selfMacAddr);
3497 if ( eSIR_SUCCESS != nSirStatus )
3498 {
3499 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003500 "tor for an Association Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 nSirStatus );
3502 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3503 goto end;
3504 }
3505
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303506 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 // That done, pack the Probe Request:
3508 nStatus = dot11fPackReAssocRequest( pMac, &frm, pFrame +
3509 sizeof(tSirMacMgmtHdr),
3510 nPayload, &nPayload );
3511 if ( DOT11F_FAILED( nStatus ) )
3512 {
3513 limLog( pMac, LOGE, FL("Failed to pack a Re-Association Reque"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003514 "st (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 nStatus );
3516 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3517 goto end;
3518 }
3519 else if ( DOT11F_WARNED( nStatus ) )
3520 {
3521 limLog( pMac, LOGW, FL("There were warnings while packing a R"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08003522 "e-Association Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 }
3524
3525 PELOG1(limLog( pMac, LOG1, FL("*** Sending Re-Association Request length %d"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003526 "to "),
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 nBytes );)
3528
3529 if( psessionEntry->assocReq != NULL )
3530 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303531 vos_mem_free(psessionEntry->assocReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 psessionEntry->assocReq = NULL;
3533 }
3534
3535 if( nAddIELen )
3536 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303537 vos_mem_copy( pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3538 pAddIE,
3539 nAddIELen );
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 nPayload += nAddIELen;
3541 }
3542
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303543 psessionEntry->assocReq = vos_mem_malloc(nPayload);
3544 if ( NULL == psessionEntry->assocReq )
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 {
3546 PELOGE(limLog(pMac, LOGE, FL("Unable to allocate memory to store assoc request"));)
Jeff Johnson43971f52012-07-17 12:26:56 -07003547 }
3548 else
3549 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 //Store the Assoc request. This is sent to csr/hdd in join cnf response.
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303551 vos_mem_copy(psessionEntry->assocReq, pFrame + sizeof(tSirMacMgmtHdr), nPayload);
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 psessionEntry->assocReqLen = nPayload;
Jeff Johnson43971f52012-07-17 12:26:56 -07003553 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003554
3555 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3557 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 )
3559 {
3560 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3561 }
3562
Sushant Kaushike8681d22015-04-21 12:08:25 +05303563 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3564 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003565 {
3566 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3567 }
Deepthi Gowri639d5042015-11-16 20:23:39 +05303568#ifdef FEATURE_WLAN_DIAG_SUPPORT
3569 limDiagEventReport(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT, psessionEntry,
3570 eSIR_SUCCESS, eSIR_SUCCESS);
3571#endif
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003572
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303573 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3574 psessionEntry->peSessionId,
3575 pMacHdr->fc.subType));
Katya Nigam63902932014-06-26 19:04:23 +05303576
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303577 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3578 {
3579 limLog(pMac, LOG1, FL("Reassoc req - txBdToken %u"), pMac->lim.txBdToken);
3580 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3581 ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3582 HAL_TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3583 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3584 limTxComplete, pFrame, limTxBdComplete,
3585 txFlag, pMac->lim.txBdToken );
3586 pMac->lim.txBdToken++;
3587 }
3588 else
3589 {
3590 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) (sizeof(tSirMacMgmtHdr) + nPayload),
3591 HAL_TXRX_FRM_802_11_MGMT,
3592 ANI_TXDIR_TODS,
3593 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
3594 limTxComplete, pFrame, txFlag );
3595 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303596 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3597 psessionEntry->peSessionId,
3598 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3600 {
3601 limLog( pMac, LOGE, FL("Failed to send Re-Association Request"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003602 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 nSirStatus );
3604 //Pkt will be freed up by the callback
3605 goto end;
3606 }
3607
Katya Nigamccaeda72015-04-20 18:51:22 +05303608 // enable caching
3609 WLANTL_EnableCaching(psessionEntry->staId);
3610
Jeff Johnson295189b2012-06-20 16:38:30 -07003611end:
3612 // Free up buffer allocated for mlmAssocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303613 vos_mem_free( pMlmReassocReq );
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 psessionEntry->pLimMlmReassocReq = NULL;
3615
3616} // limSendReassocReqMgmtFrame
3617
Sushant Kaushik9e923872015-04-02 17:09:31 +05303618eHalStatus limAuthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303619{
Sushant Kaushik9e923872015-04-02 17:09:31 +05303620 tANI_U32 txCompleteSuccess;
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303621 tpSirTxBdStatus pTxBdStatus;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303622
3623 if (!pData)
3624 {
3625 limLog(pMac, LOG1,
3626 FL(" pData is NULL"));
3627 return eHAL_STATUS_FAILURE;
3628 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303629
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303630 if (IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
3631 {
3632 pTxBdStatus = (tpSirTxBdStatus) pData;
3633 txCompleteSuccess = pTxBdStatus->txCompleteStatus;
3634 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
3635 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
3636 }
3637 else
3638 {
3639 txCompleteSuccess = *((tANI_U32*) pData);
3640 limLog(pMac, LOG1,
3641 FL("txCompleteSuccess= %d"), txCompleteSuccess);
3642 }
3643
Sushant Kaushik9e923872015-04-02 17:09:31 +05303644 if(txCompleteSuccess)
3645 {
3646 pMac->authAckStatus = LIM_AUTH_ACK_RCD_SUCCESS;
3647 // 'Change' timer for future activations
3648 limDeactivateAndChangeTimer(pMac, eLIM_AUTH_RETRY_TIMER);
3649 }
3650 else
3651 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303652#ifdef FEATURE_WLAN_DIAG_SUPPORT
Deepthi Gowri639d5042015-11-16 20:23:39 +05303653 limDiagEventReport(pMac, WLAN_PE_DIAG_AUTH_START_EVENT, NULL,
Sushant Kaushikb97a0082015-08-31 12:36:45 +05303654 pMac->authAckStatus, eSIR_SUCCESS);
3655#endif
3656
Sushant Kaushik9e923872015-04-02 17:09:31 +05303657 return eHAL_STATUS_SUCCESS;
3658}
3659
Jeff Johnson295189b2012-06-20 16:38:30 -07003660/**
3661 * \brief Send an Authentication frame
3662 *
3663 *
3664 * \param pMac Pointer to Global MAC structure
3665 *
3666 * \param pAuthFrameBody Pointer to Authentication frame structure that need
3667 * to be sent
3668 *
3669 * \param peerMacAddr MAC address of the peer entity to which Authentication
3670 * frame is destined
3671 *
3672 * \param wepBit Indicates whether wep bit to be set in FC while sending
3673 * Authentication frame3
3674 *
3675 *
3676 * This function is called by limProcessMlmMessages(). Authentication frame
3677 * is formatted and sent when this function is called.
3678 *
3679 *
3680 */
3681
3682void
3683limSendAuthMgmtFrame(tpAniSirGlobal pMac,
3684 tpSirMacAuthFrameBody pAuthFrameBody,
3685 tSirMacAddr peerMacAddr,
3686 tANI_U8 wepBit,
Sushant Kaushik9e923872015-04-02 17:09:31 +05303687 tpPESession psessionEntry,
3688 tAniBool waitForAck
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 )
3690{
3691 tANI_U8 *pFrame, *pBody;
3692 tANI_U32 frameLen = 0, bodyLen = 0;
3693 tpSirMacMgmtHdr pMacHdr;
3694 tANI_U16 i;
3695 void *pPacket;
3696 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05303697 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003698
3699 if(NULL == psessionEntry)
3700 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303701 limLog(pMac, LOGE, FL("Error: psession Entry is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 return;
3703 }
Abhishek Singh57aebef2014-02-03 18:47:44 +05303704
3705 limLog(pMac, LOG1,
3706 FL("Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
3707 pAuthFrameBody->authTransactionSeqNumber,
3708 pAuthFrameBody->authStatusCode,
3709 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
3710 MAC_ADDR_ARRAY(peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 if (wepBit == LIM_WEP_IN_FC)
3712 {
3713 /// Auth frame3 to be sent with encrypted framebody
3714 /**
3715 * Allocate buffer for Authenticaton frame of size equal
3716 * to management frame header length plus 2 bytes each for
3717 * auth algorithm number, transaction number, status code,
3718 * 128 bytes for challenge text and 4 bytes each for
3719 * IV & ICV.
3720 */
3721
3722 frameLen = sizeof(tSirMacMgmtHdr) + LIM_ENCR_AUTH_BODY_LEN;
3723
3724 bodyLen = LIM_ENCR_AUTH_BODY_LEN;
3725 } // if (wepBit == LIM_WEP_IN_FC)
3726 else
3727 {
3728 switch (pAuthFrameBody->authTransactionSeqNumber)
3729 {
3730 case SIR_MAC_AUTH_FRAME_1:
3731 /**
3732 * Allocate buffer for Authenticaton frame of size
3733 * equal to management frame header length plus 2 bytes
3734 * each for auth algorithm number, transaction number
3735 * and status code.
3736 */
3737
3738 frameLen = sizeof(tSirMacMgmtHdr) +
3739 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3740 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3741
3742#if defined WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003743 if (pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH)
3744 {
3745 if (0 != pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003747 frameLen += pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length;
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003748 limLog(pMac, LOG3, FL("Auth frame, FTIES length added=%d"),
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003749 pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 }
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003751 else
3752 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303753 limLog(pMac, LOG3, FL("Auth frame, Does not contain "
3754 "FTIES!!!"));
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003755 frameLen += (2+SIR_MDIE_SIZE);
3756 }
3757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003758#endif
3759 break;
3760
3761 case SIR_MAC_AUTH_FRAME_2:
3762 if ((pAuthFrameBody->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
3763 ((pAuthFrameBody->authAlgoNumber == eSIR_SHARED_KEY) &&
3764 (pAuthFrameBody->authStatusCode != eSIR_MAC_SUCCESS_STATUS)))
3765 {
3766 /**
3767 * Allocate buffer for Authenticaton frame of size
3768 * equal to management frame header length plus
3769 * 2 bytes each for auth algorithm number,
3770 * transaction number and status code.
3771 */
3772
3773 frameLen = sizeof(tSirMacMgmtHdr) +
3774 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3775 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3776 }
3777 else
3778 {
3779 // Shared Key algorithm with challenge text
3780 // to be sent
3781 /**
3782 * Allocate buffer for Authenticaton frame of size
3783 * equal to management frame header length plus
3784 * 2 bytes each for auth algorithm number,
3785 * transaction number, status code and 128 bytes
3786 * for challenge text.
3787 */
3788
3789 frameLen = sizeof(tSirMacMgmtHdr) +
3790 sizeof(tSirMacAuthFrame);
3791 bodyLen = sizeof(tSirMacAuthFrameBody);
3792 }
3793
3794 break;
3795
3796 case SIR_MAC_AUTH_FRAME_3:
3797 /// Auth frame3 to be sent without encrypted framebody
3798 /**
3799 * Allocate buffer for Authenticaton frame of size equal
3800 * to management frame header length plus 2 bytes each
3801 * for auth algorithm number, transaction number and
3802 * status code.
3803 */
3804
3805 frameLen = sizeof(tSirMacMgmtHdr) +
3806 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3807 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3808
3809 break;
3810
3811 case SIR_MAC_AUTH_FRAME_4:
3812 /**
3813 * Allocate buffer for Authenticaton frame of size equal
3814 * to management frame header length plus 2 bytes each
3815 * for auth algorithm number, transaction number and
3816 * status code.
3817 */
3818
3819 frameLen = sizeof(tSirMacMgmtHdr) +
3820 SIR_MAC_AUTH_CHALLENGE_OFFSET;
3821 bodyLen = SIR_MAC_AUTH_CHALLENGE_OFFSET;
3822
3823 break;
3824 } // switch (pAuthFrameBody->authTransactionSeqNumber)
3825 } // end if (wepBit == LIM_WEP_IN_FC)
3826
3827
3828 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )frameLen, ( void** ) &pFrame, ( void** ) &pPacket );
3829
3830 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
3831 {
3832 // Log error
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07003833 limLog(pMac, LOGP, FL("call to bufAlloc failed for AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003834
3835 return;
3836 }
3837
3838 for (i = 0; i < frameLen; i++)
3839 pFrame[i] = 0;
3840
3841 // Prepare BD
3842 if (limPopulateMacHeader(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3843 SIR_MAC_MGMT_AUTH, peerMacAddr,psessionEntry->selfMacAddr) != eSIR_SUCCESS)
3844 {
Abhishek Singh57aebef2014-02-03 18:47:44 +05303845 limLog(pMac, LOGE, FL("call to limPopulateMacHeader failed for "
3846 "AUTH frame"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
3848 return;
3849 }
3850
3851 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
3852 pMacHdr->fc.wep = wepBit;
3853
3854 // Prepare BSSId
3855 if( (psessionEntry->limSystemRole == eLIM_AP_ROLE)|| (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) )
3856 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303857 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
3858 (tANI_U8 *) psessionEntry->bssId,
3859 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 }
3861
3862 /// Prepare Authentication frame body
3863 pBody = pFrame + sizeof(tSirMacMgmtHdr);
3864
3865 if (wepBit == LIM_WEP_IN_FC)
3866 {
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303867 vos_mem_copy(pBody, (tANI_U8 *) pAuthFrameBody, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003868
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303869 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303870 FL("*** Sending Auth seq# 3 status %d (%d) to"MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303872 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303873 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003874
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876 else
3877 {
3878 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authAlgoNumber);
3879 pBody += sizeof(tANI_U16);
3880 bodyLen -= sizeof(tANI_U16);
3881
3882 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authTransactionSeqNumber);
3883 pBody += sizeof(tANI_U16);
3884 bodyLen -= sizeof(tANI_U16);
3885
3886 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(pAuthFrameBody->authStatusCode);
3887 pBody += sizeof(tANI_U16);
3888 bodyLen -= sizeof(tANI_U16);
Leela Venkata Kiran Kumar Reddy Chirala7d3fa552013-08-28 10:52:21 -07003889 if ( bodyLen <= (sizeof (pAuthFrameBody->type) +
3890 sizeof (pAuthFrameBody->length) +
3891 sizeof (pAuthFrameBody->challengeText)))
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05303892 vos_mem_copy(pBody, (tANI_U8 *) &pAuthFrameBody->type, bodyLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07003893
3894#if defined WLAN_FEATURE_VOWIFI_11R
3895 if ((pAuthFrameBody->authAlgoNumber == eSIR_FT_AUTH) &&
3896 (pAuthFrameBody->authTransactionSeqNumber == SIR_MAC_AUTH_FRAME_1))
3897 {
3898
3899 {
3900 int i = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 if (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length)
3902 {
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003903#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowdad63eb492014-02-06 12:21:47 -08003904 PELOG2(limLog(pMac, LOG2, FL("Auth1 Frame FTIE is: "));
3905 sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2,
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 (tANI_U8 *)pBody,
3907 (pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003908#endif
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003909 for (i=0; i<pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies_length; i++)
3910 {
Madan Mohan Koyyalamudi6a00a802012-11-28 16:12:11 -08003911 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->ft_ies[i];
3912 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003913 }
3914 }
3915 else
3916 {
3917 /* MDID attr is 54*/
3918 *pBody = 54;
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 pBody++;
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -08003920 *pBody = SIR_MDIE_SIZE;
3921 pBody++;
3922 for(i=0;i<SIR_MDIE_SIZE;i++)
3923 {
3924 *pBody = pMac->ft.ftPEContext.pFTPreAuthReq->pbssDescription->mdie[i];
3925 pBody++;
3926 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 }
3928 }
3929 }
3930#endif
3931
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303932 limLog(pMac, LOG1,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303933 FL("*** Sending Auth seq# %d status %d (%d) to "MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 pAuthFrameBody->authTransactionSeqNumber,
3935 pAuthFrameBody->authStatusCode,
Abhishek Singh57aebef2014-02-03 18:47:44 +05303936 (pAuthFrameBody->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Abhishek Singh3cbf6052014-12-15 16:46:42 +05303937 MAC_ADDR_ARRAY(pMacHdr->da));
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 }
3939 PELOG2(sirDumpBuf(pMac, SIR_LIM_MODULE_ID, LOG2, pFrame, frameLen);)
3940
3941 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
3943 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003944#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05303945 || ((NULL != pMac->ft.ftPEContext.pFTPreAuthReq)
Jeff Johnsone7245742012-09-05 17:12:55 -07003946 && ( SIR_BAND_5_GHZ == limGetRFBand(pMac->ft.ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
3947#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 )
3949 {
3950 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3951 }
3952
Sushant Kaushike8681d22015-04-21 12:08:25 +05303953 if(psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ||
3954 psessionEntry->pePersona == VOS_STA_MODE)
Ganesh K08bce952012-12-13 15:04:41 -08003955 {
3956 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
3957 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08003958
Sushant Kaushik9e923872015-04-02 17:09:31 +05303959 limLog( pMac, LOG1,
3960 FL("Sending Auth Frame over WQ5 with waitForAck %d to "MAC_ADDRESS_STR
3961 " From " MAC_ADDRESS_STR), waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05303962 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3963
3964 txFlag |= HAL_USE_FW_IN_TX_PATH;
3965
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05303966 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
3967 psessionEntry->peSessionId,
3968 pMacHdr->fc.subType));
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303969
3970 if( ( psessionEntry->is11Gonly == true ) &&
3971 ( !IS_BROADCAST_MAC(peerMacAddr) ) ){
3972 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3973 }
Sushant Kaushik9e923872015-04-02 17:09:31 +05303974 if(eSIR_TRUE == waitForAck)
3975 {
3976 pMac->authAckStatus = LIM_AUTH_ACK_NOT_RCD;
Sushant Kaushik0b343422015-05-25 17:15:55 +05303977 limLog(pMac, LOG1, FL("Auth frame - txBdToken %u"),
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303978 pMac->lim.txBdToken);
Sushant Kaushik9e923872015-04-02 17:09:31 +05303979 halstatus = halTxFrameWithTxComplete( pMac, pPacket,
3980 ( tANI_U16 ) frameLen,
3981 HAL_TXRX_FRM_802_11_MGMT,
3982 ANI_TXDIR_TODS,
3983 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattiniffc00b12015-03-18 13:11:33 +05303984 limTxComplete, pFrame, limAuthTxCompleteCnf, txFlag,
3985 pMac->lim.txBdToken);
3986 pMac->lim.txBdToken++;
Sushant Kaushik9e923872015-04-02 17:09:31 +05303987 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
3988 psessionEntry->peSessionId,
3989 halstatus));
3990 if (!HAL_STATUS_SUCCESS(halstatus))
3991 {
3992 limLog( pMac, LOGE,
3993 FL("Could not send Auth frame, retCode=%X "),
3994 halstatus );
3995 pMac->authAckStatus = LIM_AUTH_ACK_RCD_FAILURE;
3996 //Pkt will be freed up by the callback
3997 }
3998 }
3999 else
4000 {
4001 /// Queue Authentication frame in high priority WQ
4002 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) frameLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 HAL_TXRX_FRM_802_11_MGMT,
4004 ANI_TXDIR_TODS,
4005 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4006 limTxComplete, pFrame, txFlag );
Sushant Kaushik9e923872015-04-02 17:09:31 +05304007 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304008 psessionEntry->peSessionId,
4009 halstatus));
Sushant Kaushik9e923872015-04-02 17:09:31 +05304010 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4011 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004013 FL("*** Could not send Auth frame, retCode=%X ***"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 halstatus);
4015
4016 //Pkt will be freed up by the callback
Sushant Kaushik9e923872015-04-02 17:09:31 +05304017 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
4019
4020 return;
4021} /*** end limSendAuthMgmtFrame() ***/
4022
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004023eHalStatus limSendDeauthCnf(tpAniSirGlobal pMac)
4024{
4025 tANI_U16 aid;
4026 tpDphHashNode pStaDs;
4027 tLimMlmDeauthReq *pMlmDeauthReq;
4028 tLimMlmDeauthCnf mlmDeauthCnf;
4029 tpPESession psessionEntry;
4030
4031 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
4032 if (pMlmDeauthReq)
4033 {
4034 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer))
4035 {
4036 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4037 }
4038
4039 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDeauthReq->sessionId))== NULL)
4040 {
4041
4042 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004043 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004044 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4045 goto end;
4046 }
4047
4048 pStaDs = dphLookupHashEntry(pMac, pMlmDeauthReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4049 if (pStaDs == NULL)
4050 {
4051 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4052 goto end;
4053 }
4054
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004055 /// Receive path cleanup with dummy packet
4056 limCleanupRxPath(pMac, pStaDs,psessionEntry);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304057
4058#ifdef WLAN_FEATURE_VOWIFI_11R
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304059 if ( psessionEntry->limSystemRole == eLIM_STA_ROLE )
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304060 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304061 PELOGE(limLog(pMac, LOG1,
4062 FL("FT Preauth SessionId %d Cleanup"
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304063#ifdef FEATURE_WLAN_ESE
4064 " isESE %d"
4065#endif
4066#ifdef FEATURE_WLAN_LFR
4067 " isLFR %d"
4068#endif
4069 " is11r %d, Deauth reason %d Trigger = %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304070 psessionEntry->peSessionId,
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304071#ifdef FEATURE_WLAN_ESE
4072 psessionEntry->isESEconnection,
4073#endif
4074#ifdef FEATURE_WLAN_LFR
4075 psessionEntry->isFastRoamIniFeatureEnabled,
4076#endif
4077 psessionEntry->is11Rconnection,
4078 pMlmDeauthReq->reasonCode,
4079 pMlmDeauthReq->deauthTrigger););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304080
4081 limFTCleanup(pMac);
Abhishek Singhcf4590b2014-04-16 18:58:08 +05304082 }
4083#endif
4084
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004085 /// Free up buffer allocated for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304086 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004087 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
4088 }
4089 return eHAL_STATUS_SUCCESS;
4090end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304091 vos_mem_copy( (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004092 (tANI_U8 *) pMlmDeauthReq->peerMacAddr,
4093 sizeof(tSirMacAddr));
4094 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
4095 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
4096 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
4097
4098 // Free up buffer allocated
4099 // for mlmDeauthReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304100 vos_mem_free(pMlmDeauthReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004101
4102 limPostSmeMessage(pMac,
4103 LIM_MLM_DEAUTH_CNF,
4104 (tANI_U32 *) &mlmDeauthCnf);
4105 return eHAL_STATUS_SUCCESS;
4106}
4107
4108eHalStatus limSendDisassocCnf(tpAniSirGlobal pMac)
4109{
4110 tANI_U16 aid;
4111 tpDphHashNode pStaDs;
4112 tLimMlmDisassocCnf mlmDisassocCnf;
4113 tpPESession psessionEntry;
4114 tLimMlmDisassocReq *pMlmDisassocReq;
4115
4116 pMlmDisassocReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
4117 if (pMlmDisassocReq)
4118 {
4119 if (tx_timer_running(&pMac->lim.limTimers.gLimDisassocAckTimer))
4120 {
4121 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4122 }
4123
4124 if((psessionEntry = peFindSessionBySessionId(pMac, pMlmDisassocReq->sessionId))== NULL)
4125 {
4126
4127 PELOGE(limLog(pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004128 FL("session does not exist for given sessionId"));)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004129 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4130 goto end;
4131 }
4132
4133 pStaDs = dphLookupHashEntry(pMac, pMlmDisassocReq->peerMacAddr, &aid, &psessionEntry->dph.dphHashTable);
4134 if (pStaDs == NULL)
4135 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304136 limLog(pMac, LOGE,
4137 FL("StaDs Null"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004138 mlmDisassocCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
4139 goto end;
4140 }
4141
4142 /// Receive path cleanup with dummy packet
4143 if(eSIR_SUCCESS != limCleanupRxPath(pMac, pStaDs, psessionEntry))
4144 {
4145 mlmDisassocCnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304146 limLog(pMac, LOGE,
4147 FL("CleanupRxPath error"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004148 goto end;
4149 }
4150
4151#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004152 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE ) &&
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05304153 (pMlmDisassocReq->reasonCode !=
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004154 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004155 {
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304156 PELOGE(limLog(pMac, LOG1,
4157 FL("FT Preauth SessionId %d Cleanup"
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004158#ifdef FEATURE_WLAN_ESE
4159 " isESE %d"
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004160#endif
4161#ifdef FEATURE_WLAN_LFR
4162 " isLFR %d"
4163#endif
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004164 " is11r %d reason %d"),
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304165 psessionEntry->peSessionId,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004166#ifdef FEATURE_WLAN_ESE
4167 psessionEntry->isESEconnection,
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004168#endif
4169#ifdef FEATURE_WLAN_LFR
4170 psessionEntry->isFastRoamIniFeatureEnabled,
4171#endif
4172 psessionEntry->is11Rconnection,
4173 pMlmDisassocReq->reasonCode););
Mukul Sharma0820d0e2014-11-11 19:49:02 +05304174 limFTCleanup(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004175 }
4176#endif
4177
4178 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304179 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004180 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4181 return eHAL_STATUS_SUCCESS;
4182 }
4183 else
4184 {
4185 return eHAL_STATUS_SUCCESS;
4186 }
4187end:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304188 vos_mem_copy( (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004189 (tANI_U8 *) pMlmDisassocReq->peerMacAddr,
4190 sizeof(tSirMacAddr));
4191 mlmDisassocCnf.aid = pMlmDisassocReq->aid;
4192 mlmDisassocCnf.disassocTrigger = pMlmDisassocReq->disassocTrigger;
4193
4194 /* Update PE session ID*/
4195 mlmDisassocCnf.sessionId = pMlmDisassocReq->sessionId;
4196
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004197 if(pMlmDisassocReq != NULL)
4198 {
4199 /// Free up buffer allocated for mlmDisassocReq
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304200 vos_mem_free(pMlmDisassocReq);
Madan Mohan Koyyalamudib7f5a672012-11-29 11:17:46 -08004201 pMac->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
4202 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004203
4204 limPostSmeMessage(pMac,
4205 LIM_MLM_DISASSOC_CNF,
4206 (tANI_U32 *) &mlmDisassocCnf);
4207 return eHAL_STATUS_SUCCESS;
4208}
4209
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304210eHalStatus limDisassocTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004211{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304212 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4213 {
4214 tpSirTxBdStatus pTxBdStatus;
4215 pTxBdStatus = (tpSirTxBdStatus) pData;
4216 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4217 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4218 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004219 return limSendDisassocCnf(pMac);
4220}
4221
Ganesh Kondabattini358fc9b2015-03-11 16:14:25 +05304222eHalStatus limDeauthTxCompleteCnf(tpAniSirGlobal pMac, void *pData)
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004223{
Ganesh Kondabattinib18b3292015-03-16 16:59:26 +05304224 if (pData && IS_FEATURE_SUPPORTED_BY_FW(ENHANCED_TXBD_COMPLETION))
4225 {
4226 tpSirTxBdStatus pTxBdStatus;
4227 pTxBdStatus = (tpSirTxBdStatus) pData;
4228 limLog(pMac, LOG1, FL("txCompleteStatus %u, txBdToken %u"),
4229 pTxBdStatus->txCompleteStatus, pTxBdStatus->txBdToken);
4230 }
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004231 return limSendDeauthCnf(pMac);
4232}
4233
Jeff Johnson295189b2012-06-20 16:38:30 -07004234/**
4235 * \brief This function is called to send Disassociate frame.
4236 *
4237 *
4238 * \param pMac Pointer to Global MAC structure
4239 *
4240 * \param nReason Indicates the reason that need to be sent in
4241 * Disassociation frame
4242 *
4243 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
4244 * sent
4245 *
4246 *
4247 */
4248
4249void
4250limSendDisassocMgmtFrame(tpAniSirGlobal pMac,
4251 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004252 tSirMacAddr peer,
4253 tpPESession psessionEntry,
4254 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004255{
4256 tDot11fDisassociation frm;
4257 tANI_U8 *pFrame;
4258 tSirRetStatus nSirStatus;
4259 tpSirMacMgmtHdr pMacHdr;
4260 tANI_U32 nBytes, nPayload, nStatus;
4261 void *pPacket;
4262 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304263 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004264 tANI_U32 val = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004265 if(NULL == psessionEntry)
4266 {
4267 return;
4268 }
4269
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304270 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004271
4272 frm.Reason.code = nReason;
4273
4274 nStatus = dot11fGetPackedDisassociationSize( pMac, &frm, &nPayload );
4275 if ( DOT11F_FAILED( nStatus ) )
4276 {
4277 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004278 "or a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 nStatus );
4280 // We'll fall back on the worst case scenario:
4281 nPayload = sizeof( tDot11fDisassociation );
4282 }
4283 else if ( DOT11F_WARNED( nStatus ) )
4284 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004285 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 "the packed size for a Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004287 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 }
4289
4290 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4291
4292 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4293 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4294 ( void** ) &pPacket );
4295 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4296 {
4297 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Dis"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004298 "association."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 return;
4300 }
4301
4302 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304303 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004304
4305 // Next, we fill out the buffer descriptor:
4306 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4307 SIR_MAC_MGMT_DISASSOC, peer,psessionEntry->selfMacAddr);
4308 if ( eSIR_SUCCESS != nSirStatus )
4309 {
4310 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004311 "tor for a Disassociation (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 nSirStatus );
4313 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4314 ( void* ) pFrame, ( void* ) pPacket );
4315 return; // just allocated...
4316 }
4317
4318 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4319
4320 // Prepare the BSSID
4321 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4322
Chet Lanctot186b5732013-03-18 10:26:30 -07004323#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004324 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004325#endif
4326
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 nStatus = dot11fPackDisassociation( pMac, &frm, pFrame +
4328 sizeof(tSirMacMgmtHdr),
4329 nPayload, &nPayload );
4330 if ( DOT11F_FAILED( nStatus ) )
4331 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004332 limLog( pMac, LOGE, FL("Failed to pack a Disassociation (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 nStatus );
4334 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4335 ( void* ) pFrame, ( void* ) pPacket );
4336 return; // allocated!
4337 }
4338 else if ( DOT11F_WARNED( nStatus ) )
4339 {
4340 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004341 "isassociation (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004342 }
4343
Abhishek Singhcd09b562013-12-24 16:02:20 +05304344 limLog( pMac, LOG1, FL("***Sessionid %d Sending Disassociation frame with "
4345 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4346 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4347 MAC_ADDR_ARRAY(pMacHdr->da),
4348 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004349
4350 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4352 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 )
4354 {
4355 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4356 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004357
Sushant Kaushike8681d22015-04-21 12:08:25 +05304358 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004359
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304360 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4361 {
4362 /* This frame will be sent on air by firmware,
4363 which will ensure that this frame goes out
4364 even though DEL_STA is sent immediately */
4365 /* Without this for DEL_STA command there is
4366 risk of flushing frame in BTQM queue without
4367 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304368 limLog( pMac, LOG1, FL("Sending Disassoc Frame over WQ5 to "MAC_ADDRESS_STR
4369 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4370 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304371 txFlag |= HAL_USE_FW_IN_TX_PATH;
4372 }
4373
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004374 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304376 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4377 psessionEntry->peSessionId,
4378 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004379 // Queue Disassociation frame in high priority WQ
4380 /* get the duration from the request */
4381 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4382 HAL_TXRX_FRM_802_11_MGMT,
4383 ANI_TXDIR_TODS,
4384 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4385 limTxComplete, pFrame, limDisassocTxCompleteCnf,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304386 txFlag,
4387 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304388 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4389 psessionEntry->peSessionId,
4390 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004391 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
Jeff Johnson295189b2012-06-20 16:38:30 -07004392
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004393 if (tx_timer_change(
4394 &pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
4395 != TX_SUCCESS)
4396 {
4397 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004398 FL("Unable to change Disassoc ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004399 return;
4400 }
4401 else if(TX_SUCCESS != tx_timer_activate(
4402 &pMac->lim.limTimers.gLimDisassocAckTimer))
4403 {
4404 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004405 FL("Unable to activate Disassoc ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004406 limDeactivateAndChangeTimer(pMac, eLIM_DISASSOC_ACK_TIMER);
4407 return;
4408 }
4409 }
Madan Mohan Koyyalamudib6af0612012-11-19 13:45:45 -08004410 else
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004411 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304412 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4413 psessionEntry->peSessionId,
4414 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004415 // Queue Disassociation frame in high priority WQ
4416 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4417 HAL_TXRX_FRM_802_11_MGMT,
4418 ANI_TXDIR_TODS,
4419 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4420 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304421 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4422 psessionEntry->peSessionId,
4423 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004424 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4425 {
4426 limLog( pMac, LOGE, FL("Failed to send Disassociation "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004427 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004428 nSirStatus );
4429 //Pkt will be freed up by the callback
4430 return;
4431 }
4432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004433} // End limSendDisassocMgmtFrame.
4434
4435/**
4436 * \brief This function is called to send a Deauthenticate frame
4437 *
4438 *
4439 * \param pMac Pointer to global MAC structure
4440 *
4441 * \param nReason Indicates the reason that need to be sent in the
4442 * Deauthenticate frame
4443 *
4444 * \param peeer address of the STA to which the frame is to be sent
4445 *
4446 *
4447 */
4448
4449void
4450limSendDeauthMgmtFrame(tpAniSirGlobal pMac,
4451 tANI_U16 nReason,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004452 tSirMacAddr peer,
4453 tpPESession psessionEntry,
4454 tANI_BOOLEAN waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004455{
4456 tDot11fDeAuth frm;
4457 tANI_U8 *pFrame;
4458 tSirRetStatus nSirStatus;
4459 tpSirMacMgmtHdr pMacHdr;
4460 tANI_U32 nBytes, nPayload, nStatus;
4461 void *pPacket;
4462 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304463 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004464 tANI_U32 val = 0;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004465#ifdef FEATURE_WLAN_TDLS
4466 tANI_U16 aid;
4467 tpDphHashNode pStaDs;
4468#endif
4469
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 if(NULL == psessionEntry)
4471 {
4472 return;
4473 }
4474
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304475 vos_mem_set( ( tANI_U8* ) &frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004476
4477 frm.Reason.code = nReason;
4478
4479 nStatus = dot11fGetPackedDeAuthSize( pMac, &frm, &nPayload );
4480 if ( DOT11F_FAILED( nStatus ) )
4481 {
4482 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004483 "or a De-Authentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 nStatus );
4485 // We'll fall back on the worst case scenario:
4486 nPayload = sizeof( tDot11fDeAuth );
4487 }
4488 else if ( DOT11F_WARNED( nStatus ) )
4489 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004490 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 "the packed size for a De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004492 "(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 }
4494
4495 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4496
4497 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4498 ( tANI_U16 )nBytes, ( void** ) &pFrame,
4499 ( void** ) &pPacket );
4500 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4501 {
4502 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004503 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004504 return;
4505 }
4506
4507 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304508 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004509
4510 // Next, we fill out the buffer descriptor:
4511 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4512 SIR_MAC_MGMT_DEAUTH, peer,psessionEntry->selfMacAddr);
4513 if ( eSIR_SUCCESS != nSirStatus )
4514 {
4515 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004516 "tor for a De-Authentication (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 nSirStatus );
4518 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4519 ( void* ) pFrame, ( void* ) pPacket );
4520 return; // just allocated...
4521 }
4522
4523 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4524
4525 // Prepare the BSSID
4526 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
4527
Chet Lanctot186b5732013-03-18 10:26:30 -07004528#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004529 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004530#endif
4531
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 nStatus = dot11fPackDeAuth( pMac, &frm, pFrame +
4533 sizeof(tSirMacMgmtHdr),
4534 nPayload, &nPayload );
4535 if ( DOT11F_FAILED( nStatus ) )
4536 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004537 limLog( pMac, LOGE, FL("Failed to pack a DeAuthentication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 nStatus );
4539 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT,
4540 ( void* ) pFrame, ( void* ) pPacket );
4541 return;
4542 }
4543 else if ( DOT11F_WARNED( nStatus ) )
4544 {
4545 limLog( pMac, LOGW, FL("There were warnings while packing a D"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004546 "e-Authentication (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 }
Abhishek Singhcd09b562013-12-24 16:02:20 +05304548 limLog( pMac, LOG1, FL("***Sessionid %d Sending Deauth frame with "
4549 "reason %u and waitForAck %d to "MAC_ADDRESS_STR" ,From "
4550 MAC_ADDRESS_STR), psessionEntry->peSessionId, nReason, waitForAck,
4551 MAC_ADDR_ARRAY(pMacHdr->da),
4552 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004553
4554 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
4556 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 )
4558 {
4559 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4560 }
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004561
Sushant Kaushike8681d22015-04-21 12:08:25 +05304562 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Madan Mohan Koyyalamudi7ff89c12012-11-28 15:50:13 -08004563
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304564 if( IS_FW_IN_TX_PATH_FEATURE_ENABLE )
4565 {
4566 /* This frame will be sent on air by firmware,
4567 which will ensure that this frame goes out
4568 even though DEL_STA is sent immediately */
4569 /* Without this for DEL_STA command there is
4570 risk of flushing frame in BTQM queue without
4571 sending on air */
Agarwal Ashisha8e81f52014-04-02 01:59:52 +05304572 limLog( pMac, LOG1, FL("Sending Deauth Frame over WQ5 to "MAC_ADDRESS_STR
4573 " From " MAC_ADDRESS_STR),MAC_ADDR_ARRAY(pMacHdr->da),
4574 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304575 txFlag |= HAL_USE_FW_IN_TX_PATH;
4576 }
4577
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004578#ifdef FEATURE_WLAN_TDLS
4579 pStaDs = dphLookupHashEntry(pMac, peer, &aid, &psessionEntry->dph.dphHashTable);
4580#endif
4581
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004582 if (waitForAck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304584 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4585 psessionEntry->peSessionId,
4586 pMacHdr->fc.subType));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004587 // Queue Disassociation frame in high priority WQ
4588 halstatus = halTxFrameWithTxComplete( pMac, pPacket, ( tANI_U16 ) nBytes,
4589 HAL_TXRX_FRM_802_11_MGMT,
4590 ANI_TXDIR_TODS,
4591 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Ganesh Kondabattini10e67352015-03-16 17:41:57 +05304592 limTxComplete, pFrame, limDeauthTxCompleteCnf, txFlag,
4593 pMac->lim.txBdToken++);
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304594 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4595 psessionEntry->peSessionId,
4596 halstatus));
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304597 if (!HAL_STATUS_SUCCESS(halstatus))
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004598 {
4599 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304600 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004601 nSirStatus );
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08004602 //Pkt will be freed up by the callback limTxComplete
4603
4604 /*Call limProcessDeauthAckTimeout which will send
4605 * DeauthCnf for this frame
4606 */
4607 limProcessDeauthAckTimeout(pMac);
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004608 return;
4609 }
4610
4611 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
4612
4613 if (tx_timer_change(
4614 &pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
4615 != TX_SUCCESS)
4616 {
4617 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004618 FL("Unable to change Deauth ack Timer val"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004619 return;
4620 }
4621 else if(TX_SUCCESS != tx_timer_activate(
4622 &pMac->lim.limTimers.gLimDeauthAckTimer))
4623 {
4624 limLog(pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004625 FL("Unable to activate Deauth ack Timer"));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004626 limDeactivateAndChangeTimer(pMac, eLIM_DEAUTH_ACK_TIMER);
4627 return;
4628 }
4629 }
4630 else
4631 {
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304632 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4633 psessionEntry->peSessionId,
4634 pMacHdr->fc.subType));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004635#ifdef FEATURE_WLAN_TDLS
4636 if ((NULL != pStaDs) && (STA_ENTRY_TDLS_PEER == pStaDs->staType))
4637 {
4638 // Queue Disassociation frame in high priority WQ
4639 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004640 HAL_TXRX_FRM_802_11_MGMT,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004641 ANI_TXDIR_IBSS,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004642 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4643 limTxComplete, pFrame, txFlag );
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08004644 }
4645 else
4646 {
4647#endif
4648 // Queue Disassociation frame in high priority WQ
4649 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4650 HAL_TXRX_FRM_802_11_MGMT,
4651 ANI_TXDIR_TODS,
4652 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4653 limTxComplete, pFrame, txFlag );
4654#ifdef FEATURE_WLAN_TDLS
4655 }
4656#endif
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304657 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4658 psessionEntry->peSessionId,
4659 halstatus));
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004660 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4661 {
4662 limLog( pMac, LOGE, FL("Failed to send De-Authentication "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004663 "(%X)!"),
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08004664 nSirStatus );
4665 //Pkt will be freed up by the callback
4666 return;
4667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 }
4669
4670} // End limSendDeauthMgmtFrame.
4671
4672
4673#ifdef ANI_SUPPORT_11H
4674/**
4675 * \brief Send a Measurement Report Action frame
4676 *
4677 *
4678 * \param pMac Pointer to the global MAC structure
4679 *
4680 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
4681 *
4682 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4683 *
4684 *
4685 */
4686
4687tSirRetStatus
4688limSendMeasReportFrame(tpAniSirGlobal pMac,
4689 tpSirMacMeasReqActionFrame pMeasReqFrame,
4690 tSirMacAddr peer)
4691{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304692 tDot11fMeasurementReport frm;
4693 tANI_U8 *pFrame;
4694 tSirRetStatus nSirStatus;
4695 tpSirMacMgmtHdr pMacHdr;
4696 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4697 void *pPacket;
4698 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004699
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304700 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4703 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
4704 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
4705
4706 switch ( pMeasReqFrame->measReqIE.measType )
4707 {
4708 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
4709 nSirStatus =
4710 PopulateDot11fMeasurementReport0( pMac, pMeasReqFrame,
4711 &frm.MeasurementReport );
4712 break;
4713 case SIR_MAC_CCA_MEASUREMENT_TYPE:
4714 nSirStatus =
4715 PopulateDot11fMeasurementReport1( pMac, pMeasReqFrame,
4716 &frm.MeasurementReport );
4717 break;
4718 case SIR_MAC_RPI_MEASUREMENT_TYPE:
4719 nSirStatus =
4720 PopulateDot11fMeasurementReport2( pMac, pMeasReqFrame,
4721 &frm.MeasurementReport );
4722 break;
4723 default:
4724 limLog( pMac, LOGE, FL("Unknown measurement type %d in limSen"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004725 "dMeasReportFrame."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 pMeasReqFrame->measReqIE.measType );
4727 return eSIR_FAILURE;
4728 }
4729
4730 if ( eSIR_SUCCESS != nSirStatus ) return eSIR_FAILURE;
4731
4732 nStatus = dot11fGetPackedMeasurementReportSize( pMac, &frm, &nPayload );
4733 if ( DOT11F_FAILED( nStatus ) )
4734 {
4735 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004736 "or a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 nStatus );
4738 // We'll fall back on the worst case scenario:
4739 nPayload = sizeof( tDot11fMeasurementReport );
4740 }
4741 else if ( DOT11F_WARNED( nStatus ) )
4742 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004743 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004744 "the packed size for a Measurement Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004745 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 }
4747
4748 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4749
4750 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4751 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4752 {
4753 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a De-"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004754 "Authentication."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 return eSIR_FAILURE;
4756 }
4757
4758 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304759 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760
4761 // Next, we fill out the buffer descriptor:
4762 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4763 SIR_MAC_MGMT_ACTION, peer);
4764 if ( eSIR_SUCCESS != nSirStatus )
4765 {
4766 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004767 "tor for a Measurement Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 nSirStatus );
4769 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4770 return eSIR_FAILURE; // just allocated...
4771 }
4772
4773 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4774
4775 nCfg = 6;
4776 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4777 if ( eSIR_SUCCESS != nSirStatus )
4778 {
4779 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004780 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004781 nSirStatus );
4782 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4783 return eSIR_FAILURE; // just allocated...
4784 }
4785
Chet Lanctot186b5732013-03-18 10:26:30 -07004786#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004787 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004788#endif
4789
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 nStatus = dot11fPackMeasurementReport( pMac, &frm, pFrame +
4791 sizeof(tSirMacMgmtHdr),
4792 nPayload, &nPayload );
4793 if ( DOT11F_FAILED( nStatus ) )
4794 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004795 limLog( pMac, LOGE, FL("Failed to pack a Measurement Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 nStatus );
4797 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4798 return eSIR_FAILURE; // allocated!
4799 }
4800 else if ( DOT11F_WARNED( nStatus ) )
4801 {
4802 limLog( pMac, LOGW, FL("There were warnings while packing a M"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004803 "easurement Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
4805
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304806 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4807 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4808 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004809 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4810 HAL_TXRX_FRM_802_11_MGMT,
4811 ANI_TXDIR_TODS,
4812 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4813 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304814 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4815 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4816 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4818 {
4819 limLog( pMac, LOGE, FL("Failed to send a Measurement Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004820 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 nSirStatus );
4822 //Pkt will be freed up by the callback
4823 return eSIR_FAILURE; // just allocated...
4824 }
4825
4826 return eSIR_SUCCESS;
4827
4828} // End limSendMeasReportFrame.
4829
4830
4831/**
4832 * \brief Send a TPC Request Action frame
4833 *
4834 *
4835 * \param pMac Pointer to the global MAC datastructure
4836 *
4837 * \param peer MAC address to which the frame should be sent
4838 *
4839 *
4840 */
4841
4842void
4843limSendTpcRequestFrame(tpAniSirGlobal pMac,
4844 tSirMacAddr peer)
4845{
4846 tDot11fTPCRequest frm;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304847 tANI_U8 *pFrame;
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 tSirRetStatus nSirStatus;
4849 tpSirMacMgmtHdr pMacHdr;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304850 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4851 void *pPacket;
4852 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004853
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304854 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004855
4856 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4857 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
4858 frm.DialogToken.token = 1;
4859 frm.TPCRequest.present = 1;
4860
4861 nStatus = dot11fGetPackedTPCRequestSize( pMac, &frm, &nPayload );
4862 if ( DOT11F_FAILED( nStatus ) )
4863 {
4864 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004865 "or a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 nStatus );
4867 // We'll fall back on the worst case scenario:
4868 nPayload = sizeof( tDot11fTPCRequest );
4869 }
4870 else if ( DOT11F_WARNED( nStatus ) )
4871 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004872 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 "the packed size for a TPC Request (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004874 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 }
4876
4877 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
4878
4879 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
4880 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4881 {
4882 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004883 " Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 return;
4885 }
4886
4887 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304888 vos_mem_set(pFrame, nBytes,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004889
4890 // Next, we fill out the buffer descriptor:
4891 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
4892 SIR_MAC_MGMT_ACTION, peer);
4893 if ( eSIR_SUCCESS != nSirStatus )
4894 {
4895 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004896 "tor for a TPC Request (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 nSirStatus );
4898 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4899 return; // just allocated...
4900 }
4901
4902 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
4903
4904 nCfg = 6;
4905 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
4906 if ( eSIR_SUCCESS != nSirStatus )
4907 {
4908 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004909 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 nSirStatus );
4911 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4912 return; // just allocated...
4913 }
4914
Chet Lanctot186b5732013-03-18 10:26:30 -07004915#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07004916 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07004917#endif
4918
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 nStatus = dot11fPackTPCRequest( pMac, &frm, pFrame +
4920 sizeof(tSirMacMgmtHdr),
4921 nPayload, &nPayload );
4922 if ( DOT11F_FAILED( nStatus ) )
4923 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004924 limLog( pMac, LOGE, FL("Failed to pack a TPC Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 nStatus );
4926 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
4927 return; // allocated!
4928 }
4929 else if ( DOT11F_WARNED( nStatus ) )
4930 {
4931 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08004932 "PC Request (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 }
4934
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304935 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
4936 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4937 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
4939 HAL_TXRX_FRM_802_11_MGMT,
4940 ANI_TXDIR_TODS,
4941 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
4942 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05304943 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
4944 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
4945 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
4947 {
4948 limLog( pMac, LOGE, FL("Failed to send a TPC Request "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07004949 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 nSirStatus );
4951 //Pkt will be freed up by the callback
4952 return;
4953 }
4954
4955} // End limSendTpcRequestFrame.
4956
4957
4958/**
4959 * \brief Send a TPC Report Action frame
4960 *
4961 *
4962 * \param pMac Pointer to the global MAC datastructure
4963 *
4964 * \param pTpcReqFrame Pointer to the received TPC Request
4965 *
4966 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4967 *
4968 *
4969 */
4970
4971tSirRetStatus
4972limSendTpcReportFrame(tpAniSirGlobal pMac,
4973 tpSirMacTpcReqActionFrame pTpcReqFrame,
4974 tSirMacAddr peer)
4975{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05304976 tDot11fTPCReport frm;
4977 tANI_U8 *pFrame;
4978 tSirRetStatus nSirStatus;
4979 tpSirMacMgmtHdr pMacHdr;
4980 tANI_U32 nBytes, nPayload, nStatus, nCfg;
4981 void *pPacket;
4982 eHalStatus halstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07004983
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05304984 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004985
4986 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
4987 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
4988 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
4989
4990 // FramesToDo: On the Gen4_TVM branch, there was a comment:
4991 // "misplaced this function, need to replace:
4992 // txPower = halGetRateToPwrValue(pMac, staid,
4993 // pMac->lim.gLimCurrentChannelId, 0);
4994 frm.TPCReport.tx_power = 0;
4995 frm.TPCReport.link_margin = 0;
4996 frm.TPCReport.present = 1;
4997
4998 nStatus = dot11fGetPackedTPCReportSize( pMac, &frm, &nPayload );
4999 if ( DOT11F_FAILED( nStatus ) )
5000 {
5001 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005002 "or a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 nStatus );
5004 // We'll fall back on the worst case scenario:
5005 nPayload = sizeof( tDot11fTPCReport );
5006 }
5007 else if ( DOT11F_WARNED( nStatus ) )
5008 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005009 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 "the packed size for a TPC Report (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005011 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 }
5013
5014 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5015
5016 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5017 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5018 {
5019 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005020 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 return eSIR_FAILURE;
5022 }
5023
5024 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305025 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005026
5027 // Next, we fill out the buffer descriptor:
5028 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5029 SIR_MAC_MGMT_ACTION, peer);
5030 if ( eSIR_SUCCESS != nSirStatus )
5031 {
5032 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005033 "tor for a TPC Report (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 nSirStatus );
5035 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5036 return eSIR_FAILURE; // just allocated...
5037 }
5038
5039 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5040
5041 nCfg = 6;
5042 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5043 if ( eSIR_SUCCESS != nSirStatus )
5044 {
5045 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005046 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 nSirStatus );
5048 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5049 return eSIR_FAILURE; // just allocated...
5050 }
5051
Chet Lanctot186b5732013-03-18 10:26:30 -07005052#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005053 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005054#endif
5055
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 nStatus = dot11fPackTPCReport( pMac, &frm, pFrame +
5057 sizeof(tSirMacMgmtHdr),
5058 nPayload, &nPayload );
5059 if ( DOT11F_FAILED( nStatus ) )
5060 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005061 limLog( pMac, LOGE, FL("Failed to pack a TPC Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 nStatus );
5063 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5064 return eSIR_FAILURE; // allocated!
5065 }
5066 else if ( DOT11F_WARNED( nStatus ) )
5067 {
5068 limLog( pMac, LOGW, FL("There were warnings while packing a T"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005069 "PC Report (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 }
5071
5072
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305073 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5074 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5075 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5077 HAL_TXRX_FRM_802_11_MGMT,
5078 ANI_TXDIR_TODS,
5079 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5080 limTxComplete, pFrame, 0 );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305081 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5082 ((psessionEntry)? psessionEntry->peSessionId : NO_SESSION),
5083 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5085 {
5086 limLog( pMac, LOGE, FL("Failed to send a TPC Report "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005087 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005088 nSirStatus );
5089 //Pkt will be freed up by the callback
5090 return eSIR_FAILURE; // just allocated...
5091 }
5092
5093 return eSIR_SUCCESS;
5094
5095} // End limSendTpcReportFrame.
5096#endif //ANI_SUPPORT_11H
5097
5098
Jeff Johnson295189b2012-06-20 16:38:30 -07005099/**
5100 * \brief Send a Channel Switch Announcement
5101 *
5102 *
5103 * \param pMac Pointer to the global MAC datastructure
5104 *
5105 * \param peer MAC address to which this frame will be sent
5106 *
5107 * \param nMode
5108 *
5109 * \param nNewChannel
5110 *
5111 * \param nCount
5112 *
5113 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5114 *
5115 *
5116 */
5117
5118tSirRetStatus
5119limSendChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5120 tSirMacAddr peer,
Jeff Johnsone7245742012-09-05 17:12:55 -07005121 tANI_U8 nMode,
5122 tANI_U8 nNewChannel,
5123 tANI_U8 nCount,
5124 tpPESession psessionEntry )
Jeff Johnson295189b2012-06-20 16:38:30 -07005125{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305126 tDot11fChannelSwitch frm;
5127 tANI_U8 *pFrame;
5128 tSirRetStatus nSirStatus;
5129 tpSirMacMgmtHdr pMacHdr;
5130 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5131 void *pPacket;
5132 eHalStatus halstatus;
5133 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005134
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305135 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005136
5137 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5138 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5139 frm.ChanSwitchAnn.switchMode = nMode;
5140 frm.ChanSwitchAnn.newChannel = nNewChannel;
5141 frm.ChanSwitchAnn.switchCount = nCount;
5142 frm.ChanSwitchAnn.present = 1;
5143
5144 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5145 if ( DOT11F_FAILED( nStatus ) )
5146 {
5147 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005148 "or a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 nStatus );
5150 // We'll fall back on the worst case scenario:
5151 nPayload = sizeof( tDot11fChannelSwitch );
5152 }
5153 else if ( DOT11F_WARNED( nStatus ) )
5154 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005155 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005157 "%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 }
5159
5160 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5161
5162 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5163 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5164 {
5165 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005166 " Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 return eSIR_FAILURE;
5168 }
5169
5170 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305171 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005172
5173 // Next, we fill out the buffer descriptor:
5174 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsone7245742012-09-05 17:12:55 -07005175 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5176 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305177 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5178 (tANI_U8 *) psessionEntry->bssId,
5179 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 if ( eSIR_SUCCESS != nSirStatus )
5181 {
5182 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005183 "tor for a Channel Switch (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 nSirStatus );
5185 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5186 return eSIR_FAILURE; // just allocated...
5187 }
5188
Jeff Johnsone7245742012-09-05 17:12:55 -07005189#if 0
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
5191
5192 nCfg = 6;
5193 nSirStatus = wlan_cfgGetStr( pMac, WNI_CFG_BSSID, pMacHdr->bssId, &nCfg );
5194 if ( eSIR_SUCCESS != nSirStatus )
5195 {
5196 limLog( pMac, LOGE, FL("Failed to retrieve WNI_CFG_BSSID from"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005197 " CFG (%d)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 nSirStatus );
5199 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5200 return eSIR_FAILURE; // just allocated...
5201 }
Jeff Johnsone7245742012-09-05 17:12:55 -07005202#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005203
5204#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005205 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005206#endif
5207
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5209 sizeof(tSirMacMgmtHdr),
5210 nPayload, &nPayload );
5211 if ( DOT11F_FAILED( nStatus ) )
5212 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005213 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 nStatus );
5215 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5216 return eSIR_FAILURE; // allocated!
5217 }
5218 else if ( DOT11F_WARNED( nStatus ) )
5219 {
5220 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005221 "hannel Switch (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 }
5223
Jeff Johnsone7245742012-09-05 17:12:55 -07005224 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnsone7245742012-09-05 17:12:55 -07005225 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5226 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnsone7245742012-09-05 17:12:55 -07005227 )
5228 {
5229 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5230 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305231
5232 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5233 psessionEntry->peSessionId,
5234 pMacHdr->fc.subType));
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5236 HAL_TXRX_FRM_802_11_MGMT,
5237 ANI_TXDIR_TODS,
5238 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
Jeff Johnsone7245742012-09-05 17:12:55 -07005239 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305240 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5241 psessionEntry->peSessionId,
5242 halstatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5244 {
5245 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005246 "(%X)!"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 nSirStatus );
5248 //Pkt will be freed up by the callback
5249 return eSIR_FAILURE;
5250 }
5251
5252 return eSIR_SUCCESS;
5253
5254} // End limSendChannelSwitchMgmtFrame.
5255
Jeff Johnson295189b2012-06-20 16:38:30 -07005256
5257
Mohit Khanna4a70d262012-09-11 16:30:12 -07005258#ifdef WLAN_FEATURE_11AC
5259tSirRetStatus
5260limSendVHTOpmodeNotificationFrame(tpAniSirGlobal pMac,
5261 tSirMacAddr peer,
5262 tANI_U8 nMode,
5263 tpPESession psessionEntry )
5264{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305265 tDot11fOperatingMode frm;
5266 tANI_U8 *pFrame;
5267 tSirRetStatus nSirStatus;
5268 tpSirMacMgmtHdr pMacHdr;
5269 tANI_U32 nBytes, nPayload = 0, nStatus;//, nCfg;
5270 void *pPacket;
5271 eHalStatus halstatus;
5272 tANI_U32 txFlag = 0;
Mohit Khanna4a70d262012-09-11 16:30:12 -07005273
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305274 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005275
5276 frm.Category.category = SIR_MAC_ACTION_VHT;
5277 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
5278 frm.OperatingMode.chanWidth = nMode;
5279 frm.OperatingMode.rxNSS = 0;
5280 frm.OperatingMode.rxNSSType = 0;
5281
5282 nStatus = dot11fGetPackedOperatingModeSize( pMac, &frm, &nPayload );
5283 if ( DOT11F_FAILED( nStatus ) )
5284 {
5285 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005286 "or a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005287 nStatus );
5288 // We'll fall back on the worst case scenario:
5289 nPayload = sizeof( tDot11fOperatingMode);
5290 }
5291 else if ( DOT11F_WARNED( nStatus ) )
5292 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005293 limLog( pMac, LOGW, FL("There were warnings while calculating "
Mohit Khanna4a70d262012-09-11 16:30:12 -07005294 "the packed size for a Operating Mode (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005295 "%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005296 }
5297
5298 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5299
5300 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5301 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5302 {
5303 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Operating Mode"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005304 " Report."), nBytes );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005305 return eSIR_FAILURE;
5306 }
5307
5308 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305309 vos_mem_set( pFrame, nBytes, 0 );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005310
5311
5312 // Next, we fill out the buffer descriptor:
5313 if(psessionEntry->pePersona == VOS_STA_SAP_MODE) {
5314 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5315 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5316 } else
5317 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5318 SIR_MAC_MGMT_ACTION, psessionEntry->bssId, psessionEntry->selfMacAddr);
5319 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305320 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5321 (tANI_U8 *) psessionEntry->bssId,
5322 sizeof( tSirMacAddr ));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005323 if ( eSIR_SUCCESS != nSirStatus )
5324 {
5325 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005326 "tor for a Operating Mode (%d)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005327 nSirStatus );
5328 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5329 return eSIR_FAILURE; // just allocated...
5330 }
5331 nStatus = dot11fPackOperatingMode( pMac, &frm, pFrame +
5332 sizeof(tSirMacMgmtHdr),
5333 nPayload, &nPayload );
5334 if ( DOT11F_FAILED( nStatus ) )
5335 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005336 limLog( pMac, LOGE, FL("Failed to pack a Operating Mode (0x%08x)."),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005337 nStatus );
5338 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5339 return eSIR_FAILURE; // allocated!
5340 }
5341 else if ( DOT11F_WARNED( nStatus ) )
5342 {
5343 limLog( pMac, LOGW, FL("There were warnings while packing a Operating Mode"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005344 " (0x%08x)."), nStatus );
Mohit Khanna4a70d262012-09-11 16:30:12 -07005345 }
5346 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Mohit Khanna4a70d262012-09-11 16:30:12 -07005347 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5348 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Mohit Khanna4a70d262012-09-11 16:30:12 -07005349 )
5350 {
5351 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5352 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305353
5354 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5355 psessionEntry->peSessionId,
5356 pMacHdr->fc.subType));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005357 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5358 HAL_TXRX_FRM_802_11_MGMT,
5359 ANI_TXDIR_TODS,
5360 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5361 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305362 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5363 psessionEntry->peSessionId,
5364 halstatus));
Mohit Khanna4a70d262012-09-11 16:30:12 -07005365 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5366 {
5367 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005368 "(%X)!"),
Mohit Khanna4a70d262012-09-11 16:30:12 -07005369 nSirStatus );
5370 //Pkt will be freed up by the callback
5371 return eSIR_FAILURE;
5372 }
5373
5374 return eSIR_SUCCESS;
5375}
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005376
5377/**
5378 * \brief Send a VHT Channel Switch Announcement
5379 *
5380 *
5381 * \param pMac Pointer to the global MAC datastructure
5382 *
5383 * \param peer MAC address to which this frame will be sent
5384 *
5385 * \param nChanWidth
5386 *
5387 * \param nNewChannel
5388 *
5389 *
5390 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
5391 *
5392 *
5393 */
5394
5395tSirRetStatus
5396limSendVHTChannelSwitchMgmtFrame(tpAniSirGlobal pMac,
5397 tSirMacAddr peer,
5398 tANI_U8 nChanWidth,
5399 tANI_U8 nNewChannel,
5400 tANI_U8 ncbMode,
5401 tpPESession psessionEntry )
5402{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305403 tDot11fChannelSwitch frm;
5404 tANI_U8 *pFrame;
5405 tSirRetStatus nSirStatus;
5406 tpSirMacMgmtHdr pMacHdr;
5407 tANI_U32 nBytes, nPayload, nStatus;//, nCfg;
5408 void *pPacket;
5409 eHalStatus halstatus;
5410 tANI_U32 txFlag = 0;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005411
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305412 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005413
5414
5415 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
5416 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
5417 frm.ChanSwitchAnn.switchMode = 1;
5418 frm.ChanSwitchAnn.newChannel = nNewChannel;
5419 frm.ChanSwitchAnn.switchCount = 1;
5420 frm.ExtChanSwitchAnn.secondaryChannelOffset = limGetHTCBState(ncbMode);
5421 frm.ExtChanSwitchAnn.present = 1;
5422 frm.WiderBWChanSwitchAnn.newChanWidth = nChanWidth;
5423 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 = limGetCenterChannel(pMac,nNewChannel,ncbMode,nChanWidth);
5424 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 = 0;
5425 frm.ChanSwitchAnn.present = 1;
5426 frm.WiderBWChanSwitchAnn.present = 1;
5427
5428 nStatus = dot11fGetPackedChannelSwitchSize( pMac, &frm, &nPayload );
5429 if ( DOT11F_FAILED( nStatus ) )
5430 {
5431 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005432 "or a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005433 nStatus );
5434 // We'll fall back on the worst case scenario:
5435 nPayload = sizeof( tDot11fChannelSwitch );
5436 }
5437 else if ( DOT11F_WARNED( nStatus ) )
5438 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005439 limLog( pMac, LOGW, FL("There were warnings while calculating "
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005440 "the packed size for a Channel Switch (0x"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005441 "%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005442 }
5443
5444 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
5445
5446 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
5447 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5448 {
5449 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a TPC"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005450 " Report."), nBytes );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005451 return eSIR_FAILURE;
5452 }
5453 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305454 vos_mem_set( pFrame, nBytes, 0 );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005455
5456 // Next, we fill out the buffer descriptor:
5457 nSirStatus = limPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
5458 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
5459 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305460 vos_mem_copy( (tANI_U8 *) pMacHdr->bssId,
5461 (tANI_U8 *) psessionEntry->bssId,
5462 sizeof( tSirMacAddr ));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005463 if ( eSIR_SUCCESS != nSirStatus )
5464 {
5465 limLog( pMac, LOGE, FL("Failed to populate the buffer descrip"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005466 "tor for a Channel Switch (%d)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005467 nSirStatus );
5468 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5469 return eSIR_FAILURE; // just allocated...
5470 }
5471 nStatus = dot11fPackChannelSwitch( pMac, &frm, pFrame +
5472 sizeof(tSirMacMgmtHdr),
5473 nPayload, &nPayload );
5474 if ( DOT11F_FAILED( nStatus ) )
5475 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005476 limLog( pMac, LOGE, FL("Failed to pack a Channel Switch (0x%08x)."),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005477 nStatus );
5478 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
5479 return eSIR_FAILURE; // allocated!
5480 }
5481 else if ( DOT11F_WARNED( nStatus ) )
5482 {
5483 limLog( pMac, LOGW, FL("There were warnings while packing a C"
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005484 "hannel Switch (0x%08x)."), nStatus );
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005485 }
5486
5487 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005488 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5489 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005490 )
5491 {
5492 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5493 }
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305494
5495 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5496 psessionEntry->peSessionId,
5497 pMacHdr->fc.subType));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005498 halstatus = halTxFrame( pMac, pPacket, ( tANI_U16 ) nBytes,
5499 HAL_TXRX_FRM_802_11_MGMT,
5500 ANI_TXDIR_TODS,
5501 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5502 limTxComplete, pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305503 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5504 psessionEntry->peSessionId,
5505 halstatus));
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005506 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
5507 {
5508 limLog( pMac, LOGE, FL("Failed to send a Channel Switch "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005509 "(%X)!"),
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07005510 nSirStatus );
5511 //Pkt will be freed up by the callback
5512 return eSIR_FAILURE;
5513 }
5514
5515 return eSIR_SUCCESS;
5516
5517} // End limSendVHTChannelSwitchMgmtFrame.
5518
5519
5520
Mohit Khanna4a70d262012-09-11 16:30:12 -07005521#endif
5522
Jeff Johnson295189b2012-06-20 16:38:30 -07005523/**
5524 * \brief Send an ADDBA Req Action Frame to peer
5525 *
5526 * \sa limSendAddBAReq
5527 *
5528 * \param pMac The global tpAniSirGlobal object
5529 *
5530 * \param pMlmAddBAReq A pointer to tLimMlmAddBAReq. This contains
5531 * the necessary parameters reqd by PE send the ADDBA Req Action
5532 * Frame to the peer
5533 *
5534 * \return eSIR_SUCCESS if setup completes successfully
5535 * eSIR_FAILURE is some problem is encountered
5536 */
5537tSirRetStatus limSendAddBAReq( tpAniSirGlobal pMac,
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305538 tpLimMlmAddBAReq pMlmAddBAReq, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07005539{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305540 tDot11fAddBAReq frmAddBAReq;
5541 tANI_U8 *pAddBAReqBuffer = NULL;
5542 tpSirMacMgmtHdr pMacHdr;
5543 tANI_U32 frameLen = 0, nStatus, nPayload;
5544 tSirRetStatus statusCode;
5545 eHalStatus halStatus;
5546 void *pPacket;
5547 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005548
5549 if(NULL == psessionEntry)
5550 {
5551 return eSIR_FAILURE;
5552 }
5553
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305554 vos_mem_set( (void *) &frmAddBAReq, sizeof( frmAddBAReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005555
5556 // Category - 3 (BA)
5557 frmAddBAReq.Category.category = SIR_MAC_ACTION_BLKACK;
5558
5559 // Action - 0 (ADDBA Req)
5560 frmAddBAReq.Action.action = SIR_MAC_BLKACK_ADD_REQ;
5561
5562 // FIXME - Dialog Token, generalize this...
5563 frmAddBAReq.DialogToken.token = pMlmAddBAReq->baDialogToken;
5564
5565 // Fill the ADDBA Parameter Set
5566 frmAddBAReq.AddBAParameterSet.tid = pMlmAddBAReq->baTID;
5567 frmAddBAReq.AddBAParameterSet.policy = pMlmAddBAReq->baPolicy;
5568 frmAddBAReq.AddBAParameterSet.bufferSize = pMlmAddBAReq->baBufferSize;
5569
5570 // BA timeout
5571 // 0 - indicates no BA timeout
5572 frmAddBAReq.BATimeout.timeout = pMlmAddBAReq->baTimeout;
5573
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305574 /* Send SSN whatever we get from FW.
5575 */
5576 frmAddBAReq.BAStartingSequenceControl.ssn = pMlmAddBAReq->baSSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07005577
5578 nStatus = dot11fGetPackedAddBAReqSize( pMac, &frmAddBAReq, &nPayload );
5579
5580 if( DOT11F_FAILED( nStatus ))
5581 {
5582 limLog( pMac, LOGW,
5583 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005584 "an ADDBA Request (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 nStatus );
5586
5587 // We'll fall back on the worst case scenario:
5588 nPayload = sizeof( tDot11fAddBAReq );
5589 }
5590 else if( DOT11F_WARNED( nStatus ))
5591 {
5592 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005593 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005594 "the packed size for an ADDBA Req (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 nStatus );
5596 }
5597
5598 // Add the MGMT header to frame length
5599 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5600
5601 // Need to allocate a buffer for ADDBA AF
5602 if( eHAL_STATUS_SUCCESS !=
5603 (halStatus = palPktAlloc( pMac->hHdd,
5604 HAL_TXRX_FRM_802_11_MGMT,
5605 (tANI_U16) frameLen,
5606 (void **) &pAddBAReqBuffer,
5607 (void **) &pPacket )))
5608 {
5609 // Log error
5610 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005611 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005612 frameLen,
5613 halStatus );
5614
5615 statusCode = eSIR_MEM_ALLOC_FAILED;
5616 goto returnAfterError;
5617 }
5618
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305619 vos_mem_set( (void *) pAddBAReqBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005620
5621 // Copy necessary info to BD
5622 if( eSIR_SUCCESS !=
5623 (statusCode = limPopulateMacHeader( pMac,
5624 pAddBAReqBuffer,
5625 SIR_MAC_MGMT_FRAME,
5626 SIR_MAC_MGMT_ACTION,
5627 pMlmAddBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
5628 goto returnAfterError;
5629
5630 // Update A3 with the BSSID
5631 pMacHdr = ( tpSirMacMgmtHdr ) pAddBAReqBuffer;
5632
5633 #if 0
5634 cfgLen = SIR_MAC_ADDR_LENGTH;
5635 if( eSIR_SUCCESS != cfgGetStr( pMac,
5636 WNI_CFG_BSSID,
5637 (tANI_U8 *) pMacHdr->bssId,
5638 &cfgLen ))
5639 {
5640 limLog( pMac, LOGP,
5641 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005642 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005643
5644 // FIXME - Need to convert to tSirRetStatus
5645 statusCode = eSIR_FAILURE;
5646 goto returnAfterError;
5647 }
5648 #endif//TO SUPPORT BT-AMP
5649 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5650
Chet Lanctot186b5732013-03-18 10:26:30 -07005651#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005652 limSetProtectedBit(pMac, psessionEntry, pMlmAddBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005653#endif
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 // Now, we're ready to "pack" the frames
5656 nStatus = dot11fPackAddBAReq( pMac,
5657 &frmAddBAReq,
5658 pAddBAReqBuffer + sizeof( tSirMacMgmtHdr ),
5659 nPayload,
5660 &nPayload );
5661
5662 if( DOT11F_FAILED( nStatus ))
5663 {
5664 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005665 FL( "Failed to pack an ADDBA Req (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 nStatus );
5667
5668 // FIXME - Need to convert to tSirRetStatus
5669 statusCode = eSIR_FAILURE;
5670 goto returnAfterError;
5671 }
5672 else if( DOT11F_WARNED( nStatus ))
5673 {
5674 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005675 FL( "There were warnings while packing an ADDBA Req (0x%08x)."),
5676 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 }
5678
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305679 limLog( pMac, LOG1, FL( "Sending an ADDBA REQ to "MAC_ADDRESS_STR " with"
5680 " tid = %d policy = %d buffsize = %d "
5681 " amsduSupported = %d"),
5682 MAC_ADDR_ARRAY(pMlmAddBAReq->peerMacAddr),
5683 frmAddBAReq.AddBAParameterSet.tid,
5684 frmAddBAReq.AddBAParameterSet.policy,
5685 frmAddBAReq.AddBAParameterSet.bufferSize,
5686 frmAddBAReq.AddBAParameterSet.amsduSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07005687
Abhishek Singh1f6e6532014-06-05 17:35:08 +05305688 limLog( pMac, LOG1, FL( "ssn = %d fragNum = %d" ),
5689 frmAddBAReq.BAStartingSequenceControl.ssn,
5690 frmAddBAReq.BAStartingSequenceControl.fragNumber);
5691
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5694 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005695 )
5696 {
5697 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5698 }
5699
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305700 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5701 psessionEntry->peSessionId,
5702 pMacHdr->fc.subType));
5703 halStatus = halTxFrame( pMac,
5704 pPacket,
5705 (tANI_U16) frameLen,
5706 HAL_TXRX_FRM_802_11_MGMT,
5707 ANI_TXDIR_TODS,
5708 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5709 limTxComplete,
5710 pAddBAReqBuffer, txFlag );
5711 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5712 psessionEntry->peSessionId,
5713 halStatus));
5714 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 {
5716 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005717 FL( "halTxFrame FAILED! Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 halStatus );
5719
5720 // FIXME - Need to convert eHalStatus to tSirRetStatus
5721 statusCode = eSIR_FAILURE;
5722 //Pkt will be freed up by the callback
5723 return statusCode;
5724 }
5725 else
5726 return eSIR_SUCCESS;
5727
5728returnAfterError:
5729
5730 // Release buffer, if allocated
5731 if( NULL != pAddBAReqBuffer )
5732 palPktFree( pMac->hHdd,
5733 HAL_TXRX_FRM_802_11_MGMT,
5734 (void *) pAddBAReqBuffer,
5735 (void *) pPacket );
5736
5737 return statusCode;
5738}
5739
5740/**
5741 * \brief Send an ADDBA Rsp Action Frame to peer
5742 *
5743 * \sa limSendAddBARsp
5744 *
5745 * \param pMac The global tpAniSirGlobal object
5746 *
5747 * \param pMlmAddBARsp A pointer to tLimMlmAddBARsp. This contains
5748 * the necessary parameters reqd by PE send the ADDBA Rsp Action
5749 * Frame to the peer
5750 *
5751 * \return eSIR_SUCCESS if setup completes successfully
5752 * eSIR_FAILURE is some problem is encountered
5753 */
5754tSirRetStatus limSendAddBARsp( tpAniSirGlobal pMac,
5755 tpLimMlmAddBARsp pMlmAddBARsp,
5756 tpPESession psessionEntry)
5757{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305758 tDot11fAddBARsp frmAddBARsp;
5759 tANI_U8 *pAddBARspBuffer = NULL;
5760 tpSirMacMgmtHdr pMacHdr;
5761 tANI_U32 frameLen = 0, nStatus, nPayload;
5762 tSirRetStatus statusCode;
5763 eHalStatus halStatus;
5764 void *pPacket;
5765 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005766
5767 if(NULL == psessionEntry)
5768 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005769 PELOGE(limLog(pMac, LOGE, FL("Session entry is NULL!!!"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07005770 return eSIR_FAILURE;
5771 }
5772
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305773 vos_mem_set( (void *) &frmAddBARsp, sizeof( frmAddBARsp ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005774
5775 // Category - 3 (BA)
5776 frmAddBARsp.Category.category = SIR_MAC_ACTION_BLKACK;
5777 // Action - 1 (ADDBA Rsp)
5778 frmAddBARsp.Action.action = SIR_MAC_BLKACK_ADD_RSP;
5779
5780 // Should be same as the one we received in the ADDBA Req
5781 frmAddBARsp.DialogToken.token = pMlmAddBARsp->baDialogToken;
5782
5783 // ADDBA Req status
5784 frmAddBARsp.Status.status = pMlmAddBARsp->addBAResultCode;
5785
5786 // Fill the ADDBA Parameter Set as provided by caller
5787 frmAddBARsp.AddBAParameterSet.tid = pMlmAddBARsp->baTID;
5788 frmAddBARsp.AddBAParameterSet.policy = pMlmAddBARsp->baPolicy;
5789 frmAddBARsp.AddBAParameterSet.bufferSize = pMlmAddBARsp->baBufferSize;
krunal soni5afa96c2013-09-06 22:19:02 -07005790
5791 if(psessionEntry->isAmsduSupportInAMPDU)
5792 {
5793 frmAddBARsp.AddBAParameterSet.amsduSupported =
5794 psessionEntry->amsduSupportedInBA;
5795 }
5796 else
5797 {
5798 frmAddBARsp.AddBAParameterSet.amsduSupported = 0;
5799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005800
5801 // BA timeout
5802 // 0 - indicates no BA timeout
5803 frmAddBARsp.BATimeout.timeout = pMlmAddBARsp->baTimeout;
5804
5805 nStatus = dot11fGetPackedAddBARspSize( pMac, &frmAddBARsp, &nPayload );
5806
5807 if( DOT11F_FAILED( nStatus ))
5808 {
5809 limLog( pMac, LOGW,
5810 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005811 "an ADDBA Response (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 nStatus );
5813
5814 // We'll fall back on the worst case scenario:
5815 nPayload = sizeof( tDot11fAddBARsp );
5816 }
5817 else if( DOT11F_WARNED( nStatus ))
5818 {
5819 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005820 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005821 "the packed size for an ADDBA Rsp (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 nStatus );
5823 }
5824
5825 // Need to allocate a buffer for ADDBA AF
5826 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
5827
5828 // Allocate shared memory
5829 if( eHAL_STATUS_SUCCESS !=
5830 (halStatus = palPktAlloc( pMac->hHdd,
5831 HAL_TXRX_FRM_802_11_MGMT,
5832 (tANI_U16) frameLen,
5833 (void **) &pAddBARspBuffer,
5834 (void **) &pPacket )))
5835 {
5836 // Log error
5837 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005838 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 frameLen,
5840 halStatus );
5841
5842 statusCode = eSIR_MEM_ALLOC_FAILED;
5843 goto returnAfterError;
5844 }
5845
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05305846 vos_mem_set( (void *) pAddBARspBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005847
5848 // Copy necessary info to BD
5849 if( eSIR_SUCCESS !=
5850 (statusCode = limPopulateMacHeader( pMac,
5851 pAddBARspBuffer,
5852 SIR_MAC_MGMT_FRAME,
5853 SIR_MAC_MGMT_ACTION,
5854 pMlmAddBARsp->peerMacAddr,psessionEntry->selfMacAddr)))
5855 goto returnAfterError;
5856
5857 // Update A3 with the BSSID
5858
5859 pMacHdr = ( tpSirMacMgmtHdr ) pAddBARspBuffer;
5860
5861 #if 0
5862 cfgLen = SIR_MAC_ADDR_LENGTH;
5863 if( eSIR_SUCCESS != wlan_cfgGetStr( pMac,
5864 WNI_CFG_BSSID,
5865 (tANI_U8 *) pMacHdr->bssId,
5866 &cfgLen ))
5867 {
5868 limLog( pMac, LOGP,
5869 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005870 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07005871
5872 // FIXME - Need to convert to tSirRetStatus
5873 statusCode = eSIR_FAILURE;
5874 goto returnAfterError;
5875 }
5876 #endif // TO SUPPORT BT-AMP
5877 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
5878
Chet Lanctot186b5732013-03-18 10:26:30 -07005879#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07005880 limSetProtectedBit(pMac, psessionEntry, pMlmAddBARsp->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07005881#endif
5882
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 // Now, we're ready to "pack" the frames
5884 nStatus = dot11fPackAddBARsp( pMac,
5885 &frmAddBARsp,
5886 pAddBARspBuffer + sizeof( tSirMacMgmtHdr ),
5887 nPayload,
5888 &nPayload );
5889
5890 if( DOT11F_FAILED( nStatus ))
5891 {
5892 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005893 FL( "Failed to pack an ADDBA Rsp (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005894 nStatus );
5895
5896 // FIXME - Need to convert to tSirRetStatus
5897 statusCode = eSIR_FAILURE;
5898 goto returnAfterError;
5899 }
5900 else if( DOT11F_WARNED( nStatus ))
5901 {
5902 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08005903 FL( "There were warnings while packing an ADDBA Rsp (0x%08x)." ),
5904 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 }
5906
Abhishek Singh02d9f6c2014-05-12 14:07:53 +05305907 limLog( pMac, LOG1, FL( "Sending an ADDBA RSP to "MAC_ADDRESS_STR " with"
5908 " tid = %d policy = %d buffsize = %d"
5909 " amsduSupported = %d status %d"),
5910 MAC_ADDR_ARRAY(pMlmAddBARsp->peerMacAddr),
5911 frmAddBARsp.AddBAParameterSet.tid,
5912 frmAddBARsp.AddBAParameterSet.policy,
5913 frmAddBARsp.AddBAParameterSet.bufferSize,
5914 frmAddBARsp.AddBAParameterSet.amsduSupported,
5915 frmAddBARsp.Status.status);
5916
Jeff Johnson295189b2012-06-20 16:38:30 -07005917
5918 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
5920 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07005921 )
5922 {
5923 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
5924 }
5925
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05305926 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
5927 psessionEntry->peSessionId,
5928 pMacHdr->fc.subType));
5929 halStatus = halTxFrame( pMac,
5930 pPacket,
5931 (tANI_U16) frameLen,
5932 HAL_TXRX_FRM_802_11_MGMT,
5933 ANI_TXDIR_TODS,
5934 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
5935 limTxComplete,
5936 pAddBARspBuffer, txFlag );
5937 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
5938 psessionEntry->peSessionId,
5939 halStatus));
5940 if( eHAL_STATUS_SUCCESS != halStatus )
5941 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07005943 FL( "halTxFrame FAILED! Status [%d]" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07005944 halStatus );
5945
5946 // FIXME - HAL error codes are different from PE error
5947 // codes!! And, this routine is returning tSirRetStatus
5948 statusCode = eSIR_FAILURE;
5949 //Pkt will be freed up by the callback
5950 return statusCode;
5951 }
5952 else
5953 return eSIR_SUCCESS;
5954
5955 returnAfterError:
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 // Release buffer, if allocated
5957 if( NULL != pAddBARspBuffer )
5958 palPktFree( pMac->hHdd,
5959 HAL_TXRX_FRM_802_11_MGMT,
5960 (void *) pAddBARspBuffer,
5961 (void *) pPacket );
5962
5963 return statusCode;
5964}
5965
5966/**
5967 * \brief Send a DELBA Indication Action Frame to peer
5968 *
5969 * \sa limSendDelBAInd
5970 *
5971 * \param pMac The global tpAniSirGlobal object
5972 *
5973 * \param peerMacAddr MAC Address of peer
5974 *
5975 * \param reasonCode Reason for the DELBA notification
5976 *
5977 * \param pBAParameterSet The DELBA Parameter Set.
5978 * This identifies the TID for which the BA session is
5979 * being deleted.
5980 *
5981 * \return eSIR_SUCCESS if setup completes successfully
5982 * eSIR_FAILURE is some problem is encountered
5983 */
5984tSirRetStatus limSendDelBAInd( tpAniSirGlobal pMac,
5985 tpLimMlmDelBAReq pMlmDelBAReq,tpPESession psessionEntry)
5986{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305987 tDot11fDelBAInd frmDelBAInd;
5988 tANI_U8 *pDelBAIndBuffer = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 //tANI_U32 val;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05305990 tpSirMacMgmtHdr pMacHdr;
5991 tANI_U32 frameLen = 0, nStatus, nPayload;
5992 tSirRetStatus statusCode;
5993 eHalStatus halStatus;
5994 void *pPacket;
5995 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005996
5997 if(NULL == psessionEntry)
5998 {
5999 return eSIR_FAILURE;
6000 }
6001
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306002 vos_mem_set( (void *) &frmDelBAInd, sizeof( frmDelBAInd ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006003
6004 // Category - 3 (BA)
6005 frmDelBAInd.Category.category = SIR_MAC_ACTION_BLKACK;
6006 // Action - 2 (DELBA)
6007 frmDelBAInd.Action.action = SIR_MAC_BLKACK_DEL;
6008
6009 // Fill the DELBA Parameter Set as provided by caller
6010 frmDelBAInd.DelBAParameterSet.tid = pMlmDelBAReq->baTID;
6011 frmDelBAInd.DelBAParameterSet.initiator = pMlmDelBAReq->baDirection;
6012
6013 // BA Starting Sequence Number
6014 // Fragment number will always be zero
6015 frmDelBAInd.Reason.code = pMlmDelBAReq->delBAReasonCode;
6016
6017 nStatus = dot11fGetPackedDelBAIndSize( pMac, &frmDelBAInd, &nPayload );
6018
6019 if( DOT11F_FAILED( nStatus ))
6020 {
6021 limLog( pMac, LOGW,
6022 FL( "Failed to calculate the packed size for "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006023 "an DELBA Indication (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006024 nStatus );
6025
6026 // We'll fall back on the worst case scenario:
6027 nPayload = sizeof( tDot11fDelBAInd );
6028 }
6029 else if( DOT11F_WARNED( nStatus ))
6030 {
6031 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006032 FL( "There were warnings while calculating "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006033 "the packed size for an DELBA Ind (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 nStatus );
6035 }
6036
6037 // Add the MGMT header to frame length
6038 frameLen = nPayload + sizeof( tSirMacMgmtHdr );
6039
6040 // Allocate shared memory
6041 if( eHAL_STATUS_SUCCESS !=
6042 (halStatus = palPktAlloc( pMac->hHdd,
6043 HAL_TXRX_FRM_802_11_MGMT,
6044 (tANI_U16) frameLen,
6045 (void **) &pDelBAIndBuffer,
6046 (void **) &pPacket )))
6047 {
6048 // Log error
6049 limLog( pMac, LOGP,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006050 FL("palPktAlloc FAILED! Length [%d], Status [%d]"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 frameLen,
6052 halStatus );
6053
6054 statusCode = eSIR_MEM_ALLOC_FAILED;
6055 goto returnAfterError;
6056 }
6057
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306058 vos_mem_set( (void *) pDelBAIndBuffer, frameLen, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006059
6060 // Copy necessary info to BD
6061 if( eSIR_SUCCESS !=
6062 (statusCode = limPopulateMacHeader( pMac,
6063 pDelBAIndBuffer,
6064 SIR_MAC_MGMT_FRAME,
6065 SIR_MAC_MGMT_ACTION,
6066 pMlmDelBAReq->peerMacAddr,psessionEntry->selfMacAddr)))
6067 goto returnAfterError;
6068
6069 // Update A3 with the BSSID
6070 pMacHdr = ( tpSirMacMgmtHdr ) pDelBAIndBuffer;
6071
6072 #if 0
6073 cfgLen = SIR_MAC_ADDR_LENGTH;
6074 if( eSIR_SUCCESS != cfgGetStr( pMac,
6075 WNI_CFG_BSSID,
6076 (tANI_U8 *) pMacHdr->bssId,
6077 &cfgLen ))
6078 {
6079 limLog( pMac, LOGP,
6080 FL( "Failed to retrieve WNI_CFG_BSSID while"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006081 "sending an ACTION Frame" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006082
6083 // FIXME - Need to convert to tSirRetStatus
6084 statusCode = eSIR_FAILURE;
6085 goto returnAfterError;
6086 }
6087 #endif //TO SUPPORT BT-AMP
6088 sirCopyMacAddr(pMacHdr->bssId,psessionEntry->bssId);
6089
Chet Lanctot186b5732013-03-18 10:26:30 -07006090#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006091 limSetProtectedBit(pMac, psessionEntry, pMlmDelBAReq->peerMacAddr, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006092#endif
6093
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 // Now, we're ready to "pack" the frames
6095 nStatus = dot11fPackDelBAInd( pMac,
6096 &frmDelBAInd,
6097 pDelBAIndBuffer + sizeof( tSirMacMgmtHdr ),
6098 nPayload,
6099 &nPayload );
6100
6101 if( DOT11F_FAILED( nStatus ))
6102 {
6103 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006104 FL( "Failed to pack an DELBA Ind (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006105 nStatus );
6106
6107 // FIXME - Need to convert to tSirRetStatus
6108 statusCode = eSIR_FAILURE;
6109 goto returnAfterError;
6110 }
6111 else if( DOT11F_WARNED( nStatus ))
6112 {
6113 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006114 FL( "There were warnings while packing an DELBA Ind (0x%08x)." ),
6115 nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 }
6117
Abhishek Singh1f6e6532014-06-05 17:35:08 +05306118 limLog( pMac, LOG1,
6119 FL( "Sending a DELBA IND to: "MAC_ADDRESS_STR" with Tid = %d"
6120 " initiator = %d reason = %d" ),
6121 MAC_ADDR_ARRAY(pMlmDelBAReq->peerMacAddr),
6122 frmDelBAInd.DelBAParameterSet.tid,
6123 frmDelBAInd.DelBAParameterSet.initiator,
6124 frmDelBAInd.Reason.code);
6125
Jeff Johnson295189b2012-06-20 16:38:30 -07006126
6127 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006128 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6129 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 )
6131 {
6132 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6133 }
6134
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306135 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6136 psessionEntry->peSessionId,
6137 pMacHdr->fc.subType));
6138 halStatus = halTxFrame( pMac,
6139 pPacket,
6140 (tANI_U16) frameLen,
6141 HAL_TXRX_FRM_802_11_MGMT,
6142 ANI_TXDIR_TODS,
6143 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6144 limTxComplete,
6145 pDelBAIndBuffer, txFlag );
6146 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6147 psessionEntry->peSessionId,
6148 halStatus));
6149 if( eHAL_STATUS_SUCCESS != halStatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006151 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halStatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 statusCode = eSIR_FAILURE;
6153 //Pkt will be freed up by the callback
6154 return statusCode;
6155 }
6156 else
6157 return eSIR_SUCCESS;
6158
6159 returnAfterError:
6160
6161 // Release buffer, if allocated
6162 if( NULL != pDelBAIndBuffer )
6163 palPktFree( pMac->hHdd,
6164 HAL_TXRX_FRM_802_11_MGMT,
6165 (void *) pDelBAIndBuffer,
6166 (void *) pPacket );
6167
6168 return statusCode;
6169}
6170
6171#if defined WLAN_FEATURE_VOWIFI
6172
6173/**
6174 * \brief Send a Neighbor Report Request Action frame
6175 *
6176 *
6177 * \param pMac Pointer to the global MAC structure
6178 *
6179 * \param pNeighborReq Address of a tSirMacNeighborReportReq
6180 *
6181 * \param peer mac address of peer station.
6182 *
6183 * \param psessionEntry address of session entry.
6184 *
6185 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6186 *
6187 *
6188 */
6189
6190tSirRetStatus
6191limSendNeighborReportRequestFrame(tpAniSirGlobal pMac,
6192 tpSirMacNeighborReportReq pNeighborReq,
6193 tSirMacAddr peer,
6194 tpPESession psessionEntry
6195 )
6196{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306197 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 tDot11fNeighborReportRequest frm;
6199 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306200 tpSirMacMgmtHdr pMacHdr;
6201 tANI_U32 nBytes, nPayload, nStatus;
6202 void *pPacket;
6203 eHalStatus halstatus;
6204 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006205
6206 if ( psessionEntry == NULL )
6207 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006208 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Neighbor Report request action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 return eSIR_FAILURE;
6210 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306211 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006212
6213 frm.Category.category = SIR_MAC_ACTION_RRM;
6214 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
6215 frm.DialogToken.token = pNeighborReq->dialogToken;
6216
6217
6218 if( pNeighborReq->ssid_present )
6219 {
6220 PopulateDot11fSSID( pMac, &pNeighborReq->ssid, &frm.SSID );
6221 }
6222
6223 nStatus = dot11fGetPackedNeighborReportRequestSize( pMac, &frm, &nPayload );
6224 if ( DOT11F_FAILED( nStatus ) )
6225 {
6226 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006227 "or a Neighbor Report Request(0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 nStatus );
6229 // We'll fall back on the worst case scenario:
6230 nPayload = sizeof( tDot11fNeighborReportRequest );
6231 }
6232 else if ( DOT11F_WARNED( nStatus ) )
6233 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006234 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 "the packed size for a Neighbor Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006236 "ort Request(0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 }
6238
6239 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6240
6241 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6242 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6243 {
6244 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Neighbor "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006245 "Report Request."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 return eSIR_FAILURE;
6247 }
6248
6249 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306250 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006251
6252 // Copy necessary info to BD
6253 if( eSIR_SUCCESS !=
6254 (statusCode = limPopulateMacHeader( pMac,
6255 pFrame,
6256 SIR_MAC_MGMT_FRAME,
6257 SIR_MAC_MGMT_ACTION,
6258 peer, psessionEntry->selfMacAddr)))
6259 goto returnAfterError;
6260
6261 // Update A3 with the BSSID
6262 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6263
6264 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6265
Chet Lanctot186b5732013-03-18 10:26:30 -07006266#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006267 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006268#endif
6269
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 // Now, we're ready to "pack" the frames
6271 nStatus = dot11fPackNeighborReportRequest( pMac,
6272 &frm,
6273 pFrame + sizeof( tSirMacMgmtHdr ),
6274 nPayload,
6275 &nPayload );
6276
6277 if( DOT11F_FAILED( nStatus ))
6278 {
6279 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006280 FL( "Failed to pack an Neighbor Report Request (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006281 nStatus );
6282
6283 // FIXME - Need to convert to tSirRetStatus
6284 statusCode = eSIR_FAILURE;
6285 goto returnAfterError;
6286 }
6287 else if( DOT11F_WARNED( nStatus ))
6288 {
6289 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006290 FL( "There were warnings while packing Neighbor Report "
6291 "Request (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 }
6293
6294 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006295 FL( "Sending a Neighbor Report Request to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006296 limPrintMacAddr( pMac, peer, LOGW );
6297
6298 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6300 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 )
6302 {
6303 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6304 }
6305
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306306 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6307 psessionEntry->peSessionId,
6308 pMacHdr->fc.subType));
6309 halstatus = halTxFrame( pMac,
6310 pPacket,
6311 (tANI_U16) nBytes,
6312 HAL_TXRX_FRM_802_11_MGMT,
6313 ANI_TXDIR_TODS,
6314 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6315 limTxComplete,
6316 pFrame, txFlag );
6317 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6318 psessionEntry->peSessionId,
6319 halstatus));
6320 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006322 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006323 statusCode = eSIR_FAILURE;
6324 //Pkt will be freed up by the callback
6325 return statusCode;
6326 }
6327 else
6328 return eSIR_SUCCESS;
6329
6330returnAfterError:
6331 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6332
6333 return statusCode;
6334} // End limSendNeighborReportRequestFrame.
6335
6336/**
6337 * \brief Send a Link Report Action frame
6338 *
6339 *
6340 * \param pMac Pointer to the global MAC structure
6341 *
6342 * \param pLinkReport Address of a tSirMacLinkReport
6343 *
6344 * \param peer mac address of peer station.
6345 *
6346 * \param psessionEntry address of session entry.
6347 *
6348 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6349 *
6350 *
6351 */
6352
6353tSirRetStatus
6354limSendLinkReportActionFrame(tpAniSirGlobal pMac,
6355 tpSirMacLinkReport pLinkReport,
6356 tSirMacAddr peer,
6357 tpPESession psessionEntry
6358 )
6359{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306360 tSirRetStatus statusCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 tDot11fLinkMeasurementReport frm;
6362 tANI_U8 *pFrame;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306363 tpSirMacMgmtHdr pMacHdr;
6364 tANI_U32 nBytes, nPayload, nStatus;
6365 void *pPacket;
6366 eHalStatus halstatus;
6367 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006368
6369
6370 if ( psessionEntry == NULL )
6371 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006372 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Link Report action frame") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 return eSIR_FAILURE;
6374 }
6375
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306376 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006377
6378 frm.Category.category = SIR_MAC_ACTION_RRM;
6379 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
6380 frm.DialogToken.token = pLinkReport->dialogToken;
6381
6382
6383 //IEEE Std. 802.11 7.3.2.18. for the report element.
6384 //Even though TPC report an IE, it is represented using fixed fields since it is positioned
6385 //in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4
6386 //and frame parser always expects IEs to come after all fixed fields. It is easier to handle
6387 //such case this way than changing the frame parser.
6388 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
6389 frm.TPCEleLen.TPCLen = 2;
6390 frm.TxPower.txPower = pLinkReport->txPower;
6391 frm.LinkMargin.linkMargin = 0;
6392
6393 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
6394 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
6395 frm.RCPI.rcpi = pLinkReport->rcpi;
6396 frm.RSNI.rsni = pLinkReport->rsni;
6397
6398 nStatus = dot11fGetPackedLinkMeasurementReportSize( pMac, &frm, &nPayload );
6399 if ( DOT11F_FAILED( nStatus ) )
6400 {
6401 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006402 "or a Link Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 nStatus );
6404 // We'll fall back on the worst case scenario:
6405 nPayload = sizeof( tDot11fLinkMeasurementReport );
6406 }
6407 else if ( DOT11F_WARNED( nStatus ) )
6408 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006409 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 "the packed size for a Link Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006411 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 }
6413
6414 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6415
6416 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6417 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6418 {
6419 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Link "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006420 "Report."), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 return eSIR_FAILURE;
6422 }
6423
6424 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306425 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006426
6427 // Copy necessary info to BD
6428 if( eSIR_SUCCESS !=
6429 (statusCode = limPopulateMacHeader( pMac,
6430 pFrame,
6431 SIR_MAC_MGMT_FRAME,
6432 SIR_MAC_MGMT_ACTION,
6433 peer, psessionEntry->selfMacAddr)))
6434 goto returnAfterError;
6435
6436 // Update A3 with the BSSID
6437 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6438
6439 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6440
Chet Lanctot186b5732013-03-18 10:26:30 -07006441#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006442 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006443#endif
6444
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 // Now, we're ready to "pack" the frames
6446 nStatus = dot11fPackLinkMeasurementReport( pMac,
6447 &frm,
6448 pFrame + sizeof( tSirMacMgmtHdr ),
6449 nPayload,
6450 &nPayload );
6451
6452 if( DOT11F_FAILED( nStatus ))
6453 {
6454 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006455 FL( "Failed to pack an Link Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006456 nStatus );
6457
6458 // FIXME - Need to convert to tSirRetStatus
6459 statusCode = eSIR_FAILURE;
6460 goto returnAfterError;
6461 }
6462 else if( DOT11F_WARNED( nStatus ))
6463 {
6464 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006465 FL( "There were warnings while packing Link Report (0x%08x)." ),
6466 nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 }
6468
6469 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006470 FL( "Sending a Link Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006471 limPrintMacAddr( pMac, peer, LOGW );
6472
6473 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6475 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006476 )
6477 {
6478 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6479 }
6480
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306481 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6482 psessionEntry->peSessionId,
6483 pMacHdr->fc.subType));
6484 halstatus = halTxFrame( pMac,
6485 pPacket,
6486 (tANI_U16) nBytes,
6487 HAL_TXRX_FRM_802_11_MGMT,
6488 ANI_TXDIR_TODS,
6489 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6490 limTxComplete,
6491 pFrame, txFlag );
6492 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6493 psessionEntry->peSessionId,
6494 halstatus));
6495 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006497 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006498 statusCode = eSIR_FAILURE;
6499 //Pkt will be freed up by the callback
6500 return statusCode;
6501 }
6502 else
6503 return eSIR_SUCCESS;
6504
6505returnAfterError:
6506 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6507
6508 return statusCode;
6509} // End limSendLinkReportActionFrame.
6510
6511/**
6512 * \brief Send a Beacon Report Action frame
6513 *
6514 *
6515 * \param pMac Pointer to the global MAC structure
6516 *
6517 * \param dialog_token dialog token to be used in the action frame.
6518 *
6519 * \param num_report number of reports in pRRMReport.
6520 *
6521 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
6522 *
6523 * \param peer mac address of peer station.
6524 *
6525 * \param psessionEntry address of session entry.
6526 *
6527 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
6528 *
6529 *
6530 */
6531
6532tSirRetStatus
6533limSendRadioMeasureReportActionFrame(tpAniSirGlobal pMac,
6534 tANI_U8 dialog_token,
6535 tANI_U8 num_report,
6536 tpSirMacRadioMeasureReport pRRMReport,
6537 tSirMacAddr peer,
6538 tpPESession psessionEntry
6539 )
6540{
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306541 tSirRetStatus statusCode = eSIR_SUCCESS;
6542 tANI_U8 *pFrame;
6543 tpSirMacMgmtHdr pMacHdr;
6544 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006545 void *pPacket;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306546 eHalStatus halstatus;
6547 tANI_U8 i;
6548 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006549
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006550 tDot11fRadioMeasurementReport *frm =
6551 vos_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
6552 if (!frm) {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006553 limLog( pMac, LOGE, FL("Not enough memory to allocate tDot11fRadioMeasurementReport") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006554 return eSIR_FAILURE;
6555 }
6556
Jeff Johnson295189b2012-06-20 16:38:30 -07006557 if ( psessionEntry == NULL )
6558 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006559 limLog( pMac, LOGE, FL("(psession == NULL) in Request to send Beacon Report action frame") );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006560 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 return eSIR_FAILURE;
6562 }
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306563 vos_mem_set( ( tANI_U8* )frm, sizeof( *frm ), 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006564
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006565 frm->Category.category = SIR_MAC_ACTION_RRM;
6566 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
6567 frm->DialogToken.token = dialog_token;
Jeff Johnson295189b2012-06-20 16:38:30 -07006568
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006569 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 -07006570
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006571 for( i = 0 ; i < frm->num_MeasurementReport ; i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006573 frm->MeasurementReport[i].type = pRRMReport[i].type;
6574 frm->MeasurementReport[i].token = pRRMReport[i].token;
6575 frm->MeasurementReport[i].late = 0; //IEEE 802.11k section 7.3.22. (always zero in rrm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 switch( pRRMReport[i].type )
6577 {
6578 case SIR_MAC_RRM_BEACON_TYPE:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006579 PopulateDot11fBeaconReport( pMac, &frm->MeasurementReport[i], &pRRMReport[i].report.beaconReport );
6580 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6581 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
6582 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 break;
6584 default:
Gopichand Nakkala72717fd2013-02-08 12:23:45 +05306585 frm->MeasurementReport[i].incapable = pRRMReport[i].incapable;
6586 frm->MeasurementReport[i].refused = pRRMReport[i].refused;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006587 frm->MeasurementReport[i].present = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 break;
6589 }
6590 }
6591
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006592 nStatus = dot11fGetPackedRadioMeasurementReportSize( pMac, frm, &nPayload );
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 if ( DOT11F_FAILED( nStatus ) )
6594 {
6595 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006596 "or a Radio Measure Report (0x%08x)."),
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 nStatus );
6598 // We'll fall back on the worst case scenario:
6599 nPayload = sizeof( tDot11fLinkMeasurementReport );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006600 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 return eSIR_FAILURE;
6602 }
6603 else if ( DOT11F_WARNED( nStatus ) )
6604 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006605 limLog( pMac, LOGW, FL("There were warnings while calculating "
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 "the packed size for a Radio Measure Rep"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006607 "ort (0x%08x)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07006608 }
6609
6610 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6611
6612 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( tANI_U16 )nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6613 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6614 {
6615 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a Radio Measure "
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006616 "Report."), nBytes );
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006617 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 return eSIR_FAILURE;
6619 }
6620
6621 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306622 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006623
6624 // Copy necessary info to BD
6625 if( eSIR_SUCCESS !=
6626 (statusCode = limPopulateMacHeader( pMac,
6627 pFrame,
6628 SIR_MAC_MGMT_FRAME,
6629 SIR_MAC_MGMT_ACTION,
6630 peer, psessionEntry->selfMacAddr)))
6631 goto returnAfterError;
6632
6633 // Update A3 with the BSSID
6634 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6635
6636 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6637
Chet Lanctot186b5732013-03-18 10:26:30 -07006638#ifdef WLAN_FEATURE_11W
Chet Lanctot4b9abd72013-06-27 11:14:56 -07006639 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Chet Lanctot186b5732013-03-18 10:26:30 -07006640#endif
6641
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 // Now, we're ready to "pack" the frames
6643 nStatus = dot11fPackRadioMeasurementReport( pMac,
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006644 frm,
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 pFrame + sizeof( tSirMacMgmtHdr ),
6646 nPayload,
6647 &nPayload );
6648
6649 if( DOT11F_FAILED( nStatus ))
6650 {
6651 limLog( pMac, LOGE,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006652 FL( "Failed to pack an Radio Measure Report (0x%08x)." ),
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 nStatus );
6654
6655 // FIXME - Need to convert to tSirRetStatus
6656 statusCode = eSIR_FAILURE;
6657 goto returnAfterError;
6658 }
6659 else if( DOT11F_WARNED( nStatus ))
6660 {
6661 limLog( pMac, LOGW,
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006662 FL( "There were warnings while packing Radio "
6663 "Measure Report (0x%08x)." ), nStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }
6665
6666 limLog( pMac, LOGW,
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006667 FL( "Sending a Radio Measure Report to " ));
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 limPrintMacAddr( pMac, peer, LOGW );
6669
6670 if( ( SIR_BAND_5_GHZ == limGetRFBand(psessionEntry->currentOperChannel))
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6672 ( psessionEntry->pePersona == VOS_P2P_GO_MODE)
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 )
6674 {
6675 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6676 }
6677
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306678 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6679 psessionEntry->peSessionId,
6680 pMacHdr->fc.subType));
6681 halstatus = halTxFrame( pMac,
6682 pPacket,
6683 (tANI_U16) nBytes,
6684 HAL_TXRX_FRM_802_11_MGMT,
6685 ANI_TXDIR_TODS,
6686 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6687 limTxComplete,
6688 pFrame, txFlag );
6689 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
6690 psessionEntry->peSessionId,
6691 halstatus));
6692 if( eHAL_STATUS_SUCCESS != halstatus )
Jeff Johnson295189b2012-06-20 16:38:30 -07006693 {
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006694 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 statusCode = eSIR_FAILURE;
6696 //Pkt will be freed up by the callback
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006697 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698 return statusCode;
6699 }
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006700 else {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006701 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006702 return eSIR_SUCCESS;
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07006703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006704
6705returnAfterError:
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07006706 vos_mem_free(frm);
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
Jeff Johnson295189b2012-06-20 16:38:30 -07006708 return statusCode;
6709} // End limSendBeaconReportActionFrame.
6710
6711#endif
6712
6713#ifdef WLAN_FEATURE_11W
6714/**
Chet Lanctot8cecea22014-02-11 19:09:36 -08006715 * \brief Send SA query request action frame to peer
6716 *
6717 * \sa limSendSaQueryRequestFrame
6718 *
6719 *
6720 * \param pMac The global tpAniSirGlobal object
6721 *
6722 * \param transId Transaction identifier
6723 *
6724 * \param peer The Mac address of the station to which this action frame is addressed
6725 *
6726 * \param psessionEntry The PE session entry
6727 *
6728 * \return eSIR_SUCCESS if setup completes successfully
6729 * eSIR_FAILURE is some problem is encountered
6730 */
6731
6732tSirRetStatus limSendSaQueryRequestFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
6733 tSirMacAddr peer, tpPESession psessionEntry )
6734{
6735
6736 tDot11fSaQueryReq frm; // SA query request action frame
6737 tANI_U8 *pFrame;
6738 tSirRetStatus nSirStatus;
6739 tpSirMacMgmtHdr pMacHdr;
6740 tANI_U32 nBytes, nPayload, nStatus;
6741 void *pPacket;
6742 eHalStatus halstatus;
6743 tANI_U8 txFlag = 0;
6744
6745 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
6746 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6747 /* 11w action field is :
6748 action: 0 --> SA Query Request action frame
6749 action: 1 --> SA Query Response action frame */
6750 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
6751 /* 11w SA Query Request transId */
6752 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
6753
6754 nStatus = dot11fGetPackedSaQueryReqSize(pMac, &frm, &nPayload);
6755 if ( DOT11F_FAILED( nStatus ) )
6756 {
6757 limLog( pMac, LOGP, FL("Failed to calculate the packed size "
6758 "for an SA Query Request (0x%08x)."),
6759 nStatus );
6760 // We'll fall back on the worst case scenario:
6761 nPayload = sizeof( tDot11fSaQueryReq );
6762 }
6763 else if ( DOT11F_WARNED( nStatus ) )
6764 {
6765 limLog( pMac, LOGW, FL("There were warnings while calculating "
6766 "the packed size for an SA Query Request"
6767 " (0x%08x)."), nStatus );
6768 }
6769
6770 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6771 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6772 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6773 {
6774 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA Query Request "
6775 "action frame"), nBytes );
6776 return eSIR_FAILURE;
6777 }
6778
6779 // Paranoia:
6780 vos_mem_set( pFrame, nBytes, 0 );
6781
6782 // Copy necessary info to BD
6783 nSirStatus = limPopulateMacHeader( pMac,
6784 pFrame,
6785 SIR_MAC_MGMT_FRAME,
6786 SIR_MAC_MGMT_ACTION,
6787 peer, psessionEntry->selfMacAddr );
6788 if ( eSIR_SUCCESS != nSirStatus )
6789 goto returnAfterError;
6790
6791 // Update A3 with the BSSID
6792 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6793
6794 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
6795
6796 // Since this is a SA Query Request, set the "protect" (aka WEP) bit
6797 // in the FC
6798 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
6799
6800 // Pack 11w SA Query Request frame
6801 nStatus = dot11fPackSaQueryReq( pMac,
6802 &frm,
6803 pFrame + sizeof( tSirMacMgmtHdr ),
6804 nPayload,
6805 &nPayload );
6806
6807 if ( DOT11F_FAILED( nStatus ))
6808 {
6809 limLog( pMac, LOGE,
6810 FL( "Failed to pack an SA Query Request (0x%08x)." ),
6811 nStatus );
6812 // FIXME - Need to convert to tSirRetStatus
6813 nSirStatus = eSIR_FAILURE;
6814 goto returnAfterError;
6815 }
6816 else if ( DOT11F_WARNED( nStatus ))
6817 {
6818 limLog( pMac, LOGW,
6819 FL( "There were warnings while packing SA Query Request (0x%08x)." ),
6820 nStatus);
6821 }
6822
6823 limLog( pMac, LOG1,
6824 FL( "Sending an SA Query Request to " ));
6825 limPrintMacAddr( pMac, peer, LOG1 );
6826 limPrintMacAddr( pMac, peer, LOGE );
6827 limLog( pMac, LOGE,
6828 FL( "Sending an SA Query Request from " ));
6829 limPrintMacAddr( pMac, psessionEntry->selfMacAddr, LOGE );
6830
6831 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
6832#ifdef WLAN_FEATURE_P2P
6833 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6834 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
6835#endif
6836 )
6837 {
6838 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6839 }
6840
6841 halstatus = halTxFrame( pMac,
6842 pPacket,
6843 (tANI_U16) nBytes,
6844 HAL_TXRX_FRM_802_11_MGMT,
6845 ANI_TXDIR_TODS,
6846 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6847 limTxComplete,
6848 pFrame, txFlag );
6849 if ( eHAL_STATUS_SUCCESS != halstatus )
6850 {
6851 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
6852 nSirStatus = eSIR_FAILURE;
6853 //Pkt will be freed up by the callback
6854 return nSirStatus;
6855 }
6856 else {
6857 return eSIR_SUCCESS;
6858 }
6859
6860returnAfterError:
6861 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
6862 return nSirStatus;
6863} // End limSendSaQueryRequestFrame
6864
6865/**
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 * \brief Send SA query response action frame to peer
6867 *
6868 * \sa limSendSaQueryResponseFrame
6869 *
6870 *
6871 * \param pMac The global tpAniSirGlobal object
6872 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006873 * \param transId Transaction identifier received in SA query request action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 *
Chet Lanctot186b5732013-03-18 10:26:30 -07006875 * \param peer The Mac address of the AP to which this action frame is addressed
6876 *
6877 * \param psessionEntry The PE session entry
Jeff Johnson295189b2012-06-20 16:38:30 -07006878 *
6879 * \return eSIR_SUCCESS if setup completes successfully
6880 * eSIR_FAILURE is some problem is encountered
6881 */
6882
Chet Lanctot186b5732013-03-18 10:26:30 -07006883tSirRetStatus limSendSaQueryResponseFrame( tpAniSirGlobal pMac, tANI_U8 *transId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006884tSirMacAddr peer,tpPESession psessionEntry)
6885{
6886
Chet Lanctot186b5732013-03-18 10:26:30 -07006887 tDot11fSaQueryRsp frm; // SA query reponse action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 tANI_U8 *pFrame;
6889 tSirRetStatus nSirStatus;
6890 tpSirMacMgmtHdr pMacHdr;
Chet Lanctot186b5732013-03-18 10:26:30 -07006891 tANI_U32 nBytes, nPayload, nStatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07006892 void *pPacket;
6893 eHalStatus halstatus;
Kanchanapally, Vidyullathaf9426e52013-12-24 17:28:54 +05306894 tANI_U32 txFlag = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006895
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306896 vos_mem_set( ( tANI_U8* )&frm, sizeof( frm ), 0 );
Chet Lanctot186b5732013-03-18 10:26:30 -07006897 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
6898 /*11w action field is :
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 action: 0 --> SA query request action frame
6900 action: 1 --> SA query response action frame */
Chet Lanctot186b5732013-03-18 10:26:30 -07006901 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
6902 /*11w SA query response transId is same as
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 SA query request transId*/
Chet Lanctot186b5732013-03-18 10:26:30 -07006904 vos_mem_copy( &frm.TransactionId.transId[0], &transId[0], 2 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006905
Chet Lanctot186b5732013-03-18 10:26:30 -07006906 nStatus = dot11fGetPackedSaQueryRspSize(pMac, &frm, &nPayload);
6907 if ( DOT11F_FAILED( nStatus ) )
6908 {
6909 limLog( pMac, LOGP, FL("Failed to calculate the packed size f"
6910 "or a SA Query Response (0x%08x)."),
6911 nStatus );
6912 // We'll fall back on the worst case scenario:
6913 nPayload = sizeof( tDot11fSaQueryRsp );
6914 }
6915 else if ( DOT11F_WARNED( nStatus ) )
6916 {
Jeff Johnson0f4d0bc2013-11-03 17:48:50 -08006917 limLog( pMac, LOGW, FL("There were warnings while calculating "
Chet Lanctot186b5732013-03-18 10:26:30 -07006918 "the packed size for an SA Query Response"
6919 " (0x%08x)."), nStatus );
6920 }
6921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
6923 halstatus = palPktAlloc( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, nBytes, ( void** ) &pFrame, ( void** ) &pPacket );
6924 if ( ! HAL_STATUS_SUCCESS ( halstatus ) )
6925 {
6926 limLog( pMac, LOGP, FL("Failed to allocate %d bytes for a SA query response"
Kiran Kumar Lokere5be73a62013-04-01 18:40:00 -07006927 " action frame"), nBytes );
Jeff Johnson295189b2012-06-20 16:38:30 -07006928 return eSIR_FAILURE;
6929 }
6930
6931 // Paranoia:
Bansidhar Gopalachari12731232013-07-11 10:56:36 +05306932 vos_mem_set( pFrame, nBytes, 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006933
Chet Lanctot186b5732013-03-18 10:26:30 -07006934 // Copy necessary info to BD
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006935 nSirStatus = limPopulateMacHeader( pMac,
Chet Lanctot186b5732013-03-18 10:26:30 -07006936 pFrame,
6937 SIR_MAC_MGMT_FRAME,
6938 SIR_MAC_MGMT_ACTION,
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006939 peer, psessionEntry->selfMacAddr );
6940 if ( eSIR_SUCCESS != nSirStatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07006941 goto returnAfterError;
Jeff Johnson295189b2012-06-20 16:38:30 -07006942
Chet Lanctot186b5732013-03-18 10:26:30 -07006943 // Update A3 with the BSSID
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 pMacHdr = ( tpSirMacMgmtHdr ) pFrame;
6945
Chet Lanctot186b5732013-03-18 10:26:30 -07006946 sirCopyMacAddr( pMacHdr->bssId, psessionEntry->bssId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006947
Chet Lanctot186b5732013-03-18 10:26:30 -07006948 // Since this is a SA Query Response, set the "protect" (aka WEP) bit
6949 // in the FC
Chet Lanctot8cecea22014-02-11 19:09:36 -08006950 limSetProtectedBit(pMac, psessionEntry, peer, pMacHdr);
Jeff Johnson295189b2012-06-20 16:38:30 -07006951
Chet Lanctot186b5732013-03-18 10:26:30 -07006952 // Pack 11w SA query response frame
6953 nStatus = dot11fPackSaQueryRsp( pMac,
6954 &frm,
6955 pFrame + sizeof( tSirMacMgmtHdr ),
6956 nPayload,
6957 &nPayload );
6958
6959 if ( DOT11F_FAILED( nStatus ))
6960 {
6961 limLog( pMac, LOGE,
6962 FL( "Failed to pack an SA Query Response (0x%08x)." ),
6963 nStatus );
6964 // FIXME - Need to convert to tSirRetStatus
6965 nSirStatus = eSIR_FAILURE;
6966 goto returnAfterError;
6967 }
6968 else if ( DOT11F_WARNED( nStatus ))
6969 {
6970 limLog( pMac, LOGW,
6971 FL( "There were warnings while packing SA Query Response (0x%08x)." ),
6972 nStatus);
6973 }
6974
6975 limLog( pMac, LOG1,
6976 FL( "Sending a SA Query Response to " ));
6977 limPrintMacAddr( pMac, peer, LOGW );
6978
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006979 if ( ( SIR_BAND_5_GHZ == limGetRFBand( psessionEntry->currentOperChannel ) )
Chet Lanctot186b5732013-03-18 10:26:30 -07006980#ifdef WLAN_FEATURE_P2P
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006981 || ( psessionEntry->pePersona == VOS_P2P_CLIENT_MODE ) ||
6982 ( psessionEntry->pePersona == VOS_P2P_GO_MODE )
Chet Lanctot186b5732013-03-18 10:26:30 -07006983#endif
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006984 )
6985 {
6986 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
6987 }
Chet Lanctot186b5732013-03-18 10:26:30 -07006988
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05306989 MTRACE(macTrace(pMac, TRACE_CODE_TX_MGMT,
6990 psessionEntry->peSessionId,
6991 pMacHdr->fc.subType));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07006992 halstatus = halTxFrame( pMac,
6993 pPacket,
6994 (tANI_U16) nBytes,
6995 HAL_TXRX_FRM_802_11_MGMT,
6996 ANI_TXDIR_TODS,
6997 7,//SMAC_SWBD_TX_TID_MGMT_HIGH,
6998 limTxComplete,
6999 pFrame, txFlag );
Edhar Mahesh Kumarf956b902013-12-05 09:35:46 +05307000 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE,
7001 psessionEntry->peSessionId,
7002 halstatus));
Chet Lanctotb2b0d552013-03-22 16:58:44 -07007003 if ( eHAL_STATUS_SUCCESS != halstatus )
Chet Lanctot186b5732013-03-18 10:26:30 -07007004 {
7005 PELOGE(limLog( pMac, LOGE, FL( "halTxFrame FAILED! Status [%d]" ), halstatus );)
7006 nSirStatus = eSIR_FAILURE;
7007 //Pkt will be freed up by the callback
7008 return nSirStatus;
7009 }
7010 else {
7011 return eSIR_SUCCESS;
7012 }
7013
7014returnAfterError:
7015 palPktFree( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, ( void* ) pFrame, ( void* ) pPacket );
7016 return nSirStatus;
7017} // End limSendSaQueryResponseFrame
Jeff Johnson295189b2012-06-20 16:38:30 -07007018#endif