blob: 2c896f3d55db7952ccffb300a7f2c765d3a62712 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * \file lim_send_management_frames.c
30 *
31 * \brief Code for preparing and sending 802.11 Management frames
32 *
33 *
34 */
35
36#include "sir_api.h"
37#include "ani_global.h"
38#include "sir_mac_prot_def.h"
39#include "cfg_api.h"
40#include "utils_api.h"
41#include "lim_types.h"
42#include "lim_utils.h"
43#include "lim_security_utils.h"
44#include "lim_prop_exts_utils.h"
45#include "dot11f.h"
46#include "lim_sta_hash_api.h"
47#include "sch_api.h"
48#include "lim_send_messages.h"
49#include "lim_assoc_utils.h"
50#include "lim_ft.h"
51#ifdef WLAN_FEATURE_11W
52#include "wni_cfg.h"
53#endif
54
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053057#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053058#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059#include "cds_utils.h"
60#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053062#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080065#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070066#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053067#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070068#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069
70/**
71 *
72 * \brief This function is called to add the sequence number to the
73 * management frames
74 *
75 * \param pMac Pointer to Global MAC structure
76 *
77 * \param pMacHdr Pointer to MAC management header
78 *
79 * The pMacHdr argument points to the MAC management header. The
80 * sequence number stored in the pMac structure will be incremented
81 * and updated to the MAC management header. The start sequence
82 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
83 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
84 * number will roll over.
85 *
86 */
Jeff Johnson38112a32016-10-07 07:30:50 -070087static void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088{
89 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
90 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
91 }
92
93 pMac->mgmtSeqNum++;
94
95 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
96 pMacHdr->seqControl.seqNumHi =
97 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
98}
99
100/**
101 *
102 * \brief This function is called before sending a p2p action frame
103 * inorder to add sequence numbers to action packets
104 *
105 * \param pMac Pointer to Global MAC structure
106 *
107 * \param pBD Pointer to the frame buffer that needs to be populate
108 *
109 * The pMacHdr argument points to the MAC management header. The
110 * sequence number stored in the pMac structure will be incremented
111 * and updated to the MAC management header. The start sequence
112 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
113 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
114 * number will roll over.
115 *
116 */
117void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
118{
119 tpSirMacMgmtHdr pMacHdr;
120
121 /* / Prepare MAC management header */
122 pMacHdr = (tpSirMacMgmtHdr) (pBD);
123
124 /* Prepare sequence number */
125 lim_add_mgmt_seq_num(pMac, pMacHdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700126 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 pMacHdr->seqControl.seqNumLo,
128 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
129}
130
131/**
132 * lim_populate_mac_header() - Fill in 802.11 header of frame
133 *
134 * @mac_ctx: Pointer to Global MAC structure
135 * @buf: Pointer to the frame buffer that needs to be populate
136 * @type: 802.11 Type of the frame
137 * @sub_type: 802.11 Subtype of the frame
138 * @peer_addr: dst address
139 * @self_mac_addr: local mac address
140 *
141 * This function is called by various LIM modules to prepare the
142 * 802.11 frame MAC header
143 *
144 * The buf argument points to the beginning of the frame buffer to
145 * which - a) The 802.11 MAC header is set b) Following this MAC header
146 * will be the MGMT frame payload The payload itself is populated by the
147 * caller API
148 *
149 * Return: None
150 */
151
152void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
153 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
154 tSirMacAddr self_mac_addr)
155{
156 tpSirMacMgmtHdr mac_hdr;
157
158 /* Prepare MAC management header */
159 mac_hdr = (tpSirMacMgmtHdr) (buf);
160
161 /* Prepare FC */
162 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
163 mac_hdr->fc.type = type;
164 mac_hdr->fc.subType = sub_type;
165
166 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
169
170 /* Prepare Address 2 */
171 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
172
173 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530174 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
176
177 /* Prepare sequence number */
178 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700179 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 mac_hdr->seqControl.seqNumLo,
181 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
182}
183
184/**
185 * lim_send_probe_req_mgmt_frame() - send probe request management frame
186 * @mac_ctx: Pointer to Global MAC structure
187 * @ssid: SSID to be sent in Probe Request frame
188 * @bssid: BSSID to be sent in Probe Request frame
189 * @channel: Channel # on which the Probe Request is going out
190 * @self_macaddr: self MAC address
191 * @dot11mode: self dotllmode
192 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
193 * frame
194 * @additional_ie: if additional_ielen is non zero, include this field in the
195 * Probe Request frame
196 *
197 * This function is called by various LIM modules to send Probe Request frame
198 * during active scan/learn phase.
199 * Probe request is sent out in the following scenarios:
200 * --heartbeat failure: session needed
201 * --join req: session needed
202 * --foreground scan: no session
203 * --background scan: no session
204 * --sch_beacon_processing: to get EDCA parameters: session needed
205 *
206 * Return: tSirRetStatus (eSIR_SUCCESS on success and error codes otherwise)
207 */
208tSirRetStatus
209lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
210 tSirMacSSid *ssid,
211 tSirMacAddr bssid,
212 uint8_t channel,
213 tSirMacAddr self_macaddr,
214 uint32_t dot11mode,
215 uint32_t additional_ielen, uint8_t *additional_ie)
216{
217 tDot11fProbeRequest pr;
218 uint32_t status, bytes, payload;
219 uint8_t *frame;
220 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530221 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 tpPESession pesession;
223 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700224 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 uint8_t txflag = 0;
226 uint8_t sme_sessionid = 0;
227 bool is_vht_enabled = false;
228 uint8_t txPower;
229 uint16_t addn_ielen = additional_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530230 bool extracted_ext_cap_flag = false;
231 tDot11fIEExtCap extracted_ext_cap;
232 tSirRetStatus sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233
234 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
235 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
236 * is false and dot11mode is 11ac set it to 11n.
237 */
238 if (channel <= SIR_11B_CHANNEL_END &&
239 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
240 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
241 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
242 dot11mode = WNI_CFG_DOT11_MODE_11N;
243 /*
244 * session context may or may not be present, when probe request needs
245 * to be sent out. Following cases exist:
246 * --heartbeat failure: session needed
247 * --join req: session needed
248 * --foreground scan: no session
249 * --background scan: no session
250 * --sch_beacon_processing: to get EDCA parameters: session needed
251 * If session context does not exist, some IEs will be populated from
252 * CFGs, e.g. Supported and Extended rate set IEs
253 */
254 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
255
256 if (pesession != NULL)
257 sme_sessionid = pesession->smeSessionId;
258
259 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
260 /* and then hand it off to 'dot11f_pack_probe_request' (for */
261 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530262 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263
264 /* & delegating to assorted helpers: */
265 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
266
267 if (addn_ielen && additional_ie)
268 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
269
270 /*
271 * Don't include 11b rate if it is a P2P serach or probe request is
272 * sent by P2P Client
273 */
274 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
275 (((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
276 mac_ctx->lim.gpLimMlmScanReq->p2pSearch) ||
277 ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530278 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 )
280 ) {
281 /*
282 * In the below API pass channel number > 14, do that it fills
283 * only 11a rates in supported rates
284 */
285 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
286 pesession);
287 } else {
288 populate_dot11f_supp_rates(mac_ctx, channel,
289 &pr.SuppRates, pesession);
290
291 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
292 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
293 &pr.ExtSuppRates);
294 }
295 }
296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 /*
298 * Table 7-14 in IEEE Std. 802.11k-2008 says
299 * DS params "can" be present in RRM is disabled and "is" present if
300 * RRM is enabled. It should be ok even if we add it into probe req when
301 * RRM is not enabled.
302 */
303 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
304 /* Call RRM module to get the tx power for management used. */
305 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
306 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308
309 if (pesession != NULL) {
310 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
311 /* Include HT Capability IE */
312 if (pesession->htCapability)
313 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
314 } else { /* pesession == NULL */
315 if (IS_DOT11_MODE_HT(dot11mode))
316 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
317 }
318
319 /*
320 * Set channelbonding information as "disabled" when tunned to a
321 * 2.4 GHz channel
322 */
323 if (channel <= SIR_11B_CHANNEL_END) {
324 if (mac_ctx->roam.configParam.channelBondingMode24GHz
325 == PHY_SINGLE_CHANNEL_CENTERED) {
326 pr.HTCaps.supportedChannelWidthSet =
327 eHT_CHANNEL_WIDTH_20MHZ;
328 pr.HTCaps.shortGI40MHz = 0;
329 } else {
330 pr.HTCaps.supportedChannelWidthSet =
331 eHT_CHANNEL_WIDTH_40MHZ;
332 }
333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 if (pesession != NULL) {
335 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
336 /* Include VHT Capability IE */
337 if (pesession->vhtCapability) {
338 populate_dot11f_vht_caps(mac_ctx, pesession,
339 &pr.VHTCaps);
340 is_vht_enabled = true;
341 }
342 } else {
343 if (IS_DOT11_MODE_VHT(dot11mode)) {
344 populate_dot11f_vht_caps(mac_ctx, pesession,
345 &pr.VHTCaps);
346 is_vht_enabled = true;
347 }
348 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 if (pesession != NULL)
350 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
351 pesession);
352
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +0530353 if (mac_ctx->roam.configParam.qcn_ie_support)
354 populate_dot11f_qcn_ie(&pr.QCN_IE);
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +0530355
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800356 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
357 lim_update_session_he_capable(mac_ctx, pesession);
358
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700359 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800360 populate_dot11f_he_caps(mac_ctx, pesession, &pr.vendor_he_cap);
361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 if (addn_ielen) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530363 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
364 sizeof(tDot11fIEExtCap));
365 sir_status = lim_strip_extcap_update_struct(mac_ctx,
366 additional_ie,
367 &addn_ielen,
368 &extracted_ext_cap);
369 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700370 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530371 } else {
372 struct s_ext_cap *p_ext_cap =
373 (struct s_ext_cap *)
374 extracted_ext_cap.bytes;
375 if (p_ext_cap->interworking_service)
376 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800377 extracted_ext_cap.num_bytes =
378 lim_compute_ext_cap_ie_length
379 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530380 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800381 (extracted_ext_cap.num_bytes > 0);
Kapil Guptac03eb072016-08-09 14:01:36 +0530382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 }
384
Hu Wang411e0cc2016-10-28 14:56:01 +0800385 /*
386 * Extcap IE now support variable length, merge Extcap IE from addn_ie
387 * may change the frame size. Therefore, MUST merge ExtCap IE before
388 * dot11f get packed payload size.
389 */
390 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800391 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800392
393 /* That's it-- now we pack it. First, how much space are we going to */
394 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
395 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700396 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800397 status);
398 /* We'll fall back on the worst case scenario: */
399 payload = sizeof(tDot11fProbeRequest);
400 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700401 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800402 status);
403 }
404
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
406
407 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530408 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530410 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700411 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 return eSIR_MEM_ALLOC_FAILED;
413 }
414 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530415 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416
417 /* Next, we fill out the buffer descriptor: */
418 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
419 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
420
421 /* That done, pack the Probe Request: */
422 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
423 sizeof(tSirMacMgmtHdr),
424 payload, &payload);
425 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 cds_packet_free((void *)packet);
428 return eSIR_FAILURE; /* allocated! */
429 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700430 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 }
432 /* Append any AddIE if present. */
433 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530434 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 additional_ie, addn_ielen);
436 payload += addn_ielen;
437 }
438
439 /* If this probe request is sent during P2P Search State, then we need
440 * to send it at OFDM rate.
441 */
442 if ((SIR_BAND_5_GHZ == lim_get_rf_band(channel))
443 || ((mac_ctx->lim.gpLimMlmScanReq != NULL) &&
444 mac_ctx->lim.gpLimMlmScanReq->p2pSearch)
445 /*
446 * For unicast probe req mgmt from Join function we don't set
447 * above variables. So we need to add one more check whether it
448 * is pePersona is P2P_CLIENT or not
449 */
450 || ((pesession != NULL) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +0530451 (QDF_P2P_CLIENT_MODE == pesession->pePersona))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452 ) {
453 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
454 }
455
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530456 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 wma_tx_frame(mac_ctx, packet,
458 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
459 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
460 lim_tx_complete, frame, txflag, sme_sessionid,
461 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530462 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700463 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 /* Pkt will be freed up by the callback */
465 return eSIR_FAILURE;
466 }
467
468 return eSIR_SUCCESS;
469} /* End lim_send_probe_req_mgmt_frame. */
470
Jeff Johnson38112a32016-10-07 07:30:50 -0700471static tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 uint8_t *addIE, uint16_t *addnIELen,
473 uint8_t probeReqP2pIe)
474{
475 /* If Probe request doesn't have P2P IE, then take out P2P IE
476 from additional IE */
477 if (!probeReqP2pIe) {
478 uint8_t *tempbuf = NULL;
479 uint16_t tempLen = 0;
480 int left = *addnIELen;
481 uint8_t *ptr = addIE;
482 uint8_t elem_id, elem_len;
483
484 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700485 pe_err("NULL addIE pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 return eSIR_FAILURE;
487 }
488
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530489 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700491 pe_err("Unable to allocate memory to store addn IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 return eSIR_MEM_ALLOC_FAILED;
493 }
494
495 while (left >= 2) {
496 elem_id = ptr[0];
497 elem_len = ptr[1];
498 left -= 2;
499 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700500 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 return eSIR_FAILURE;
504 }
505 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
506 (memcmp
507 (&ptr[2], SIR_MAC_P2P_OUI,
508 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 elem_len + 2);
511 tempLen += (elem_len + 2);
512 }
513 left -= elem_len;
514 ptr += (elem_len + 2);
515 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530516 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530518 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 }
520 return eSIR_SUCCESS;
521}
522
523/**
524 * lim_send_probe_rsp_mgmt_frame() - Send probe response
525 *
526 * @mac_ctx: Handle for mac context
527 * @peer_macaddr: Mac address of requesting peer
528 * @ssid: SSID for response
529 * @n_staid: Station ID, currently unused.
530 * @pe_session: PE session id
531 * @keepalive: Keep alive flag. Currently unused.
532 * @preq_p2pie: P2P IE in incoming probe request
533 *
534 * Builds and sends probe response frame to the requesting peer
535 *
536 * Return: void
537 */
538
539void
540lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
541 tSirMacAddr peer_macaddr,
542 tpAniSSID ssid,
543 short n_staid,
544 uint8_t keepalive,
545 tpPESession pe_session, uint8_t preq_p2pie)
546{
547 tDot11fProbeResponse *frm;
548 tSirRetStatus sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800549 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 tpSirMacMgmtHdr mac_hdr;
551 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700552 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530553 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 uint32_t addn_ie_present = false;
555
556 uint16_t addn_ie_len = 0;
557 uint32_t wps_ap = 0, tmp;
558 uint8_t tx_flag = 0;
559 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700560 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 uint8_t noalen = 0;
562 uint8_t total_noalen = 0;
563 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
564 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
565 uint8_t sme_sessionid = 0;
566 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530567 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530568 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569
570 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700571 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572 return;
573
574 if (NULL == pe_session)
575 return;
576
577 /*
578 * In case when cac timer is running for this SAP session then
579 * avoid sending probe rsp out. It is violation of dfs specification.
580 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530581 if (((pe_session->pePersona == QDF_SAP_MODE) ||
582 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530584 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 FL("CAC timer is running, probe response dropped"));
586 return;
587 }
588 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530589 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700591 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 return;
593 }
594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 /*
596 * Fill out 'frm', after which we'll just hand the struct off to
597 * 'dot11f_pack_probe_response'.
598 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530599 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600
601 /*
602 * Timestamp to be updated by TFP, below.
603 *
604 * Beacon Interval:
605 */
606 if (LIM_IS_AP_ROLE(pe_session)) {
607 frm->BeaconInterval.interval =
608 mac_ctx->sch.schObject.gSchBeaconInterval;
609 } else {
610 sir_status = wlan_cfg_get_int(mac_ctx,
611 WNI_CFG_BEACON_INTERVAL, &cfg);
612 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700613 pe_err("Failed to get WNI_CFG_BEACON_INTERVAL (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 sir_status);
615 goto err_ret;
616 }
617 frm->BeaconInterval.interval = (uint16_t) cfg;
618 }
619
620 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
621 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
622 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
623 &frm->SuppRates, pe_session);
624
625 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
626 pe_session->currentOperChannel);
627 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
628
629 if (LIM_IS_AP_ROLE(pe_session)) {
630 if (pe_session->wps_state != SAP_WPS_DISABLED)
631 populate_dot11f_probe_res_wpsi_es(mac_ctx,
632 &frm->WscProbeRes,
633 pe_session);
634 } else {
635 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
636 &tmp) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700637 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638
639 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
640
641 if (wps_ap)
642 populate_dot11f_wsc_in_probe_res(mac_ctx,
643 &frm->WscProbeRes);
644
645 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
646 eLIM_WSC_ENROLL_BEGIN) {
647 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
648 &frm->WscProbeRes);
649 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
650 eLIM_WSC_ENROLL_IN_PROGRESS;
651 }
652
653 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
654 eLIM_WSC_ENROLL_END) {
655 de_populate_dot11f_wsc_registrar_info_in_probe_res(
656 mac_ctx, &frm->WscProbeRes);
657 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
658 eLIM_WSC_ENROLL_NOOP;
659 }
660 }
661
662 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
663 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
664
665 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
666 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
667
668 populate_dot11f_ext_supp_rates(mac_ctx,
669 POPULATE_DOT11F_RATES_OPERATIONAL,
670 &frm->ExtSuppRates, pe_session);
671
672 /* Populate HT IEs, when operating in 11n */
673 if (pe_session->htCapability) {
674 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
675 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
676 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700678 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
680 populate_dot11f_vht_operation(mac_ctx, pe_session,
681 &frm->VHTOperation);
682 /*
683 * we do not support multi users yet.
684 * populate_dot11f_vht_ext_bss_load( mac_ctx,
685 * &frm.VHTExtBssLoad );
686 */
687 is_vht_enabled = true;
688 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800690 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700691 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800692 populate_dot11f_he_caps(mac_ctx, pe_session,
693 &frm->vendor_he_cap);
694 populate_dot11f_he_operation(mac_ctx, pe_session,
695 &frm->vendor_he_op);
696 }
697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
699 pe_session);
700
701 if (pe_session->pLimStartBssReq) {
702 populate_dot11f_wpa(mac_ctx,
703 &(pe_session->pLimStartBssReq->rsnIE),
704 &frm->WPA);
705 populate_dot11f_rsn_opaque(mac_ctx,
706 &(pe_session->pLimStartBssReq->rsnIE),
707 &frm->RSNOpaque);
708 }
709
710 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
711 &frm->WMMCaps, pe_session);
712
713#if defined(FEATURE_WLAN_WAPI)
714 if (pe_session->pLimStartBssReq)
715 populate_dot11f_wapi(mac_ctx,
716 &(pe_session->pLimStartBssReq->rsnIE),
717 &frm->WAPI);
718#endif /* defined(FEATURE_WLAN_WAPI) */
719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 if (mac_ctx->lim.gpLimRemainOnChanReq)
721 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
722 sizeof(tSirRemainOnChnReq));
723 else
724 /*
725 * Only use CFG for non-listen mode. This CFG is not working for
726 * concurrency. In listening mode, probe rsp IEs is passed in
727 * the message from SME to PE.
728 */
729 addn_ie_present =
730 (pe_session->addIeParams.probeRespDataLen != 0);
731
732 if (addn_ie_present) {
733
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530734 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 pe_session->addIeParams.probeRespDataLen);
736 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700737 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 goto err_ret;
739 }
740
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530741 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 pe_session->addIeParams.probeRespData_buff,
743 pe_session->addIeParams.probeRespDataLen);
744 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
745
746 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
747 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700748 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 goto err_ret;
750 }
751
752 sir_status = lim_strip_extcap_update_struct(mac_ctx,
753 add_ie, &addn_ie_len,
754 &extracted_ext_cap);
755 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700756 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530757 } else {
758 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 }
760
761 bytes = bytes + addn_ie_len;
762
763 if (preq_p2pie)
764 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
765 addn_ie_len);
766
767 if (p2p_ie != NULL) {
768 /* get NoA attribute stream P2P IE */
769 noalen = lim_get_noa_attr_stream(mac_ctx,
770 noa_stream, pe_session);
771 if (noalen != 0) {
772 total_noalen =
773 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
774 &noa_stream[0], noalen);
775 bytes = bytes + total_noalen;
776 }
777 }
778 }
779
Hu Wang411e0cc2016-10-28 14:56:01 +0800780 /*
781 * Extcap IE now support variable length, merge Extcap IE from addn_ie
782 * may change the frame size. Therefore, MUST merge ExtCap IE before
783 * dot11f get packed payload size.
784 */
785 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800786 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
787 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800788
789 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
790 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700791 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800792 status);
793 /* We'll fall back on the worst case scenario: */
794 payload = sizeof(tDot11fProbeResponse);
795 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700796 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800797 status);
798 }
799
800 bytes += payload + sizeof(tSirMacMgmtHdr);
801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530802 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530804 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700805 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 goto err_ret;
807 }
808 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530809 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810
811 /* Next, we fill out the buffer descriptor: */
812 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
813 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
814 pe_session->selfMacAddr);
815
816 mac_hdr = (tpSirMacMgmtHdr) frame;
817
818 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 /* That done, pack the Probe Response: */
821 status =
822 dot11f_pack_probe_response(mac_ctx, frm,
823 frame + sizeof(tSirMacMgmtHdr),
824 payload, &payload);
825 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700826 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 status);
828 goto err_ret;
829 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700830 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 }
832
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700833 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530834 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530837 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
839 (mac_ctx->lim.gpLimRemainOnChanReq->length -
840 sizeof(tSirRemainOnChnReq)));
841
842 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530843 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 &add_ie[0], addn_ie_len);
845
846 if (noalen != 0) {
847 if (total_noalen >
848 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700849 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 total_noalen);
851 goto err_ret;
852 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530853 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 &noa_ie[0], total_noalen);
855 }
856 }
857
858 if ((SIR_BAND_5_GHZ == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530859 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
860 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 )
862 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
863
864 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530865 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 (uint16_t) bytes,
867 TXRX_FRM_802_11_MGMT,
868 ANI_TXDIR_TODS,
869 7, lim_tx_complete, frame, tx_flag,
870 sme_sessionid, 0);
871
872 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530873 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700874 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
876 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530879 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 return;
881
882err_ret:
883 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530884 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530886 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 if (packet != NULL)
888 cds_packet_free((void *)packet);
889 return;
890
891} /* End lim_send_probe_rsp_mgmt_frame. */
892
893void
894lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
895 tSirMacAddr peerMacAddr,
896 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
897{
898 uint16_t i;
899 uint8_t *pFrame;
900 tDot11fAddTSRequest AddTSReq;
901 tDot11fWMMAddTSRequest WMMAddTSReq;
902 uint32_t nPayload, nBytes, nStatus;
903 tpSirMacMgmtHdr pMacHdr;
904 void *pPacket;
905#ifdef FEATURE_WLAN_ESE
906 uint32_t phyMode;
907#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530908 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 uint8_t txFlag = 0;
910 uint8_t smeSessionId = 0;
911
912 if (NULL == psessionEntry) {
913 return;
914 }
915
916 smeSessionId = psessionEntry->smeSessionId;
917
918 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530919 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
921 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
922 AddTSReq.DialogToken.token = pAddTS->dialogToken;
923 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
924 if (pAddTS->lleTspecPresent) {
925 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
926 } else {
927 populate_dot11f_wmmtspec(&pAddTS->tspec,
928 &AddTSReq.WMMTSPEC);
929 }
930
931 if (pAddTS->lleTspecPresent) {
932 AddTSReq.num_WMMTCLAS = 0;
933 AddTSReq.num_TCLAS = pAddTS->numTclas;
934 for (i = 0; i < pAddTS->numTclas; ++i) {
935 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
936 &AddTSReq.TCLAS[i]);
937 }
938 } else {
939 AddTSReq.num_TCLAS = 0;
940 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
941 for (i = 0; i < pAddTS->numTclas; ++i) {
942 populate_dot11f_wmmtclas(pMac,
943 &pAddTS->tclasInfo[i],
944 &AddTSReq.WMMTCLAS[i]);
945 }
946 }
947
948 if (pAddTS->tclasProcPresent) {
949 if (pAddTS->lleTspecPresent) {
950 AddTSReq.TCLASSPROC.processing =
951 pAddTS->tclasProc;
952 AddTSReq.TCLASSPROC.present = 1;
953 } else {
954 AddTSReq.WMMTCLASPROC.version = 1;
955 AddTSReq.WMMTCLASPROC.processing =
956 pAddTS->tclasProc;
957 AddTSReq.WMMTCLASPROC.present = 1;
958 }
959 }
960
961 nStatus =
962 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
963 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700964 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
965 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 /* We'll fall back on the worst case scenario: */
967 nPayload = sizeof(tDot11fAddTSRequest);
968 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700969 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
970 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 }
972 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530973 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974
975 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
976 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
977 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
978
979 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
980 WMMAddTSReq.StatusCode.statusCode = 0;
981
982 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
983#ifdef FEATURE_WLAN_ESE
984 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
985
986 if (phyMode == WNI_CFG_PHY_MODE_11G
987 || phyMode == WNI_CFG_PHY_MODE_11A) {
988 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
989 } else {
990 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
991 }
992 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
993 &WMMAddTSReq.ESETrafStrmRateSet,
994 sizeof(uint8_t));
995#endif
996 /* fillWmeTspecIE */
997
998 nStatus =
999 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
1000 &nPayload);
1001 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001002 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 nStatus);
1004 /* We'll fall back on the worst case scenario: */
1005 nPayload = sizeof(tDot11fAddTSRequest);
1006 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001007 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1008 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 }
1010 }
1011
1012 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1013
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301014 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301016 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001017 pe_err("Failed to allocate %d bytes for an Add TS Request",
1018 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 return;
1020 }
1021 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301022 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
1024 /* Next, we fill out the buffer descriptor: */
1025 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1026 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1027 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1028
1029 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1030
1031#ifdef WLAN_FEATURE_11W
1032 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1033#endif
1034
1035 /* That done, pack the struct: */
1036 if (!pAddTS->wmeTspecPresent) {
1037 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1038 pFrame +
1039 sizeof(tSirMacMgmtHdr),
1040 nPayload, &nPayload);
1041 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001042 pe_err("Failed to pack an Add TS Request "
1043 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 cds_packet_free((void *)pPacket);
1045 return; /* allocated! */
1046 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001047 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1048 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 }
1050 } else {
1051 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1052 pFrame +
1053 sizeof(tSirMacMgmtHdr),
1054 nPayload, &nPayload);
1055 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001056 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1057 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 cds_packet_free((void *)pPacket);
1059 return; /* allocated! */
1060 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001061 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1062 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 }
1064 }
1065
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001066 pe_debug("Sending an Add TS Request frame to");
1067 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068
1069 if ((SIR_BAND_5_GHZ ==
1070 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301071 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1072 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 ) {
1074 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1075 }
1076
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301077 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 psessionEntry->peSessionId, pMacHdr->fc.subType));
1079
1080 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301081 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 TXRX_FRM_802_11_MGMT,
1083 ANI_TXDIR_TODS,
1084 7, lim_tx_complete, pFrame, txFlag,
1085 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301086 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301087 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001089 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1090 pe_err("Could not send an Add TS Request (%X",
1091 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092} /* End lim_send_addts_req_action_frame. */
1093
1094/**
1095 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1096 * @mac_ctx: Handle for mac context
1097 * @status_code: Status code for assoc response frame
1098 * @aid: Association ID
1099 * @peer_addr: Mac address of requesting peer
1100 * @subtype: Assoc/Reassoc
1101 * @sta: Pointer to station node
1102 * @pe_session: PE session id.
1103 *
1104 * Builds and sends association response frame to the requesting peer.
1105 *
1106 * Return: void
1107 */
1108
1109void
1110lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1111 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1112 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1113{
1114 static tDot11fAssocResponse frm;
1115 uint8_t *frame;
1116 tpSirMacMgmtHdr mac_hdr;
1117 tSirRetStatus sir_status;
1118 uint8_t lle_mode = 0, addts;
1119 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001120 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301122 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123 tUpdateBeaconParams beacon_params;
1124 uint8_t tx_flag = 0;
1125 uint32_t addn_ie_len = 0;
1126 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1127 tpSirAssocReq assoc_req = NULL;
1128 uint8_t sme_session = 0;
1129 bool is_vht = false;
1130 uint16_t stripoff_len = 0;
1131 tDot11fIEExtCap extracted_ext_cap;
1132 bool extracted_flag = false;
1133#ifdef WLAN_FEATURE_11W
1134 uint32_t retry_int;
1135 uint32_t max_retries;
1136#endif
1137
1138 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001139 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 return;
1141 }
1142
1143 sme_session = pe_session->smeSessionId;
1144
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301145 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146
1147 limGetQosMode(pe_session, &qos_mode);
1148 limGetWmeMode(pe_session, &wme_mode);
1149
1150 /*
1151 * An Add TS IE is added only if the AP supports it and
1152 * the requesting STA sent a traffic spec.
1153 */
1154 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1155
1156 frm.Status.status = status_code;
1157
1158 frm.AID.associd = aid | LIM_AID_MASK;
1159
1160 if (NULL == sta) {
1161 populate_dot11f_supp_rates(mac_ctx,
1162 POPULATE_DOT11F_RATES_OPERATIONAL,
1163 &frm.SuppRates, pe_session);
1164 populate_dot11f_ext_supp_rates(mac_ctx,
1165 POPULATE_DOT11F_RATES_OPERATIONAL,
1166 &frm.ExtSuppRates, pe_session);
1167 } else {
1168 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1169 &frm.ExtSuppRates,
1170 sta->supportedRates.llbRates,
1171 sta->supportedRates.llaRates);
1172 }
1173
1174 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
1175 eSIR_SUCCESS == status_code) {
1176 assoc_req = (tpSirAssocReq)
1177 pe_session->parsedAssocReq[sta->assocId];
1178 /*
1179 * populate P2P IE in AssocRsp when assocReq from the peer
1180 * includes P2P IE
1181 */
1182 if (assoc_req != NULL && assoc_req->addIEPresent)
1183 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1184 &frm.P2PAssocRes,
1185 assoc_req);
1186 }
1187
1188 if (NULL != sta) {
1189 if (eHAL_SET == qos_mode) {
1190 if (sta->lleEnabled) {
1191 lle_mode = 1;
1192 populate_dot11f_edca_param_set(mac_ctx,
1193 &frm.EDCAParamSet, pe_session);
1194 }
1195 }
1196
1197 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1198 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1199 pe_session);
1200
1201 if (sta->wsmEnabled)
1202 populate_dot11f_wmm_caps(&frm.WMMCaps);
1203 }
1204
1205 if (sta->mlmStaContext.htCapability &&
1206 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001207 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 populate_dot11f_ht_caps(mac_ctx, pe_session,
1209 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001210 /*
1211 * Check the STA capability and
1212 * update the HTCaps accordingly
1213 */
1214 frm.HTCaps.supportedChannelWidthSet = (
1215 sta->htSupportedChannelWidthSet <
1216 pe_session->htSupportedChannelWidthSet) ?
1217 sta->htSupportedChannelWidthSet :
1218 pe_session->htSupportedChannelWidthSet;
1219 if (!frm.HTCaps.supportedChannelWidthSet)
1220 frm.HTCaps.shortGI40MHz = 0;
1221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1223 pe_session);
1224 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001225 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301226 frm.HTCaps.supportedChannelWidthSet,
1227 frm.HTCaps.mimoPowerSave,
1228 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1229 frm.HTCaps.shortGI40MHz,
1230 frm.HTCaps.dsssCckMode40MHz,
1231 frm.HTCaps.maxRxAMPDUFactor);
1232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 if (sta->mlmStaContext.vhtCapability &&
1234 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001235 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 populate_dot11f_vht_caps(mac_ctx, pe_session,
1237 &frm.VHTCaps);
1238 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301239 &frm.VHTOperation);
1240 is_vht = true;
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +05301241 } else {
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -07001242 /*
1243 * 2G-AS platform: SAP associates with HT (11n)clients
1244 * as 2x1 in 2G and 2X2 in 5G
1245 * Non-2G-AS platform: SAP associates with HT (11n)
1246 * clients as 2X2 in 2G and 5G
1247 * 5G-AS: DonÂ’t care
1248 */
1249 if (!policy_mgr_is_hw_dbs_2x2_capable(mac_ctx->psoc) &&
1250 frm.HTCaps.present && mac_ctx->hw_dbs_capable &&
1251 mac_ctx->lteCoexAntShare &&
1252 IS_24G_CH(pe_session->currentOperChannel))
Nitesh Shahdb5ea0d2017-03-22 15:17:47 +05301253 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301254 }
1255 if (pe_session->vhtCapability &&
1256 pe_session->vendor_vht_sap &&
1257 (assoc_req != NULL) &&
1258 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001259 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301260 frm.vendor_vht_ie.present = 1;
1261 frm.vendor_vht_ie.type =
1262 pe_session->vendor_specific_vht_ie_type;
1263 frm.vendor_vht_ie.sub_type =
1264 pe_session->vendor_specific_vht_ie_sub_type;
1265
1266 frm.vendor_vht_ie.VHTCaps.present = 1;
1267 populate_dot11f_vht_caps(mac_ctx, pe_session,
1268 &frm.vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 is_vht = true;
1270 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1272 pe_session);
1273
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001274 if (lim_is_sta_he_capable(sta) &&
1275 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001276 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001277 populate_dot11f_he_caps(mac_ctx, pe_session,
1278 &frm.vendor_he_cap);
1279 populate_dot11f_he_operation(mac_ctx, pe_session,
1280 &frm.vendor_he_op);
1281 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282#ifdef WLAN_FEATURE_11W
1283 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1284 if (wlan_cfg_get_int
1285 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1286 &max_retries) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001287 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 else if (wlan_cfg_get_int
1289 (mac_ctx,
1290 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1291 &retry_int) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001292 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 else
1294 populate_dot11f_timeout_interval(mac_ctx,
1295 &frm.TimeoutInterval,
1296 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1297 (max_retries -
1298 sta->pmfSaQueryRetryCount)
1299 * retry_int);
1300 }
1301#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001302
1303 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1304 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 }
1306
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308
1309 if (LIM_IS_AP_ROLE(pe_session) &&
1310 (pe_session->gLimProtectionControl !=
1311 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1312 lim_decide_ap_protection(mac_ctx, peer_addr,
1313 &beacon_params, pe_session);
1314
1315 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1316 pe_session);
1317 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1318 pe_session);
1319
1320 /*
1321 * Populate Do11capabilities after updating session with
1322 * Assos req details
1323 */
1324 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1325
1326 beacon_params.bssIdx = pe_session->bssIdx;
1327
1328 /* Send message to HAL about beacon parameter change. */
1329 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1330 && beacon_params.paramChangeBitmap) {
1331 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1332 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334
1335 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001336 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
1338 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001339 if (addn_ie_len > 0 &&
1340 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1341 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301342 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 pe_session->addIeParams.assocRespData_buff,
1344 pe_session->addIeParams.assocRespDataLen);
1345
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301346 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 sizeof(extracted_ext_cap), 0);
1348
1349 stripoff_len = addn_ie_len;
1350 sir_status =
1351 lim_strip_extcap_update_struct
1352 (mac_ctx, &add_ie[0], &stripoff_len,
1353 &extracted_ext_cap);
1354 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001355 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 } else {
1357 addn_ie_len = stripoff_len;
1358 extracted_flag = true;
1359 }
1360 bytes = bytes + addn_ie_len;
1361 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001362 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 addn_ie_len, assoc_req->addIEPresent);
1364 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001365
1366 /*
1367 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1368 * may change the frame size. Therefore, MUST merge ExtCap IE before
1369 * dot11f get packed payload size.
1370 */
1371 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001372 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1373 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001374
1375 /* Allocate a buffer for this frame: */
1376 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1377 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001378 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001379 status);
1380 return;
1381 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001382 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001383 status);
1384 }
1385
1386 bytes += sizeof(tSirMacMgmtHdr) + payload;
1387
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301388 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301390 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001391 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 return;
1393 }
1394 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301395 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396
1397 /* Next, we fill out the buffer descriptor: */
1398 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1399 (LIM_ASSOC == subtype) ?
1400 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1401 peer_addr,
1402 pe_session->selfMacAddr);
1403 mac_hdr = (tpSirMacMgmtHdr) frame;
1404
1405 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1408 frame + sizeof(tSirMacMgmtHdr),
1409 payload, &payload);
1410 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001411 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 status);
1413 cds_packet_free((void *)packet);
1414 return;
1415 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001416 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 status);
1418 }
1419
1420 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001421 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 status_code, aid);
1423 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001424 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 status_code, aid);
1426
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301427 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428
1429 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301430 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 &add_ie[0], addn_ie_len);
1432
1433 if ((SIR_BAND_5_GHZ ==
1434 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301435 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1436 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1438
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301439 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 pe_session->peSessionId, mac_hdr->fc.subType));
1441 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301442 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 TXRX_FRM_802_11_MGMT,
1444 ANI_TXDIR_TODS,
1445 7, lim_tx_complete, frame, tx_flag,
1446 sme_session, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301447 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301448 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
1450 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301451 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001452 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301453 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454
1455 /*
1456 * update the ANI peer station count.
1457 * FIXME_PROTECTION : take care of different type of station
1458 * counter inside this function.
1459 */
1460 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1461
1462}
1463
1464void
1465lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1466 tSirMacAddr peer,
1467 uint8_t wmmTspecPresent,
1468 tSirMacTSInfo *pTsinfo,
1469 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1470{
1471 uint8_t *pFrame;
1472 tpSirMacMgmtHdr pMacHdr;
1473 tDot11fDelTS DelTS;
1474 tDot11fWMMDelTS WMMDelTS;
1475 uint32_t nBytes, nPayload, nStatus;
1476 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301477 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 uint8_t txFlag = 0;
1479 uint8_t smeSessionId = 0;
1480
1481 if (NULL == psessionEntry) {
1482 return;
1483 }
1484
1485 smeSessionId = psessionEntry->smeSessionId;
1486
1487 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301488 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489
1490 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1491 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1492 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1493
1494 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1495 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001496 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 /* We'll fall back on the worst case scenario: */
1498 nPayload = sizeof(tDot11fDelTS);
1499 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001500 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1501 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 }
1503 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301504 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505
1506 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1507 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1508 WMMDelTS.DialogToken.token = 0;
1509 WMMDelTS.StatusCode.statusCode = 0;
1510 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1511 nStatus =
1512 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1513 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001514 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 /* We'll fall back on the worst case scenario: */
1516 nPayload = sizeof(tDot11fDelTS);
1517 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001518 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1519 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 }
1521 }
1522
1523 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1524
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301525 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1527 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301528 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001529 pe_err("Failed to allocate %d bytes for an Add TS Response",
1530 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 return;
1532 }
1533 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535
1536 /* Next, we fill out the buffer descriptor: */
1537 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1538 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1539 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1540
1541 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1542
1543#ifdef WLAN_FEATURE_11W
1544 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1545#endif
1546
1547 /* That done, pack the struct: */
1548 if (!wmmTspecPresent) {
1549 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1550 pFrame + sizeof(tSirMacMgmtHdr),
1551 nPayload, &nPayload);
1552 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001553 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 nStatus);
1555 cds_packet_free((void *)pPacket);
1556 return; /* allocated! */
1557 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001558 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1559 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 }
1561 } else {
1562 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1563 pFrame + sizeof(tSirMacMgmtHdr),
1564 nPayload, &nPayload);
1565 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001566 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 nStatus);
1568 cds_packet_free((void *)pPacket);
1569 return; /* allocated! */
1570 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001571 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1572 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 }
1574 }
1575
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001576 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1577 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578
1579 if ((SIR_BAND_5_GHZ ==
1580 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301581 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1582 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 ) {
1584 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1585 }
1586
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301587 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301589 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 TXRX_FRM_802_11_MGMT,
1591 ANI_TXDIR_TODS,
1592 7, lim_tx_complete, pFrame, txFlag,
1593 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301594 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301595 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301597 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001598 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
1600} /* End lim_send_delts_req_action_frame. */
1601
1602/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301603 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1604 * @context: pointer to global mac
1605 * @buf: buffer
1606 * @tx_complete : Sent status
1607 * @params; tx completion params
1608 *
1609 * Return: This returns QDF_STATUS
1610 */
1611
1612static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1613 qdf_nbuf_t buf,
1614 uint32_t tx_complete,
1615 void *params)
1616{
1617 uint16_t assoc_ack_status;
1618 uint16_t reason_code;
1619 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1620
1621 pe_debug("tx_complete= %d", tx_complete);
1622 if (tx_complete) {
1623 assoc_ack_status = ACKED;
1624 reason_code = eSIR_SUCCESS;
1625 } else {
1626 assoc_ack_status = NOT_ACKED;
1627 reason_code = eSIR_FAILURE;
1628 }
1629 if (buf)
1630 qdf_nbuf_free(buf);
1631
1632 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1633 NULL, assoc_ack_status, reason_code);
1634 return QDF_STATUS_SUCCESS;
1635}
1636
1637/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 * lim_send_assoc_req_mgmt_frame() - Send association request
1639 * @mac_ctx: Handle to MAC context
1640 * @mlm_assoc_req: Association request information
1641 * @pe_session: PE session information
1642 *
1643 * Builds and transmits association request frame to AP.
1644 *
1645 * Return: Void
1646 */
1647
1648void
1649lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1650 tLimMlmAssocReq *mlm_assoc_req,
1651 tpPESession pe_session)
1652{
1653 tDot11fAssocRequest *frm;
1654 uint16_t caps;
1655 uint8_t *frame;
1656 tSirRetStatus sir_status;
1657 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001658 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1660 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301661 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 uint16_t add_ie_len;
1663 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001664 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 uint8_t tx_flag = 0;
1667 uint8_t sme_sessionid = 0;
1668 bool vht_enabled = false;
1669 tDot11fIEExtCap extr_ext_cap;
1670 bool extr_ext_flag = true;
1671 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001672 uint32_t ie_offset = 0;
1673 uint8_t *p_ext_cap = NULL;
1674 tDot11fIEExtCap bcn_ext_cap;
1675 uint8_t *bcn_ie = NULL;
1676 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301677 uint32_t aes_block_size_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678
1679 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001680 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301681 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 return;
1683 }
1684
1685 sme_sessionid = pe_session->smeSessionId;
1686
1687 /* check this early to avoid unncessary operation */
1688 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001689 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301690 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 return;
1692 }
1693 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1694 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1695
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301696 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001698 pe_err("Unable to allocate memory");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301699 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 return;
1701 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001702 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301704 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301705 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 0);
1707 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1708 add_ie, &add_ie_len, &extr_ext_cap);
1709 if (eSIR_SUCCESS != sir_status) {
1710 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001711 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 } else {
1713 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1714 extr_ext_cap.bytes;
1715
1716 if (p_ext_cap->interworking_service)
1717 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001718 extr_ext_cap.num_bytes =
1719 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1720 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 }
1722 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001723 pe_debug("No addn IE or peer dosen't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 extr_ext_flag = false;
1725 }
1726
1727 caps = mlm_assoc_req->capabilityInfo;
1728#if defined(FEATURE_WLAN_WAPI)
1729 /*
1730 * According to WAPI standard:
1731 * 7.3.1.4 Capability Information field
1732 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1733 * in transmitted Association or Reassociation management frames.
1734 * APs ignore the Privacy subfield within received Association and
1735 * Reassociation management frames.
1736 */
1737 if (pe_session->encryptType == eSIR_ED_WPI)
1738 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1739#endif
1740 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1741
1742 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1743 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1744 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1745 &frm->SuppRates, pe_session);
1746
1747 qos_enabled = (pe_session->limQosEnabled) &&
1748 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1749
1750 wme_enabled = (pe_session->limWmeEnabled) &&
1751 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1752
1753 /* We prefer .11e asociations: */
1754 if (qos_enabled)
1755 wme_enabled = false;
1756
1757 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1758 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1759
1760 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001761 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 power_caps = true;
1763
1764 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1765 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1767 LIM_ASSOC, pe_session);
1768
1769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1771 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1772 if (power_caps == false) {
1773 power_caps = true;
1774 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1775 LIM_ASSOC, pe_session);
1776 }
1777 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001779 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1780 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781
1782 populate_dot11f_ext_supp_rates(mac_ctx,
1783 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1784 pe_session);
1785
Gupta, Kapil54a16992016-01-13 19:34:02 +05301786 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1787 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1789 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 /*
1792 * The join request *should* contain zero or one of the WPA and RSN
1793 * IEs. The payload send along with the request is a
1794 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1795 * typedef struct sSirRSNie
1796 * {
1797 * uint16_t length;
1798 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1799 * } tSirRSNie, *tpSirRSNie;
1800 * So, we should be able to make the following two calls harmlessly,
1801 * since they do nothing if they don't find the given IE in the
1802 * bytestream with which they're provided.
1803 * The net effect of this will be to faithfully transmit whatever
1804 * security IE is in the join request.
1805 * However, if we're associating for the purpose of WPS
1806 * enrollment, and we've been configured to indicate that by
1807 * eliding the WPA or RSN IE, we just skip this:
1808 */
1809 if (add_ie_len && add_ie)
1810 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1811
1812 if (NULL == wps_ie) {
1813 populate_dot11f_rsn_opaque(mac_ctx,
1814 &(pe_session->pLimJoinReq->rsnIE),
1815 &frm->RSNOpaque);
1816 populate_dot11f_wpa_opaque(mac_ctx,
1817 &(pe_session->pLimJoinReq->rsnIE),
1818 &frm->WPAOpaque);
1819#if defined(FEATURE_WLAN_WAPI)
1820 populate_dot11f_wapi_opaque(mac_ctx,
1821 &(pe_session->pLimJoinReq->rsnIE),
1822 &frm->WAPIOpaque);
1823#endif /* defined(FEATURE_WLAN_WAPI) */
1824 }
1825 /* include WME EDCA IE as well */
1826 if (wme_enabled) {
1827 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1828 pe_session, &frm->WMMInfoStation);
1829
1830 if (wsm_enabled)
1831 populate_dot11f_wmm_caps(&frm->WMMCaps);
1832 }
1833
1834 /*
1835 * Populate HT IEs, when operating in 11n and
1836 * when AP is also operating in 11n mode
1837 */
1838 if (pe_session->htCapability &&
1839 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001840 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001842 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1843 &frm->HTCaps, sizeof(frm->HTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001845 pe_debug("SupportedChnlWidth: %d, mimoPS: %d, GF: %d, short GI20:%d, shortGI40: %d, dsssCck: %d, AMPDU Param: %x",
Agrawal Ashishc38e58d2015-09-16 17:17:29 +05301846 frm->HTCaps.supportedChannelWidthSet,
1847 frm->HTCaps.mimoPowerSave,
1848 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1849 frm->HTCaps.shortGI40MHz,
1850 frm->HTCaps.dsssCckMode40MHz,
1851 frm->HTCaps.maxRxAMPDUFactor);
1852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 if (pe_session->vhtCapability &&
1854 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001855 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001857 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1858 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001860 if (pe_session->enableHtSmps &&
1861 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001862 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001863 populate_dot11f_operating_mode(mac_ctx,
1864 &frm->OperatingMode, pe_session);
1865 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 }
1867 if (!vht_enabled &&
1868 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001869 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301870 frm->vendor_vht_ie.present = 1;
1871 frm->vendor_vht_ie.type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 pe_session->vendor_specific_vht_ie_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301873 frm->vendor_vht_ie.sub_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 pe_session->vendor_specific_vht_ie_sub_type;
1875
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301876 frm->vendor_vht_ie.VHTCaps.present = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301878 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 vht_enabled = true;
1880 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301881 if (pe_session->is_ext_caps_present)
1882 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1883 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301885 if (mac_ctx->roam.configParam.qcn_ie_support)
1886 populate_dot11f_qcn_ie(&frm->QCN_IE);
1887
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001888 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001889 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001890 populate_dot11f_he_caps(mac_ctx, pe_session,
1891 &frm->vendor_he_cap);
1892 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301893
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 tSirBssDescription *bssdescr;
1896
1897 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001898 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 (unsigned int) bssdescr->mdie[0],
1900 (unsigned int) bssdescr->mdie[1],
1901 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 populate_mdie(mac_ctx, &frm->MobilityDomain,
1903 pe_session->pLimJoinReq->bssDescription.mdie);
1904 } else {
1905 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001906 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908
1909#ifdef FEATURE_WLAN_ESE
1910 /*
1911 * ESE Version IE will be included in association request
1912 * when ESE is enabled on DUT through ini and it is also
1913 * advertised by the peer AP to which we are trying to
1914 * associate to.
1915 */
1916 if (pe_session->is_ese_version_ie_present &&
1917 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1918 populate_dot11f_ese_version(&frm->ESEVersion);
1919 /* For ESE Associations fill the ESE IEs */
1920 if (pe_session->isESEconnection &&
1921 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1922#ifndef FEATURE_DISABLE_RM
1923 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1924#endif
1925 }
1926#endif
1927
Hu Wang411e0cc2016-10-28 14:56:01 +08001928 /*
1929 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1930 * may change the frame size. Therefore, MUST merge ExtCap IE before
1931 * dot11f get packed payload size.
1932 */
1933 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001934 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1935
1936 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1937 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1938 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1939 DOT11F_FF_BEACONINTERVAL_LEN +
1940 DOT11F_FF_CAPABILITIES_LEN;
1941
1942 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1943 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1944 bcn_ie = pe_session->beacon + ie_offset;
1945 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001946 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001947 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001948 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001949 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1950 &bcn_ext_cap);
1951 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1952 false);
1953 }
1954 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001955
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001956 if (eSIR_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
1957 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001958 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001959
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301960 if (lim_is_fils_connection(pe_session)) {
1961 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1962 aes_block_size_len = AES_BLOCK_SIZE;
1963 }
1964
1965 /*
1966 * Do unpack to populate the add_ie buffer to frm structure
1967 * before packing the frm structure. In this way, the IE ordering
1968 * which the latest 802.11 spec mandates is maintained.
1969 */
1970 if (add_ie_len)
1971 dot11f_unpack_assoc_request(mac_ctx, add_ie,
1972 add_ie_len, frm, true);
1973
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1975 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001976 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977 status);
1978 /* We'll fall back on the worst case scenario: */
1979 payload = sizeof(tDot11fAssocRequest);
1980 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001981 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 status);
1983 }
1984
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301985 bytes = payload + sizeof(tSirMacMgmtHdr) +
1986 aes_block_size_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301988 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301990 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001991 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992
1993 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301994 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 pe_session->peSessionId,
1996 pe_session->limMlmState));
1997
1998 /* Update PE session id */
1999 assoc_cnf.sessionId = pe_session->peSessionId;
2000
2001 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2002
2003 cds_packet_free((void *)packet);
2004
2005 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2006 (uint32_t *) &assoc_cnf);
2007
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302008 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 }
2010 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302011 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012
2013 /* Next, we fill out the buffer descriptor: */
2014 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2015 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2016 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 /* That done, pack the Assoc Request: */
2018 status = dot11f_pack_assoc_request(mac_ctx, frm,
2019 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2020 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002021 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302023 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002025 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 }
2027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002031 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 }
2033
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302034 if (lim_is_fils_connection(pe_session)) {
2035 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2036 frame, &payload);
2037 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2038 cds_packet_free((void *)packet);
2039 qdf_mem_free(frm);
2040 return;
2041 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 }
2043
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302044 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002046 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else {
2048 /*
2049 * Store the Assoc request. This is sent to csr/hdd in
2050 * join cnf response.
2051 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302052 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 frame + sizeof(tSirMacMgmtHdr), payload);
2054 pe_session->assocReqLen = payload;
2055 }
2056
2057 if ((SIR_BAND_5_GHZ == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302058 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2059 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 )
2061 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2062
Anurag Chouhan6d760662016-02-20 16:05:43 +05302063 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2064 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2066
2067#ifdef FEATURE_WLAN_DIAG_SUPPORT
2068 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
2069 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
2070#endif
2071 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302072 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302074
2075 pe_debug("Sending Association Request length %d to ", bytes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302076 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302077 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2079 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302080 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
2081 tx_flag, sme_sessionid, false, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302082 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302083 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302084 pe_session->peSessionId, qdf_status));
2085 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002086 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302087 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302088 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
2089 pe_session, SENT_FAIL, eSIR_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 }
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302092end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302094 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302096 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 return;
2098}
2099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302101 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302102 * @context: pointer to global mac
2103 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302104 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302105 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302106 *
2107 * Return: This returns QDF_STATUS
2108 */
2109
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302110static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2111 qdf_nbuf_t buf,
2112 uint32_t tx_complete,
2113 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302114{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302115 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302116 uint16_t auth_ack_status;
2117 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302118
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002119 pe_debug("tx_complete= %d", tx_complete);
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302120 if (tx_complete) {
2121 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302122 auth_ack_status = ACKED;
2123 reason_code = eSIR_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302124 /* 'Change' timer for future activations */
2125 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2126 } else {
2127 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302128 auth_ack_status = NOT_ACKED;
2129 reason_code = eSIR_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302130 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302131
2132 if (buf)
2133 qdf_nbuf_free(buf);
2134
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302135 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2136 NULL, auth_ack_status, reason_code);
2137
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302138 return QDF_STATUS_SUCCESS;
2139}
2140
2141/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2143 *
2144 * @mac_ctx: Pointer to Global MAC structure
2145 * @auth_frame: Pointer to Authentication frame structure
2146 * @peer_addr: MAC address of destination peer
2147 * @wep_bit: wep bit in frame control for Authentication frame3
2148 * @session: PE session information
2149 *
2150 * This function is called by lim_process_mlm_messages(). Authentication frame
2151 * is formatted and sent when this function is called.
2152 *
2153 * Return: void
2154 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155void
2156lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2157 tpSirMacAuthFrameBody auth_frame,
2158 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302159 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302160 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161{
2162 uint8_t *frame, *body;
2163 uint32_t frame_len = 0, body_len = 0;
2164 tpSirMacMgmtHdr mac_hdr;
2165 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302166 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 uint8_t tx_flag = 0;
2168 uint8_t sme_sessionid = 0;
2169 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002170 bool challenge_req = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171
2172 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002173 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 return;
2175 }
2176
2177 sme_sessionid = session->smeSessionId;
2178
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302179 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002180 /*
2181 * Auth frame3 to be sent with encrypted framebody
2182 *
2183 * Allocate buffer for Authenticaton frame of size
2184 * equal to management frame header length plus 2 bytes
2185 * each for auth algorithm number, transaction number,
2186 * status code, 128 bytes for challenge text and
2187 * 4 bytes each for IV & ICV.
2188 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002189 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2190 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002191
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302192 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002193 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002194
2195 goto alloc_packet;
2196 }
2197
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302198 pe_info("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002199 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 auth_frame->authTransactionSeqNumber,
2201 auth_frame->authStatusCode,
2202 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2203 MAC_ADDR_ARRAY(peer_addr));
2204
2205 switch (auth_frame->authTransactionSeqNumber) {
2206 case SIR_MAC_AUTH_FRAME_1:
2207 /*
2208 * Allocate buffer for Authenticaton frame of size
2209 * equal to management frame header length plus 2 bytes
2210 * each for auth algorithm number, transaction number
2211 * and status code.
2212 */
2213
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002214 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2215 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302217 frame_len += lim_create_fils_auth_data(mac_ctx,
2218 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2220 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2221 0 != session->ftPEContext.pFTPreAuthReq->
2222 ft_ies_length) {
2223 ft_ies_length = session->ftPEContext.
2224 pFTPreAuthReq->ft_ies_length;
2225 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002226 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 ft_ies_length);
2228 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002229 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 frame_len += (2 + SIR_MDIE_SIZE);
2231 }
2232 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 break;
2234
2235 case SIR_MAC_AUTH_FRAME_2:
2236 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2237 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2238 (auth_frame->authStatusCode !=
2239 eSIR_MAC_SUCCESS_STATUS))) {
2240 /*
2241 * Allocate buffer for Authenticaton frame of size
2242 * equal to management frame header length plus
2243 * 2 bytes each for auth algorithm number,
2244 * transaction number and status code.
2245 */
2246
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002247 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2248 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 } else {
2250 /*
2251 * Shared Key algorithm with challenge text
2252 * to be sent.
2253 *
2254 * Allocate buffer for Authenticaton frame of size
2255 * equal to management frame header length plus
2256 * 2 bytes each for auth algorithm number,
2257 * transaction number, status code and 128 bytes
2258 * for challenge text.
2259 */
2260
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002261 challenge_req = true;
2262 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
2263 SIR_MAC_AUTH_CHALLENGE_BODY_LEN;
2264 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 }
2266 break;
2267
2268 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002269 /*
2270 * Auth frame3 to be sent without encrypted framebody
2271 *
2272 * Allocate buffer for Authenticaton frame of size equal
2273 * to management frame header length plus 2 bytes each
2274 * for auth algorithm number, transaction number and
2275 * status code.
2276 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002278 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2279 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 break;
2281
2282 case SIR_MAC_AUTH_FRAME_4:
2283 /*
2284 * Allocate buffer for Authenticaton frame of size equal
2285 * to management frame header length plus 2 bytes each
2286 * for auth algorithm number, transaction number and
2287 * status code.
2288 */
2289
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002290 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2291 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292
2293 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002294 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002295 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002296 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 } /* switch (auth_frame->authTransactionSeqNumber) */
2298
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002299alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302300 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 (void **)&packet);
2302
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302303 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002304 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 return;
2306 }
2307
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302308 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309
2310 /* Prepare BD */
2311 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2312 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2313 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302314 if (wep_challenge_len)
2315 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2316 else
2317 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318
2319 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002320 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302321 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322 (uint8_t *) session->bssId,
2323 sizeof(tSirMacAddr));
2324
2325 /* Prepare Authentication frame body */
2326 body = frame + sizeof(tSirMacMgmtHdr);
2327
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302328 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302329 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002331 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 MAC_ADDR_ARRAY(mac_hdr->da));
2333
2334 } else {
2335 *((uint16_t *) (body)) =
2336 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2337 body += sizeof(uint16_t);
2338 body_len -= sizeof(uint16_t);
2339
2340 *((uint16_t *) (body)) =
2341 sir_swap_u16if_needed(
2342 auth_frame->authTransactionSeqNumber);
2343 body += sizeof(uint16_t);
2344 body_len -= sizeof(uint16_t);
2345
2346 *((uint16_t *) (body)) =
2347 sir_swap_u16if_needed(auth_frame->authStatusCode);
2348 body += sizeof(uint16_t);
2349 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002350
2351 if (challenge_req) {
2352 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302353 /* copy challenge IE id, len, challenge text */
2354 *body = auth_frame->type;
2355 body++;
2356 body_len -= sizeof(uint8_t);
2357 *body = auth_frame->length;
2358 body++;
2359 body_len -= sizeof(uint8_t);
2360 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002361 body_len);
2362 pe_err("Incomplete challenge info: length: %d, expected: %d",
2363 body_len,
2364 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2365 body += body_len;
2366 body_len = 0;
2367 } else {
2368 /* copy challenge IE id, len, challenge text */
2369 *body = auth_frame->type;
2370 body++;
2371 *body = auth_frame->length;
2372 body++;
2373 qdf_mem_copy(body, auth_frame->challengeText,
2374 SIR_MAC_AUTH_CHALLENGE_LENGTH);
2375 body += SIR_MAC_AUTH_CHALLENGE_LENGTH;
2376
2377 body_len -= SIR_MAC_AUTH_CHALLENGE_BODY_LEN;
2378 }
2379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2382 (auth_frame->authTransactionSeqNumber ==
2383 SIR_MAC_AUTH_FRAME_1) &&
2384 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2385
2386 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302387 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 session->ftPEContext.
2389 pFTPreAuthReq->ft_ies,
2390 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002391 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002392 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2393 QDF_TRACE_LEVEL_DEBUG,
2394 (uint8_t *) body,
2395 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 } else if (NULL != session->ftPEContext.
2397 pFTPreAuthReq->pbssDescription) {
2398 /* MDID attr is 54 */
2399 *body = SIR_MDIE_ELEMENT_ID;
2400 body++;
2401 *body = SIR_MDIE_SIZE;
2402 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302403 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 &session->ftPEContext.pFTPreAuthReq->
2405 pbssDescription->mdie[0],
2406 SIR_MDIE_SIZE);
2407 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302408 } else if (auth_frame->authAlgoNumber ==
2409 eSIR_FILS_SK_WITHOUT_PFS) {
2410 /* TODO MDIE */
2411 pe_debug("appending fils Auth data");
2412 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002415 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2416 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 auth_frame->authTransactionSeqNumber,
2418 auth_frame->authStatusCode,
2419 (auth_frame->authStatusCode ==
2420 eSIR_MAC_SUCCESS_STATUS),
2421 MAC_ADDR_ARRAY(mac_hdr->da));
2422 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002423 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2424 QDF_TRACE_LEVEL_DEBUG,
2425 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302427 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
2428 (SIR_BAND_5_GHZ == lim_get_rf_band(
2429 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302431 else if ((SIR_BAND_5_GHZ ==
2432 lim_get_rf_band(session->currentOperChannel))
2433 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2434 || (session->pePersona == QDF_P2P_GO_MODE))
2435 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
Anurag Chouhan6d760662016-02-20 16:05:43 +05302437 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2438 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2440
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302441 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302444 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
2445 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2446 (uint16_t)frame_len,
2447 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2448 7, lim_tx_complete, frame,
2449 lim_auth_tx_complete_cnf,
2450 tx_flag, sme_sessionid, false, 0);
2451 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2452 session->peSessionId, qdf_status));
2453 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2454 pe_err("*** Could not send Auth frame, retCode=%X ***",
2455 qdf_status);
2456 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2457 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2458 session, SENT_FAIL, eSIR_FAILURE);
2459 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302460 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 return;
2462}
2463
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302464QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465{
2466 uint16_t aid;
2467 tpDphHashNode pStaDs;
2468 tLimMlmDeauthReq *pMlmDeauthReq;
2469 tLimMlmDeauthCnf mlmDeauthCnf;
2470 tpPESession psessionEntry;
2471
2472 pMlmDeauthReq = pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2473 if (pMlmDeauthReq) {
2474 if (tx_timer_running(&pMac->lim.limTimers.gLimDeauthAckTimer)) {
2475 lim_deactivate_and_change_timer(pMac,
2476 eLIM_DEAUTH_ACK_TIMER);
2477 }
2478
2479 psessionEntry = pe_find_session_by_session_id(pMac,
2480 pMlmDeauthReq->sessionId);
2481 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002482 pe_err("session does not exist for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 mlmDeauthCnf.resultCode =
2484 eSIR_SME_INVALID_PARAMETERS;
2485 goto end;
2486 }
2487
2488 pStaDs =
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002489 dph_lookup_hash_entry(pMac,
2490 pMlmDeauthReq->peer_macaddr.bytes,
2491 &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 &psessionEntry->dph.dphHashTable);
2493 if (pStaDs == NULL) {
2494 mlmDeauthCnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2495 goto end;
2496 }
2497
2498 /* / Receive path cleanup with dummy packet */
2499 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
2500 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002501 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE) &&
2502 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302503#ifdef FEATURE_WLAN_ESE
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002504 (psessionEntry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302505#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002506 (psessionEntry->isFastRoamIniFeatureEnabled) ||
2507 (psessionEntry->is11Rconnection))) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002508 pe_debug("FT Preauth (%p,%d) Deauth rc %d src = %d",
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002509 psessionEntry,
2510 psessionEntry->peSessionId,
2511 pMlmDeauthReq->reasonCode,
2512 pMlmDeauthReq->deauthTrigger);
2513 lim_ft_cleanup(pMac, psessionEntry);
2514 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002515 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002516#ifdef FEATURE_WLAN_ESE
2517 " isESE %d"
2518#endif
2519 " isLFR %d"
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002520 " is11r %d, Deauth reason %d Trigger = %d",
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002521 psessionEntry->limSystemRole,
2522#ifdef FEATURE_WLAN_ESE
2523 psessionEntry->isESEconnection,
2524#endif
2525 psessionEntry->isFastRoamIniFeatureEnabled,
2526 psessionEntry->is11Rconnection,
Abhishek Singhe0680852015-12-16 14:28:48 +05302527 pMlmDeauthReq->reasonCode,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002528 pMlmDeauthReq->deauthTrigger);
2529 }
2530 /* Free up buffer allocated for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302531 qdf_mem_free(pMlmDeauthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 pMac->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
2533 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302534 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535end:
Anurag Chouhanc5548422016-02-24 18:33:27 +05302536 qdf_copy_macaddr(&mlmDeauthCnf.peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002537 &pMlmDeauthReq->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 mlmDeauthCnf.deauthTrigger = pMlmDeauthReq->deauthTrigger;
2539 mlmDeauthCnf.aid = pMlmDeauthReq->aid;
2540 mlmDeauthCnf.sessionId = pMlmDeauthReq->sessionId;
2541
2542 /* Free up buffer allocated */
2543 /* for mlmDeauthReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 qdf_mem_free(pMlmDeauthReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545
2546 lim_post_sme_message(pMac,
2547 LIM_MLM_DEAUTH_CNF, (uint32_t *) &mlmDeauthCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549}
2550
2551/**
2552 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2553 *
2554 * @mac_ctx: Handle to MAC context
2555 *
2556 * Sends disassoc confirmation to SME. Removes disassoc request stored
2557 * in lim.
2558 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302559 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 */
2561
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302562QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563{
2564 uint16_t aid;
2565 tpDphHashNode sta_ds;
2566 tLimMlmDisassocCnf disassoc_cnf;
2567 tpPESession pe_session;
2568 tLimMlmDisassocReq *disassoc_req;
2569
2570 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2571 if (disassoc_req) {
2572 if (tx_timer_running(
2573 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2574 lim_deactivate_and_change_timer(mac_ctx,
2575 eLIM_DISASSOC_ACK_TIMER);
2576
2577 pe_session = pe_find_session_by_session_id(
2578 mac_ctx, disassoc_req->sessionId);
2579 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002580 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 disassoc_cnf.resultCode =
2582 eSIR_SME_INVALID_PARAMETERS;
2583 goto end;
2584 }
2585
2586 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002587 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 &pe_session->dph.dphHashTable);
2589 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002590 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2592 goto end;
2593 }
2594 /* Receive path cleanup with dummy packet */
2595 if (eSIR_SUCCESS !=
2596 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2597 disassoc_cnf.resultCode =
2598 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002599 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 goto end;
2601 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002602 if (LIM_IS_STA_ROLE(pe_session) &&
2603 (disassoc_req->reasonCode !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002605 pe_debug("FT Preauth Session (%p %d) Clean up",
2606 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 /* Delete FT session if there exists one */
2609 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302612 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302614 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302616 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 }
2618end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302619 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002620 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302621 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 disassoc_cnf.aid = disassoc_req->aid;
2623 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2624
2625 /* Update PE session ID */
2626 disassoc_cnf.sessionId = disassoc_req->sessionId;
2627
2628 if (disassoc_req != NULL) {
2629 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302630 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2632 }
2633
2634 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2635 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302636 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637}
2638
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302639QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
2640 qdf_nbuf_t buf,
2641 uint32_t txCompleteSuccess,
2642 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302644 tpAniSirGlobal pMac = (tpAniSirGlobal)context;
2645
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002646 pe_debug("txCompleteSuccess: %d", txCompleteSuccess);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302647
2648 if (buf)
2649 qdf_nbuf_free(buf);
2650
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 return lim_send_disassoc_cnf(pMac);
2652}
2653
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302654QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
2655 qdf_nbuf_t buf,
2656 uint32_t txCompleteSuccess,
2657 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302659 tpAniSirGlobal pMac = (tpAniSirGlobal)context;
2660
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002661 pe_debug("txCompleteSuccess: %d", txCompleteSuccess);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302662
2663 if (buf)
2664 qdf_nbuf_free(buf);
2665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 return lim_send_deauth_cnf(pMac);
2667}
2668
2669/**
2670 * \brief This function is called to send Disassociate frame.
2671 *
2672 *
2673 * \param pMac Pointer to Global MAC structure
2674 *
2675 * \param nReason Indicates the reason that need to be sent in
2676 * Disassociation frame
2677 *
2678 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2679 * sent
2680 *
2681 *
2682 */
2683
2684void
2685lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2686 uint16_t nReason,
2687 tSirMacAddr peer,
2688 tpPESession psessionEntry, bool waitForAck)
2689{
2690 tDot11fDisassociation frm;
2691 uint8_t *pFrame;
2692 tpSirMacMgmtHdr pMacHdr;
2693 uint32_t nBytes, nPayload, nStatus;
2694 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302695 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 uint8_t txFlag = 0;
2697 uint32_t val = 0;
2698 uint8_t smeSessionId = 0;
2699 if (NULL == psessionEntry) {
2700 return;
2701 }
2702
2703 /*
2704 * In case when cac timer is running for this SAP session then
2705 * avoid sending disassoc out. It is violation of dfs specification.
2706 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302707 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2708 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302710 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 FL
2712 ("CAC timer is running, drop disassoc from going out"));
2713 return;
2714 }
2715 smeSessionId = psessionEntry->smeSessionId;
2716
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302717 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718
2719 frm.Reason.code = nReason;
2720
2721 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2722 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002723 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 nStatus);
2725 /* We'll fall back on the worst case scenario: */
2726 nPayload = sizeof(tDot11fDisassociation);
2727 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002728 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2729 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730 }
2731
2732 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2733
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302734 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302736 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002737 pe_err("Failed to allocate %d bytes for a Disassociation",
2738 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 return;
2740 }
2741 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743
2744 /* Next, we fill out the buffer descriptor: */
2745 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2746 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2747 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2748
2749 /* Prepare the BSSID */
2750 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2751
2752#ifdef WLAN_FEATURE_11W
2753 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2754#endif
2755
2756 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2757 sizeof(tSirMacMgmtHdr),
2758 nPayload, &nPayload);
2759 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002760 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 nStatus);
2762 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002763 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002765 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2766 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 }
2768
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002769 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002771 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2773 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2774
2775 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302776 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2777 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 ) {
2779 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2780 }
2781
Sushant Kaushik46556062015-12-02 16:57:47 +05302782 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783
2784 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302785 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 psessionEntry->peSessionId,
2787 pMacHdr->fc.subType));
2788 /* Queue Disassociation frame in high priority WQ */
2789 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302790 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2792 TXRX_FRM_802_11_MGMT,
2793 ANI_TXDIR_TODS, 7, lim_tx_complete,
2794 pFrame, lim_disassoc_tx_complete_cnf,
2795 txFlag, smeSessionId, false, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302796 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302797 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302798 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799
2800 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2801
2802 if (tx_timer_change
2803 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2804 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002805 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 return;
2807 } else if (TX_SUCCESS !=
2808 tx_timer_activate(&pMac->lim.limTimers.
2809 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002810 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 lim_deactivate_and_change_timer(pMac,
2812 eLIM_DISASSOC_ACK_TIMER);
2813 return;
2814 }
2815 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302816 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 psessionEntry->peSessionId,
2818 pMacHdr->fc.subType));
2819 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302820 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 TXRX_FRM_802_11_MGMT,
2822 ANI_TXDIR_TODS,
2823 7,
2824 lim_tx_complete, pFrame, txFlag,
2825 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302826 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302827 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302828 psessionEntry->peSessionId, qdf_status));
2829 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002830 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302831 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 /* Pkt will be freed up by the callback */
2833 }
2834 }
2835} /* End lim_send_disassoc_mgmt_frame. */
2836
2837/**
2838 * \brief This function is called to send a Deauthenticate frame
2839 *
2840 *
2841 * \param pMac Pointer to global MAC structure
2842 *
2843 * \param nReason Indicates the reason that need to be sent in the
2844 * Deauthenticate frame
2845 *
2846 * \param peeer address of the STA to which the frame is to be sent
2847 *
2848 *
2849 */
2850
2851void
2852lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2853 uint16_t nReason,
2854 tSirMacAddr peer,
2855 tpPESession psessionEntry, bool waitForAck)
2856{
2857 tDot11fDeAuth frm;
2858 uint8_t *pFrame;
2859 tpSirMacMgmtHdr pMacHdr;
2860 uint32_t nBytes, nPayload, nStatus;
2861 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302862 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 uint8_t txFlag = 0;
2864 uint32_t val = 0;
2865#ifdef FEATURE_WLAN_TDLS
2866 uint16_t aid;
2867 tpDphHashNode pStaDs;
2868#endif
2869 uint8_t smeSessionId = 0;
2870
2871 if (NULL == psessionEntry) {
2872 return;
2873 }
2874
2875 /*
2876 * In case when cac timer is running for this SAP session then
2877 * avoid deauth frame out. It is violation of dfs specification.
2878 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302879 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2880 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302882 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 FL
2884 ("CAC timer is running, drop the deauth from going out"));
2885 return;
2886 }
2887 smeSessionId = psessionEntry->smeSessionId;
2888
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302889 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890
2891 frm.Reason.code = nReason;
2892
2893 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2894 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002895 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 nStatus);
2897 /* We'll fall back on the worst case scenario: */
2898 nPayload = sizeof(tDot11fDeAuth);
2899 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002900 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
2901 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 }
2903
2904 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2905
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302906 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302908 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002909 pe_err("Failed to allocate %d bytes for a De-Authentication",
2910 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 return;
2912 }
2913 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302914 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915
2916 /* Next, we fill out the buffer descriptor: */
2917 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2918 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2919 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2920
2921 /* Prepare the BSSID */
2922 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2923
2924#ifdef WLAN_FEATURE_11W
2925 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2926#endif
2927
2928 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
2929 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
2930 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002931 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 nStatus);
2933 cds_packet_free((void *)pPacket);
2934 return;
2935 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002936 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
2937 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002939 pe_debug("***Sessionid %d Sending Deauth frame with "
2940 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
2941 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 psessionEntry->peSessionId, nReason, waitForAck,
2943 MAC_ADDR_ARRAY(pMacHdr->da),
2944 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2945
2946 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302947 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2948 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 ) {
2950 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2951 }
2952
Sushant Kaushik46556062015-12-02 16:57:47 +05302953 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954#ifdef FEATURE_WLAN_TDLS
2955 pStaDs =
2956 dph_lookup_hash_entry(pMac, peer, &aid,
2957 &psessionEntry->dph.dphHashTable);
2958#endif
2959
2960 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302961 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 psessionEntry->peSessionId,
2963 pMacHdr->fc.subType));
2964 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302965 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2967 TXRX_FRM_802_11_MGMT,
2968 ANI_TXDIR_TODS, 7, lim_tx_complete,
2969 pFrame, lim_deauth_tx_complete_cnf,
2970 txFlag, smeSessionId, false, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302971 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302972 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302973 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302975 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002976 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302977 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978
2979 /* Call lim_process_deauth_ack_timeout which will send
2980 * DeauthCnf for this frame
2981 */
2982 lim_process_deauth_ack_timeout(pMac);
2983 return;
2984 }
2985
2986 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2987
2988 if (tx_timer_change
2989 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
2990 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002991 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 return;
2993 } else if (TX_SUCCESS !=
2994 tx_timer_activate(&pMac->lim.limTimers.
2995 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002996 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 lim_deactivate_and_change_timer(pMac,
2998 eLIM_DEAUTH_ACK_TIMER);
2999 return;
3000 }
3001 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303002 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 psessionEntry->peSessionId,
3004 pMacHdr->fc.subType));
3005#ifdef FEATURE_WLAN_TDLS
3006 if ((NULL != pStaDs)
3007 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3008 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303009 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3011 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3012 7, lim_tx_complete, pFrame, txFlag,
3013 smeSessionId, 0);
3014 } else {
3015#endif
3016 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303017 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3019 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3020 7, lim_tx_complete, pFrame, txFlag,
3021 smeSessionId, 0);
3022#ifdef FEATURE_WLAN_TDLS
3023 }
3024#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303025 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303026 psessionEntry->peSessionId, qdf_status));
3027 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003028 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303029 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 /* Pkt will be freed up by the callback */
3031 }
3032 }
3033
3034} /* End lim_send_deauth_mgmt_frame. */
3035
3036#ifdef ANI_SUPPORT_11H
3037/**
3038 * \brief Send a Measurement Report Action frame
3039 *
3040 *
3041 * \param pMac Pointer to the global MAC structure
3042 *
3043 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3044 *
3045 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3046 *
3047 *
3048 */
3049
3050tSirRetStatus
3051lim_send_meas_report_frame(tpAniSirGlobal pMac,
3052 tpSirMacMeasReqActionFrame pMeasReqFrame,
3053 tSirMacAddr peer, tpPESession psessionEntry)
3054{
3055 tDot11fMeasurementReport frm;
3056 uint8_t *pFrame;
3057 tSirRetStatus nSirStatus;
3058 tpSirMacMgmtHdr pMacHdr;
3059 uint32_t nBytes, nPayload, nStatus;
3060 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303061 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303063 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064
3065 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3066 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3067 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3068
3069 switch (pMeasReqFrame->measReqIE.measType) {
3070 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3071 nSirStatus =
3072 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3073 &frm.MeasurementReport);
3074 break;
3075 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3076 nSirStatus =
3077 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3078 &frm.MeasurementReport);
3079 break;
3080 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3081 nSirStatus =
3082 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3083 &frm.MeasurementReport);
3084 break;
3085 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003086 pe_err("Unknown measurement type %d in limSen"
3087 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 pMeasReqFrame->measReqIE.measType);
3089 return eSIR_FAILURE;
3090 }
3091
3092 if (eSIR_SUCCESS != nSirStatus)
3093 return eSIR_FAILURE;
3094
3095 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3096 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003097 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 nStatus);
3099 /* We'll fall back on the worst case scenario: */
3100 nPayload = sizeof(tDot11fMeasurementReport);
3101 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003102 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3103 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104 }
3105
3106 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3107
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303108 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3110 (uint16_t) nBytes, (void **)&pFrame,
3111 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303112 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003113 pe_err("Failed to allocate %d bytes for a "
3114 "De-Authentication", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 return eSIR_FAILURE;
3116 }
3117 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119
3120 /* Next, we fill out the buffer descriptor: */
3121 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3122 SIR_MAC_MGMT_ACTION, peer);
3123 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3124
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303125 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126
3127#ifdef WLAN_FEATURE_11W
3128 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3129#endif
3130
3131 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3132 sizeof(tSirMacMgmtHdr),
3133 nPayload, &nPayload);
3134 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003135 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 nStatus);
3137 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3138 (void *)pFrame, (void *)pPacket);
3139 return eSIR_FAILURE; /* allocated! */
3140 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003141 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3142 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 }
3144
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303145 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 ((psessionEntry) ? psessionEntry->
3147 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3150 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3151 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303152 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303153 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303155 qdf_status));
3156 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003157 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303158 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 /* Pkt will be freed up by the callback */
3160 return eSIR_FAILURE; /* just allocated... */
3161 }
3162
3163 return eSIR_SUCCESS;
3164
3165} /* End lim_send_meas_report_frame. */
3166
3167/**
3168 * \brief Send a TPC Request Action frame
3169 *
3170 *
3171 * \param pMac Pointer to the global MAC datastructure
3172 *
3173 * \param peer MAC address to which the frame should be sent
3174 *
3175 *
3176 */
3177
3178void
3179lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3180 tSirMacAddr peer, tpPESession psessionEntry)
3181{
3182 tDot11fTPCRequest frm;
3183 uint8_t *pFrame;
3184 tpSirMacMgmtHdr pMacHdr;
3185 uint32_t nBytes, nPayload, nStatus;
3186 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303187 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303189 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190
3191 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3192 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3193 frm.DialogToken.token = 1;
3194 frm.TPCRequest.present = 1;
3195
3196 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3197 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003198 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 /* We'll fall back on the worst case scenario: */
3200 nPayload = sizeof(tDot11fTPCRequest);
3201 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003202 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3203 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 }
3205
3206 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3207
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303208 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3210 (uint16_t) nBytes, (void **)&pFrame,
3211 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303212 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003213 pe_err("Failed to allocate %d bytes for a TPC"
3214 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 return;
3216 }
3217 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303218 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219
3220 /* Next, we fill out the buffer descriptor: */
3221 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3222 SIR_MAC_MGMT_ACTION, peer);
3223 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303225 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226
3227#ifdef WLAN_FEATURE_11W
3228 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3229#endif
3230
3231 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3232 sizeof(tSirMacMgmtHdr),
3233 nPayload, &nPayload);
3234 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003235 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 nStatus);
3237 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3238 (void *)pFrame, (void *)pPacket);
3239 return; /* allocated! */
3240 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003241 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3242 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 }
3244
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303245 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 ((psessionEntry) ? psessionEntry->
3247 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3250 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3251 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303252 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303253 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303255 qdf_status));
3256 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003257 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303258 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 /* Pkt will be freed up by the callback */
3260 }
3261
3262} /* End lim_send_tpc_request_frame. */
3263
3264/**
3265 * \brief Send a TPC Report Action frame
3266 *
3267 *
3268 * \param pMac Pointer to the global MAC datastructure
3269 *
3270 * \param pTpcReqFrame Pointer to the received TPC Request
3271 *
3272 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3273 *
3274 *
3275 */
3276
3277tSirRetStatus
3278lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3279 tpSirMacTpcReqActionFrame pTpcReqFrame,
3280 tSirMacAddr peer, tpPESession psessionEntry)
3281{
3282 tDot11fTPCReport frm;
3283 uint8_t *pFrame;
3284 tpSirMacMgmtHdr pMacHdr;
3285 uint32_t nBytes, nPayload, nStatus;
3286 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303289 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290
3291 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3292 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3293 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3294
3295 frm.TPCReport.tx_power = 0;
3296 frm.TPCReport.link_margin = 0;
3297 frm.TPCReport.present = 1;
3298
3299 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3300 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003301 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 /* We'll fall back on the worst case scenario: */
3303 nPayload = sizeof(tDot11fTPCReport);
3304 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003305 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3306 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 }
3308
3309 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3310
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303311 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3313 (uint16_t) nBytes, (void **)&pFrame,
3314 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303315 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003316 pe_err("Failed to allocate %d bytes for a TPC"
3317 " Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 return eSIR_FAILURE;
3319 }
3320 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303321 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322
3323 /* Next, we fill out the buffer descriptor: */
3324 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3325 SIR_MAC_MGMT_ACTION, peer);
3326
3327 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3328
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303329 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330
3331#ifdef WLAN_FEATURE_11W
3332 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3333#endif
3334
3335 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3336 sizeof(tSirMacMgmtHdr),
3337 nPayload, &nPayload);
3338 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003339 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 nStatus);
3341 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3342 (void *)pFrame, (void *)pPacket);
3343 return eSIR_FAILURE; /* allocated! */
3344 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003345 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3346 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303348 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 ((psessionEntry) ? psessionEntry->
3350 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303351 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3353 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
3354 lim_tx_complete, pFrame, 0, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303355 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003356 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3357 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3358 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303359 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003360 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303361 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 /* Pkt will be freed up by the callback */
3363 return eSIR_FAILURE; /* just allocated... */
3364 }
3365
3366 return eSIR_SUCCESS;
3367
3368} /* End lim_send_tpc_report_frame. */
3369#endif /* ANI_SUPPORT_11H */
3370
3371/**
3372 * \brief Send a Channel Switch Announcement
3373 *
3374 *
3375 * \param pMac Pointer to the global MAC datastructure
3376 *
3377 * \param peer MAC address to which this frame will be sent
3378 *
3379 * \param nMode
3380 *
3381 * \param nNewChannel
3382 *
3383 * \param nCount
3384 *
3385 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3386 *
3387 *
3388 */
3389
3390tSirRetStatus
3391lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3392 tSirMacAddr peer,
3393 uint8_t nMode,
3394 uint8_t nNewChannel,
3395 uint8_t nCount, tpPESession psessionEntry)
3396{
3397 tDot11fChannelSwitch frm;
3398 uint8_t *pFrame;
3399 tpSirMacMgmtHdr pMacHdr;
3400 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3401 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303402 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 uint8_t txFlag = 0;
3404
3405 uint8_t smeSessionId = 0;
3406
3407 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003408 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 return eSIR_FAILURE;
3410 }
3411 smeSessionId = psessionEntry->smeSessionId;
3412
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303413 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414
3415 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3416 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3417 frm.ChanSwitchAnn.switchMode = nMode;
3418 frm.ChanSwitchAnn.newChannel = nNewChannel;
3419 frm.ChanSwitchAnn.switchCount = nCount;
3420 frm.ChanSwitchAnn.present = 1;
3421
3422 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3423 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003424 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 nStatus);
3426 /* We'll fall back on the worst case scenario: */
3427 nPayload = sizeof(tDot11fChannelSwitch);
3428 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003429 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3430 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 }
3432
3433 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3434
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303435 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3437 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303438 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003439 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 return eSIR_FAILURE;
3441 }
3442 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303443 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444
3445 /* Next, we fill out the buffer descriptor: */
3446 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3447 SIR_MAC_MGMT_ACTION, peer,
3448 psessionEntry->selfMacAddr);
3449 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303450 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003451 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3452
3453#ifdef WLAN_FEATURE_11W
3454 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3455#endif
3456
3457 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3458 sizeof(tSirMacMgmtHdr),
3459 nPayload, &nPayload);
3460 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003461 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 nStatus);
3463 cds_packet_free((void *)pPacket);
3464 return eSIR_FAILURE; /* allocated! */
3465 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003466 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3467 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 }
3469
3470 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303471 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3472 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 ) {
3474 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3475 }
3476
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303477 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303479 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 TXRX_FRM_802_11_MGMT,
3481 ANI_TXDIR_TODS,
3482 7, lim_tx_complete, pFrame, txFlag,
3483 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303484 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303485 psessionEntry->peSessionId, qdf_status));
3486 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003487 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303488 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 /* Pkt will be freed up by the callback */
3490 return eSIR_FAILURE;
3491 }
3492
3493 return eSIR_SUCCESS;
3494
3495} /* End lim_send_channel_switch_mgmt_frame. */
3496
Abhishek Singh518323d2015-10-19 17:42:01 +05303497/**
3498 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3499 * action frame over the air .
3500 * @mac_ctx: pointer to global mac structure
3501 * @peer: Destination mac.
3502 * @mode: channel switch mode
3503 * @new_op_class: new op class
3504 * @new_channel: new channel to switch
3505 * @count: channel switch count
3506 *
3507 * This function is called to send ECSA frame.
3508 *
3509 * Return: success if frame is sent else return failure
3510 */
3511
3512tSirRetStatus
3513lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3514 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3515 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3516{
3517 tDot11fext_channel_switch_action_frame frm;
3518 uint8_t *frame;
3519 tpSirMacMgmtHdr mac_hdr;
3520 uint32_t num_bytes, n_payload, status;
3521 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303523 uint8_t txFlag = 0;
3524 uint8_t sme_session_id = 0;
3525
3526 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003527 pe_err("Session entry is NULL!!!");
Abhishek Singh518323d2015-10-19 17:42:01 +05303528 return eSIR_FAILURE;
3529 }
3530
3531 sme_session_id = session_entry->smeSessionId;
3532
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303533 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303534
3535 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3536 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3537
3538 frm.ext_chan_switch_ann_action.switch_mode = mode;
3539 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3540 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3541 frm.ext_chan_switch_ann_action.switch_count = count;
3542
3543
3544 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3545 &frm, &n_payload);
3546 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003547 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303548 status);
3549 /* We'll fall back on the worst case scenario*/
3550 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3551 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003552 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303553 status);
3554 }
3555
3556 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3557
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303559 (void **) &frame, (void **) &packet);
3560
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303561 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003562 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303563 num_bytes);
3564 return eSIR_FAILURE;
3565 }
3566
3567 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303568 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303569
3570 /* Next, we fill out the buffer descriptor */
3571 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3572 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3573 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303574 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303575 (uint8_t *) session_entry->bssId,
3576 sizeof(tSirMacAddr));
3577
3578 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3579 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3580 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003581 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303582 cds_packet_free((void *)packet);
3583 return eSIR_FAILURE;
3584 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003585 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303586 status);
3587 }
3588
3589 if ((SIR_BAND_5_GHZ ==
3590 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303591 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3592 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303593 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3594 }
3595
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003596 pe_debug("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05303597 MAC_ADDR_ARRAY(mac_hdr->da),
3598 frm.ext_chan_switch_ann_action.switch_count,
3599 frm.ext_chan_switch_ann_action.switch_mode,
3600 frm.ext_chan_switch_ann_action.new_channel,
3601 frm.ext_chan_switch_ann_action.op_class);
3602
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303603 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303604 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303605 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303606 TXRX_FRM_802_11_MGMT,
3607 ANI_TXDIR_TODS,
3608 7,
3609 lim_tx_complete, frame,
3610 txFlag, sme_session_id, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303611 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303612 session_entry->peSessionId, qdf_status));
3613 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003614 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303615 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303616 /* Pkt will be freed up by the callback */
3617 return eSIR_FAILURE;
3618 }
3619 return eSIR_SUCCESS;
3620} /* End lim_send_extended_chan_switch_action_frame */
3621
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303622
3623/**
3624 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3625 * sent over the air
3626 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303627 * @context: pointer to global mac
3628 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303629 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303630 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303631 *
3632 * Return: This returns QDF_STATUS
3633 */
3634
3635static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303636 void *context,
3637 qdf_nbuf_t buf,
3638 uint32_t tx_complete,
3639 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303640{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003641 pe_debug("tx_complete: %d", tx_complete);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303642 return QDF_STATUS_SUCCESS;
3643}
3644
3645/**
3646 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3647 * p2p oper chan change confirm action frame
3648 * @mac_ctx: pointer to global mac structure
3649 * @peer: Destination mac.
3650 * @session_entry: session entry
3651 *
3652 * This function is called to send p2p oper chan change confirm action frame.
3653 *
3654 * Return: success if frame is sent else return failure
3655 */
3656
3657tSirRetStatus
3658lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3659 tSirMacAddr peer, tpPESession session_entry)
3660{
3661 tDot11fp2p_oper_chan_change_confirm frm;
3662 uint8_t *frame;
3663 tpSirMacMgmtHdr mac_hdr;
3664 uint32_t num_bytes, n_payload, status;
3665 void *packet;
3666 QDF_STATUS qdf_status;
3667 uint8_t tx_flag = 0;
3668 uint8_t sme_session_id = 0;
3669
3670 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003671 pe_err("Session entry is NULL!!!");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303672 return eSIR_FAILURE;
3673 }
3674
3675 sme_session_id = session_entry->smeSessionId;
3676
3677 qdf_mem_set(&frm, sizeof(frm), 0);
3678
3679 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3680
3681 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3682 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3683 frm.p2p_action_subtype.subtype = 0x04;
3684 frm.DialogToken.token = 0x0;
3685
3686 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003687 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303688 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3689 }
3690
3691 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003692 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303693 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3694 populate_dot11f_operating_mode(mac_ctx,
3695 &frm.OperatingMode, session_entry);
3696 }
3697
3698 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3699 &frm, &n_payload);
3700 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003701 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303702 /* We'll fall back on the worst case scenario*/
3703 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3704 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003705 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3706 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303707 }
3708
3709 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3710
3711 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3712 (void **) &frame, (void **) &packet);
3713
3714 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003715 pe_err("Failed to allocate %d bytes", num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303716 return eSIR_FAILURE;
3717 }
3718
3719 qdf_mem_set(frame, num_bytes, 0);
3720
3721 /* Next, fill out the buffer descriptor */
3722 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3723 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3724 mac_hdr = (tpSirMacMgmtHdr) frame;
3725 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3726 (uint8_t *) session_entry->bssId,
3727 sizeof(tSirMacAddr));
3728
3729 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3730 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3731 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003732 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303733 cds_packet_free((void *)packet);
3734 return eSIR_FAILURE;
3735 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003736 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303737 status);
3738 }
3739
3740 if ((SIR_BAND_5_GHZ ==
3741 lim_get_rf_band(session_entry->currentOperChannel)) ||
3742 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3743 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3744 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3745 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003746 pe_debug("Send frame on channel %d to mac "
3747 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303748 MAC_ADDR_ARRAY(peer));
3749
3750 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3751 session_entry->peSessionId, mac_hdr->fc.subType));
3752
3753 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3754 (uint16_t)num_bytes,
3755 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3756 7, lim_tx_complete, frame,
3757 lim_oper_chan_change_confirm_tx_complete_cnf,
3758 tx_flag, sme_session_id, false, 0);
3759
3760 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3761 session_entry->peSessionId, qdf_status));
3762 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003763 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303764 /* Pkt will be freed up by the callback */
3765 return eSIR_FAILURE;
3766 }
3767 return eSIR_SUCCESS;
3768}
3769
3770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771tSirRetStatus
3772lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3773 tSirMacAddr peer,
3774 uint8_t nMode, tpPESession psessionEntry)
3775{
3776 tDot11fOperatingMode frm;
3777 uint8_t *pFrame;
3778 tpSirMacMgmtHdr pMacHdr;
3779 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3780 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 uint8_t txFlag = 0;
3783
3784 uint8_t smeSessionId = 0;
3785
3786 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003787 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 return eSIR_FAILURE;
3789 }
3790 smeSessionId = psessionEntry->smeSessionId;
3791
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303792 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793
3794 frm.Category.category = SIR_MAC_ACTION_VHT;
3795 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3796 frm.OperatingMode.chanWidth = nMode;
3797 frm.OperatingMode.rxNSS = 0;
3798 frm.OperatingMode.rxNSSType = 0;
3799
3800 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3801 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003802 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 nStatus);
3804 /* We'll fall back on the worst case scenario: */
3805 nPayload = sizeof(tDot11fOperatingMode);
3806 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003807 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3808 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 }
3810
3811 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3812
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303813 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3815 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003817 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
3818 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 return eSIR_FAILURE;
3820 }
3821 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303822 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823
3824 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303825 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3827 SIR_MAC_MGMT_ACTION, peer,
3828 psessionEntry->selfMacAddr);
3829 else
3830 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3831 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3832 psessionEntry->selfMacAddr);
3833 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303834 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3836 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3837 sizeof(tSirMacMgmtHdr),
3838 nPayload, &nPayload);
3839 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003840 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 nStatus);
3842 cds_packet_free((void *)pPacket);
3843 return eSIR_FAILURE; /* allocated! */
3844 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003845 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
3846 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 }
3848 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303849 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3850 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 ) {
3852 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3853 }
3854
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303855 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 TXRX_FRM_802_11_MGMT,
3859 ANI_TXDIR_TODS,
3860 7, lim_tx_complete, pFrame, txFlag,
3861 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303862 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303863 psessionEntry->peSessionId, qdf_status));
3864 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003865 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303866 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867 /* Pkt will be freed up by the callback */
3868 return eSIR_FAILURE;
3869 }
3870
3871 return eSIR_SUCCESS;
3872}
3873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874/**
3875 * \brief Send a Neighbor Report Request Action frame
3876 *
3877 *
3878 * \param pMac Pointer to the global MAC structure
3879 *
3880 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3881 *
3882 * \param peer mac address of peer station.
3883 *
3884 * \param psessionEntry address of session entry.
3885 *
3886 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3887 *
3888 *
3889 */
3890
3891tSirRetStatus
3892lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3893 tpSirMacNeighborReportReq pNeighborReq,
3894 tSirMacAddr peer, tpPESession psessionEntry)
3895{
3896 tSirRetStatus statusCode = eSIR_SUCCESS;
3897 tDot11fNeighborReportRequest frm;
3898 uint8_t *pFrame;
3899 tpSirMacMgmtHdr pMacHdr;
3900 uint32_t nBytes, nPayload, nStatus;
3901 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303902 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 uint8_t txFlag = 0;
3904 uint8_t smeSessionId = 0;
3905
3906 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003907 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 return eSIR_FAILURE;
3909 }
3910 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303911 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912
3913 frm.Category.category = SIR_MAC_ACTION_RRM;
3914 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
3915 frm.DialogToken.token = pNeighborReq->dialogToken;
3916
3917 if (pNeighborReq->ssid_present) {
3918 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
3919 }
3920
3921 nStatus =
3922 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
3923 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003924 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 nStatus);
3926 /* We'll fall back on the worst case scenario: */
3927 nPayload = sizeof(tDot11fNeighborReportRequest);
3928 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003929 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
3930 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 }
3932
3933 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303935 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3937 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303938 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003939 pe_err("Failed to allocate %d bytes for a Neighbor "
3940 "Report Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 return eSIR_FAILURE;
3942 }
3943 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303944 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945
3946 /* Copy necessary info to BD */
3947 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3948 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
3949
3950 /* Update A3 with the BSSID */
3951 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3952
3953 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3954
3955#ifdef WLAN_FEATURE_11W
3956 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3957#endif
3958
3959 /* Now, we're ready to "pack" the frames */
3960 nStatus = dot11f_pack_neighbor_report_request(pMac,
3961 &frm,
3962 pFrame +
3963 sizeof(tSirMacMgmtHdr),
3964 nPayload, &nPayload);
3965
3966 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003967 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 nStatus);
3969
3970 /* FIXME - Need to convert to tSirRetStatus */
3971 statusCode = eSIR_FAILURE;
3972 goto returnAfterError;
3973 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003974 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
3975 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976 }
3977
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003978 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05303979 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980
3981 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303982 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3983 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 ) {
3985 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3986 }
3987
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303988 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303990 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 pPacket,
3992 (uint16_t) nBytes,
3993 TXRX_FRM_802_11_MGMT,
3994 ANI_TXDIR_TODS,
3995 7, lim_tx_complete, pFrame, txFlag,
3996 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303997 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303998 psessionEntry->peSessionId, qdf_status));
3999 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004000 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001 statusCode = eSIR_FAILURE;
4002 /* Pkt will be freed up by the callback */
4003 return statusCode;
4004 } else
4005 return eSIR_SUCCESS;
4006
4007returnAfterError:
4008 cds_packet_free((void *)pPacket);
4009
4010 return statusCode;
4011} /* End lim_send_neighbor_report_request_frame. */
4012
4013/**
4014 * \brief Send a Link Report Action frame
4015 *
4016 *
4017 * \param pMac Pointer to the global MAC structure
4018 *
4019 * \param pLinkReport Address of a tSirMacLinkReport
4020 *
4021 * \param peer mac address of peer station.
4022 *
4023 * \param psessionEntry address of session entry.
4024 *
4025 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4026 *
4027 *
4028 */
4029
4030tSirRetStatus
4031lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4032 tpSirMacLinkReport pLinkReport,
4033 tSirMacAddr peer, tpPESession psessionEntry)
4034{
4035 tSirRetStatus statusCode = eSIR_SUCCESS;
4036 tDot11fLinkMeasurementReport frm;
4037 uint8_t *pFrame;
4038 tpSirMacMgmtHdr pMacHdr;
4039 uint32_t nBytes, nPayload, nStatus;
4040 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 uint8_t txFlag = 0;
4043 uint8_t smeSessionId = 0;
4044
4045 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004046 pe_err("(psession == NULL) in Request to send Link Report action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 return eSIR_FAILURE;
4048 }
4049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051
4052 frm.Category.category = SIR_MAC_ACTION_RRM;
4053 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4054 frm.DialogToken.token = pLinkReport->dialogToken;
4055
4056 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4057 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4058 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4059 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4060 /* such case this way than changing the frame parser. */
4061 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4062 frm.TPCEleLen.TPCLen = 2;
4063 frm.TxPower.txPower = pLinkReport->txPower;
4064 frm.LinkMargin.linkMargin = 0;
4065
4066 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4067 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4068 frm.RCPI.rcpi = pLinkReport->rcpi;
4069 frm.RSNI.rsni = pLinkReport->rsni;
4070
4071 nStatus =
4072 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4073 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004074 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 /* We'll fall back on the worst case scenario: */
4076 nPayload = sizeof(tDot11fLinkMeasurementReport);
4077 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004078 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4079 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 }
4081
4082 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4086 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304087 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004088 pe_err("Failed to allocate %d bytes for a Link "
4089 "Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 return eSIR_FAILURE;
4091 }
4092 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304093 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094
4095 /* Copy necessary info to BD */
4096 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4097 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4098
4099 /* Update A3 with the BSSID */
4100 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4101
4102 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4103
4104#ifdef WLAN_FEATURE_11W
4105 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4106#endif
4107
4108 /* Now, we're ready to "pack" the frames */
4109 nStatus = dot11f_pack_link_measurement_report(pMac,
4110 &frm,
4111 pFrame +
4112 sizeof(tSirMacMgmtHdr),
4113 nPayload, &nPayload);
4114
4115 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004116 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117
4118 /* FIXME - Need to convert to tSirRetStatus */
4119 statusCode = eSIR_FAILURE;
4120 goto returnAfterError;
4121 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004122 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 nStatus);
4124 }
4125
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004126 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 lim_print_mac_addr(pMac, peer, LOGW);
4128
4129 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304130 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4131 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4133 }
4134
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304135 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304137 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 pPacket,
4139 (uint16_t) nBytes,
4140 TXRX_FRM_802_11_MGMT,
4141 ANI_TXDIR_TODS,
4142 7, lim_tx_complete, pFrame, txFlag,
4143 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304144 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304145 psessionEntry->peSessionId, qdf_status));
4146 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004147 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 statusCode = eSIR_FAILURE;
4149 /* Pkt will be freed up by the callback */
4150 return statusCode;
4151 } else
4152 return eSIR_SUCCESS;
4153
4154returnAfterError:
4155 cds_packet_free((void *)pPacket);
4156
4157 return statusCode;
4158} /* End lim_send_link_report_action_frame. */
4159
4160/**
4161 * \brief Send a Beacon Report Action frame
4162 *
4163 *
4164 * \param pMac Pointer to the global MAC structure
4165 *
4166 * \param dialog_token dialog token to be used in the action frame.
4167 *
4168 * \param num_report number of reports in pRRMReport.
4169 *
4170 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
4171 *
4172 * \param peer mac address of peer station.
4173 *
4174 * \param psessionEntry address of session entry.
4175 *
4176 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4177 *
4178 *
4179 */
4180
4181tSirRetStatus
4182lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
4183 uint8_t dialog_token,
4184 uint8_t num_report,
4185 tpSirMacRadioMeasureReport pRRMReport,
4186 tSirMacAddr peer,
4187 tpPESession psessionEntry)
4188{
4189 tSirRetStatus statusCode = eSIR_SUCCESS;
4190 uint8_t *pFrame;
4191 tpSirMacMgmtHdr pMacHdr;
4192 uint32_t nBytes, nPayload, nStatus;
4193 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304194 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 uint8_t i;
4196 uint8_t txFlag = 0;
4197 uint8_t smeSessionId = 0;
4198
4199 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304200 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004202 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 return eSIR_MEM_ALLOC_FAILED;
4204 }
4205
4206 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004207 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304208 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 return eSIR_FAILURE;
4210 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004212 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304213 dialog_token, num_report);
4214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 frm->Category.category = SIR_MAC_ACTION_RRM;
4216 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4217 frm->DialogToken.token = dialog_token;
4218
4219 frm->num_MeasurementReport =
4220 (num_report >
4221 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4222 num_report;
4223
4224 for (i = 0; i < frm->num_MeasurementReport; i++) {
4225 frm->MeasurementReport[i].type = pRRMReport[i].type;
4226 frm->MeasurementReport[i].token = pRRMReport[i].token;
4227 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4228 switch (pRRMReport[i].type) {
4229 case SIR_MAC_RRM_BEACON_TYPE:
4230 populate_dot11f_beacon_report(pMac,
4231 &frm->MeasurementReport[i],
4232 &pRRMReport[i].report.
4233 beaconReport);
4234 frm->MeasurementReport[i].incapable =
4235 pRRMReport[i].incapable;
4236 frm->MeasurementReport[i].refused =
4237 pRRMReport[i].refused;
4238 frm->MeasurementReport[i].present = 1;
4239 break;
4240 default:
4241 frm->MeasurementReport[i].incapable =
4242 pRRMReport[i].incapable;
4243 frm->MeasurementReport[i].refused =
4244 pRRMReport[i].refused;
4245 frm->MeasurementReport[i].present = 1;
4246 break;
4247 }
4248 }
4249
4250 nStatus =
4251 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4252 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004253 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 nStatus);
4255 /* We'll fall back on the worst case scenario: */
4256 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304257 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 return eSIR_FAILURE;
4259 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004260 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4261 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 }
4263
4264 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4265
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304266 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4268 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304269 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004270 pe_err("Failed to allocate %d bytes for a Radio Measure "
4271 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304272 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 return eSIR_FAILURE;
4274 }
4275 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304276 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277
4278 /* Copy necessary info to BD */
4279 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4280 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4281
4282 /* Update A3 with the BSSID */
4283 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4284
4285 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4286
4287#ifdef WLAN_FEATURE_11W
4288 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4289#endif
4290
4291 /* Now, we're ready to "pack" the frames */
4292 nStatus = dot11f_pack_radio_measurement_report(pMac,
4293 frm,
4294 pFrame +
4295 sizeof(tSirMacMgmtHdr),
4296 nPayload, &nPayload);
4297
4298 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004299 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 nStatus);
4301
4302 /* FIXME - Need to convert to tSirRetStatus */
4303 statusCode = eSIR_FAILURE;
4304 goto returnAfterError;
4305 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004306 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4307 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 }
4309
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004310 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 lim_print_mac_addr(pMac, peer, LOGW);
4312
4313 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304314 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4315 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 ) {
4317 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4318 }
4319
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304320 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304322 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 pPacket,
4324 (uint16_t) nBytes,
4325 TXRX_FRM_802_11_MGMT,
4326 ANI_TXDIR_TODS,
4327 7, lim_tx_complete, pFrame, txFlag,
4328 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304329 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304330 psessionEntry->peSessionId, qdf_status));
4331 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004332 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 statusCode = eSIR_FAILURE;
4334 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304335 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 return statusCode;
4337 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304338 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 return eSIR_SUCCESS;
4340 }
4341
4342returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304343 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 cds_packet_free((void *)pPacket);
4345 return statusCode;
4346}
4347
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348#ifdef WLAN_FEATURE_11W
4349/**
4350 * \brief Send SA query request action frame to peer
4351 *
4352 * \sa lim_send_sa_query_request_frame
4353 *
4354 *
4355 * \param pMac The global tpAniSirGlobal object
4356 *
4357 * \param transId Transaction identifier
4358 *
4359 * \param peer The Mac address of the station to which this action frame is addressed
4360 *
4361 * \param psessionEntry The PE session entry
4362 *
4363 * \return eSIR_SUCCESS if setup completes successfully
4364 * eSIR_FAILURE is some problem is encountered
4365 */
4366
4367tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4368 tSirMacAddr peer,
4369 tpPESession psessionEntry)
4370{
4371
4372 tDot11fSaQueryReq frm; /* SA query request action frame */
4373 uint8_t *pFrame;
4374 tSirRetStatus nSirStatus;
4375 tpSirMacMgmtHdr pMacHdr;
4376 uint32_t nBytes, nPayload, nStatus;
4377 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304378 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 uint8_t txFlag = 0;
4380 uint8_t smeSessionId = 0;
4381
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304382 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4384 /* 11w action field is :
4385 action: 0 --> SA Query Request action frame
4386 action: 1 --> SA Query Response action frame */
4387 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4388 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304389 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390
4391 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4392 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004393 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 nStatus);
4395 /* We'll fall back on the worst case scenario: */
4396 nPayload = sizeof(tDot11fSaQueryReq);
4397 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004398 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4399 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 }
4401
4402 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304403 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304405 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004406 pe_err("Failed to allocate %d bytes for a SA Query Request "
4407 "action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 return eSIR_FAILURE;
4409 }
4410 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304411 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412
4413 /* Copy necessary info to BD */
4414 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4415 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4416
4417 /* Update A3 with the BSSID */
4418 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4419
4420 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4421
4422 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4423 /* in the FC */
4424 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4425
4426 /* Pack 11w SA Query Request frame */
4427 nStatus = dot11f_pack_sa_query_req(pMac,
4428 &frm,
4429 pFrame + sizeof(tSirMacMgmtHdr),
4430 nPayload, &nPayload);
4431
4432 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004433 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 nStatus);
4435 /* FIXME - Need to convert to tSirRetStatus */
4436 nSirStatus = eSIR_FAILURE;
4437 goto returnAfterError;
4438 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004439 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 nStatus);
4441 }
4442
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004443 pe_debug("Sending an SA Query Request to");
4444 lim_print_mac_addr(pMac, peer, LOGD);
4445 pe_debug("Sending an SA Query Request from ");
4446 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447
4448 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
4449#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304450 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4451 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452#endif
4453 ) {
4454 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4455 }
4456 smeSessionId = psessionEntry->smeSessionId;
4457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304458 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 pPacket,
4460 (uint16_t) nBytes,
4461 TXRX_FRM_802_11_MGMT,
4462 ANI_TXDIR_TODS,
4463 7, lim_tx_complete, pFrame, txFlag,
4464 smeSessionId, 0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304465 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004466 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 nSirStatus = eSIR_FAILURE;
4468 /* Pkt will be freed up by the callback */
4469 return nSirStatus;
4470 } else {
4471 return eSIR_SUCCESS;
4472 }
4473
4474returnAfterError:
4475 cds_packet_free((void *)pPacket);
4476 return nSirStatus;
4477} /* End lim_send_sa_query_request_frame */
4478
4479/**
4480 * \brief Send SA query response action frame to peer
4481 *
4482 * \sa lim_send_sa_query_response_frame
4483 *
4484 *
4485 * \param pMac The global tpAniSirGlobal object
4486 *
4487 * \param transId Transaction identifier received in SA query request action frame
4488 *
4489 * \param peer The Mac address of the AP to which this action frame is addressed
4490 *
4491 * \param psessionEntry The PE session entry
4492 *
4493 * \return eSIR_SUCCESS if setup completes successfully
4494 * eSIR_FAILURE is some problem is encountered
4495 */
4496
4497tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4498 uint8_t *transId, tSirMacAddr peer,
4499 tpPESession psessionEntry)
4500{
4501
4502 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4503 uint8_t *pFrame;
4504 tSirRetStatus nSirStatus;
4505 tpSirMacMgmtHdr pMacHdr;
4506 uint32_t nBytes, nPayload, nStatus;
4507 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304508 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 uint8_t txFlag = 0;
4510 uint8_t smeSessionId = 0;
4511
4512 smeSessionId = psessionEntry->smeSessionId;
4513
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304514 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4516 /*11w action field is :
4517 action: 0 --> SA query request action frame
4518 action: 1 --> SA query response action frame */
4519 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4520 /*11w SA query response transId is same as
4521 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304522 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523
4524 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4525 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004526 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 nStatus);
4528 /* We'll fall back on the worst case scenario: */
4529 nPayload = sizeof(tDot11fSaQueryRsp);
4530 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004531 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4532 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 }
4534
4535 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304536 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304538 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004539 pe_err("Failed to allocate %d bytes for a SA query response"
4540 " action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541 return eSIR_FAILURE;
4542 }
4543 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304544 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545
4546 /* Copy necessary info to BD */
4547 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4548 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4549
4550 /* Update A3 with the BSSID */
4551 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4552
4553 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4554
4555 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4556 /* in the FC */
4557 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4558
4559 /* Pack 11w SA query response frame */
4560 nStatus = dot11f_pack_sa_query_rsp(pMac,
4561 &frm,
4562 pFrame + sizeof(tSirMacMgmtHdr),
4563 nPayload, &nPayload);
4564
4565 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004566 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 nStatus);
4568 /* FIXME - Need to convert to tSirRetStatus */
4569 nSirStatus = eSIR_FAILURE;
4570 goto returnAfterError;
4571 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004572 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 nStatus);
4574 }
4575
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004576 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004577 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578
4579 if ((SIR_BAND_5_GHZ == lim_get_rf_band(psessionEntry->currentOperChannel))
4580#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304581 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4582 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583#endif
4584 ) {
4585 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4586 }
4587
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304588 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304590 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 pPacket,
4592 (uint16_t) nBytes,
4593 TXRX_FRM_802_11_MGMT,
4594 ANI_TXDIR_TODS,
4595 7, lim_tx_complete, pFrame, txFlag,
4596 smeSessionId, 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304597 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304598 psessionEntry->peSessionId, qdf_status));
4599 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004600 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 nSirStatus = eSIR_FAILURE;
4602 /* Pkt will be freed up by the callback */
4603 return nSirStatus;
4604 } else {
4605 return eSIR_SUCCESS;
4606 }
4607
4608returnAfterError:
4609 cds_packet_free((void *)pPacket);
4610 return nSirStatus;
4611} /* End lim_send_sa_query_response_frame */
4612#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004613
4614/**
4615 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4616 * @mac_ctx: mac context
4617 * @peer_mac: Peer MAC address
4618 * @tid: TID for which addba response is being sent
4619 * @session: PE session entry
4620 *
4621 * This function is called when ADDBA request is successful. ADDBA response is
4622 * setup by calling addba_response_setup API and frame is then sent out OTA.
4623 *
4624 * Return: QDF_STATUS
4625 */
4626QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
4627 tSirMacAddr peer_mac, uint16_t tid, tpPESession session)
4628{
4629
4630 tDot11faddba_rsp frm;
4631 uint8_t *frame_ptr;
4632 tpSirMacMgmtHdr mgmt_hdr;
4633 uint32_t num_bytes, payload_size, status;
4634 void *pkt_ptr;
4635 QDF_STATUS qdf_status;
4636 uint8_t tx_flag = 0;
4637 uint8_t sme_sessionid = 0;
4638 uint16_t buff_size, status_code, batimeout;
4639 uint8_t peer_id, dialog_token;
4640 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4641 void *peer, *pdev;
4642
4643 sme_sessionid = session->smeSessionId;
4644
4645 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4646 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004647 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004648 return QDF_STATUS_E_FAILURE;
4649 }
4650
4651 peer = cdp_peer_find_by_addr(soc, pdev, peer_mac, &peer_id);
4652 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004653 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004654 return QDF_STATUS_E_FAILURE;
4655 }
4656
4657 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4658 &status_code, &buff_size, &batimeout);
4659
4660 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4661 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4662 frm.Action.action = SIR_MAC_ADDBA_RSP;
4663
4664 frm.DialogToken.token = dialog_token;
4665 frm.Status.status = status_code;
4666 frm.addba_param_set.tid = tid;
4667 frm.addba_param_set.buff_size = buff_size;
4668 frm.addba_param_set.amsdu_supp = SIR_MAC_BA_POLICY_IMMEDIATE;
4669 frm.addba_param_set.policy = SIR_MAC_BA_AMSDU_SUPPORTED;
4670 frm.ba_timeout.timeout = batimeout;
4671
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004672 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004673 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004674 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004675 tid, frm.DialogToken.token, frm.Status.status,
4676 frm.addba_param_set.buff_size);
4677
4678 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4679 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004680 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004681 status);
4682 /* We'll fall back on the worst case scenario: */
4683 payload_size = sizeof(tDot11faddba_rsp);
4684 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004685 pe_warn("There were warnings while calculating the packed size for a ADDBA Response (0x%08x).", status);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004686 }
4687
4688 num_bytes = payload_size + sizeof(*mgmt_hdr);
4689 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4690 (void **)&pkt_ptr);
4691 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004692 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4693 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004694 return QDF_STATUS_E_FAILURE;
4695 }
4696 qdf_mem_set(frame_ptr, num_bytes, 0);
4697
4698 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4699 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4700
4701 /* Update A3 with the BSSID */
4702 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4703 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4704
4705 /* ADDBA Response is a robust mgmt action frame,
4706 * set the "protect" (aka WEP) bit in the FC
4707 */
4708 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4709
4710 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4711 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4712 &payload_size);
4713
4714 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004715 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004716 status);
4717 qdf_status = QDF_STATUS_E_FAILURE;
4718 goto error_addba_rsp;
4719 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004720 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004721 status);
4722 }
4723
4724
4725 if ((SIR_BAND_5_GHZ == lim_get_rf_band(session->currentOperChannel))
4726#ifdef WLAN_FEATURE_P2P
4727 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4728 (session->pePersona == QDF_P2P_GO_MODE)
4729#endif
4730 ) {
4731 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4732 }
4733
4734 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4735 session->peSessionId, mgmt_hdr->fc.subType));
4736 qdf_status = wma_tx_frame(mac_ctx, pkt_ptr, (uint16_t) num_bytes,
4737 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
4738 lim_tx_complete, frame_ptr, tx_flag, sme_sessionid, 0);
4739 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4740 session->peSessionId, qdf_status));
4741 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004742 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004743 qdf_status);
4744 qdf_status = QDF_STATUS_E_FAILURE;
4745 /*
4746 * wma_tx_frame free memory in certain cases, free pkt_ptr
4747 * only if not freed already.
4748 */
4749 if (pkt_ptr)
4750 cds_packet_free((void *)pkt_ptr);
4751 return qdf_status;
4752 } else {
4753 return eSIR_SUCCESS;
4754 }
4755
4756error_addba_rsp:
4757 cds_packet_free((void *)pkt_ptr);
4758 return qdf_status;
4759}