blob: 414d221694669948a8c955263fbd212aa6ccff63 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002 * Copyright (c) 2011-2018 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;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530233 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234
235 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
236 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
237 * is false and dot11mode is 11ac set it to 11n.
238 */
239 if (channel <= SIR_11B_CHANNEL_END &&
240 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
241 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
242 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
243 dot11mode = WNI_CFG_DOT11_MODE_11N;
244 /*
245 * session context may or may not be present, when probe request needs
246 * to be sent out. Following cases exist:
247 * --heartbeat failure: session needed
248 * --join req: session needed
249 * --foreground scan: no session
250 * --background scan: no session
251 * --sch_beacon_processing: to get EDCA parameters: session needed
252 * If session context does not exist, some IEs will be populated from
253 * CFGs, e.g. Supported and Extended rate set IEs
254 */
255 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
256
257 if (pesession != NULL)
258 sme_sessionid = pesession->smeSessionId;
259
260 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
261 /* and then hand it off to 'dot11f_pack_probe_request' (for */
262 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530263 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264
265 /* & delegating to assorted helpers: */
266 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
267
268 if (addn_ielen && additional_ie)
269 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
270
271 /*
272 * Don't include 11b rate if it is a P2P serach or probe request is
273 * sent by P2P Client
274 */
275 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530276 ((pesession != NULL) &&
277 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 /*
279 * In the below API pass channel number > 14, do that it fills
280 * only 11a rates in supported rates
281 */
282 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
283 pesession);
284 } else {
285 populate_dot11f_supp_rates(mac_ctx, channel,
286 &pr.SuppRates, pesession);
287
288 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
289 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
290 &pr.ExtSuppRates);
291 }
292 }
293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 /*
295 * Table 7-14 in IEEE Std. 802.11k-2008 says
296 * DS params "can" be present in RRM is disabled and "is" present if
297 * RRM is enabled. It should be ok even if we add it into probe req when
298 * RRM is not enabled.
299 */
300 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
301 /* Call RRM module to get the tx power for management used. */
302 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
303 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
306 if (pesession != NULL) {
307 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
308 /* Include HT Capability IE */
309 if (pesession->htCapability)
310 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
311 } else { /* pesession == NULL */
312 if (IS_DOT11_MODE_HT(dot11mode))
313 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
314 }
315
316 /*
317 * Set channelbonding information as "disabled" when tunned to a
318 * 2.4 GHz channel
319 */
320 if (channel <= SIR_11B_CHANNEL_END) {
321 if (mac_ctx->roam.configParam.channelBondingMode24GHz
322 == PHY_SINGLE_CHANNEL_CENTERED) {
323 pr.HTCaps.supportedChannelWidthSet =
324 eHT_CHANNEL_WIDTH_20MHZ;
325 pr.HTCaps.shortGI40MHz = 0;
326 } else {
327 pr.HTCaps.supportedChannelWidthSet =
328 eHT_CHANNEL_WIDTH_40MHZ;
329 }
330 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 if (pesession != NULL) {
332 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
333 /* Include VHT Capability IE */
334 if (pesession->vhtCapability) {
335 populate_dot11f_vht_caps(mac_ctx, pesession,
336 &pr.VHTCaps);
337 is_vht_enabled = true;
338 }
339 } else {
340 if (IS_DOT11_MODE_VHT(dot11mode)) {
341 populate_dot11f_vht_caps(mac_ctx, pesession,
342 &pr.VHTCaps);
343 is_vht_enabled = true;
344 }
345 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 if (pesession != NULL)
347 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
348 pesession);
349
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800350 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
351 lim_update_session_he_capable(mac_ctx, pesession);
352
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700353 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700354 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 if (addn_ielen) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530357 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
358 sizeof(tDot11fIEExtCap));
359 sir_status = lim_strip_extcap_update_struct(mac_ctx,
360 additional_ie,
361 &addn_ielen,
362 &extracted_ext_cap);
363 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700364 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530365 } else {
366 struct s_ext_cap *p_ext_cap =
367 (struct s_ext_cap *)
368 extracted_ext_cap.bytes;
369 if (p_ext_cap->interworking_service)
370 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800371 extracted_ext_cap.num_bytes =
372 lim_compute_ext_cap_ie_length
373 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530374 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800375 (extracted_ext_cap.num_bytes > 0);
Kapil Guptac03eb072016-08-09 14:01:36 +0530376 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530377 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
378 SIR_MAC_QCN_OUI_TYPE_SIZE,
379 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530381 /* Add qcn_ie only if qcn ie is not present in additional_ie */
382 if (mac_ctx->roam.configParam.qcn_ie_support && !qcn_ie)
383 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384
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 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530442 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 /*
444 * For unicast probe req mgmt from Join function we don't set
445 * above variables. So we need to add one more check whether it
446 * is pePersona is P2P_CLIENT or not
447 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530448 ((pesession != NULL) &&
449 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
451 }
452
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530453 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 wma_tx_frame(mac_ctx, packet,
455 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
456 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
457 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700458 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530459 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700460 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 /* Pkt will be freed up by the callback */
462 return eSIR_FAILURE;
463 }
464
465 return eSIR_SUCCESS;
466} /* End lim_send_probe_req_mgmt_frame. */
467
Jeff Johnson38112a32016-10-07 07:30:50 -0700468static tSirRetStatus lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 uint8_t *addIE, uint16_t *addnIELen,
470 uint8_t probeReqP2pIe)
471{
472 /* If Probe request doesn't have P2P IE, then take out P2P IE
473 from additional IE */
474 if (!probeReqP2pIe) {
475 uint8_t *tempbuf = NULL;
476 uint16_t tempLen = 0;
477 int left = *addnIELen;
478 uint8_t *ptr = addIE;
479 uint8_t elem_id, elem_len;
480
481 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700482 pe_err("NULL addIE pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 return eSIR_FAILURE;
484 }
485
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530486 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700488 pe_err("Unable to allocate memory to store addn IE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 return eSIR_MEM_ALLOC_FAILED;
490 }
491
492 while (left >= 2) {
493 elem_id = ptr[0];
494 elem_len = ptr[1];
495 left -= 2;
496 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700497 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530499 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 return eSIR_FAILURE;
501 }
502 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
503 (memcmp
504 (&ptr[2], SIR_MAC_P2P_OUI,
505 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530506 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 elem_len + 2);
508 tempLen += (elem_len + 2);
509 }
510 left -= elem_len;
511 ptr += (elem_len + 2);
512 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530513 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530515 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 }
517 return eSIR_SUCCESS;
518}
519
520/**
521 * lim_send_probe_rsp_mgmt_frame() - Send probe response
522 *
523 * @mac_ctx: Handle for mac context
524 * @peer_macaddr: Mac address of requesting peer
525 * @ssid: SSID for response
526 * @n_staid: Station ID, currently unused.
527 * @pe_session: PE session id
528 * @keepalive: Keep alive flag. Currently unused.
529 * @preq_p2pie: P2P IE in incoming probe request
530 *
531 * Builds and sends probe response frame to the requesting peer
532 *
533 * Return: void
534 */
535
536void
537lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
538 tSirMacAddr peer_macaddr,
539 tpAniSSID ssid,
540 short n_staid,
541 uint8_t keepalive,
542 tpPESession pe_session, uint8_t preq_p2pie)
543{
544 tDot11fProbeResponse *frm;
545 tSirRetStatus sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800546 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 tpSirMacMgmtHdr mac_hdr;
548 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700549 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530550 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 uint32_t addn_ie_present = false;
552
553 uint16_t addn_ie_len = 0;
554 uint32_t wps_ap = 0, tmp;
555 uint8_t tx_flag = 0;
556 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700557 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 uint8_t noalen = 0;
559 uint8_t total_noalen = 0;
560 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
561 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
562 uint8_t sme_sessionid = 0;
563 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530564 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530565 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566
567 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700568 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569 return;
570
571 if (NULL == pe_session)
572 return;
573
574 /*
575 * In case when cac timer is running for this SAP session then
576 * avoid sending probe rsp out. It is violation of dfs specification.
577 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530578 if (((pe_session->pePersona == QDF_SAP_MODE) ||
579 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530581 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 FL("CAC timer is running, probe response dropped"));
583 return;
584 }
585 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530586 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700588 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 return;
590 }
591
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 /*
593 * Fill out 'frm', after which we'll just hand the struct off to
594 * 'dot11f_pack_probe_response'.
595 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530596 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597
598 /*
599 * Timestamp to be updated by TFP, below.
600 *
601 * Beacon Interval:
602 */
603 if (LIM_IS_AP_ROLE(pe_session)) {
604 frm->BeaconInterval.interval =
605 mac_ctx->sch.schObject.gSchBeaconInterval;
606 } else {
607 sir_status = wlan_cfg_get_int(mac_ctx,
608 WNI_CFG_BEACON_INTERVAL, &cfg);
609 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700610 pe_err("Failed to get WNI_CFG_BEACON_INTERVAL (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 sir_status);
612 goto err_ret;
613 }
614 frm->BeaconInterval.interval = (uint16_t) cfg;
615 }
616
617 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
618 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
619 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
620 &frm->SuppRates, pe_session);
621
622 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
623 pe_session->currentOperChannel);
624 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
625
626 if (LIM_IS_AP_ROLE(pe_session)) {
627 if (pe_session->wps_state != SAP_WPS_DISABLED)
628 populate_dot11f_probe_res_wpsi_es(mac_ctx,
629 &frm->WscProbeRes,
630 pe_session);
631 } else {
632 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
633 &tmp) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700634 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635
636 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
637
638 if (wps_ap)
639 populate_dot11f_wsc_in_probe_res(mac_ctx,
640 &frm->WscProbeRes);
641
642 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
643 eLIM_WSC_ENROLL_BEGIN) {
644 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
645 &frm->WscProbeRes);
646 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
647 eLIM_WSC_ENROLL_IN_PROGRESS;
648 }
649
650 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
651 eLIM_WSC_ENROLL_END) {
652 de_populate_dot11f_wsc_registrar_info_in_probe_res(
653 mac_ctx, &frm->WscProbeRes);
654 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
655 eLIM_WSC_ENROLL_NOOP;
656 }
657 }
658
659 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
660 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
661
662 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
663 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
664
665 populate_dot11f_ext_supp_rates(mac_ctx,
666 POPULATE_DOT11F_RATES_OPERATIONAL,
667 &frm->ExtSuppRates, pe_session);
668
669 /* Populate HT IEs, when operating in 11n */
670 if (pe_session->htCapability) {
671 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
672 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700675 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
677 populate_dot11f_vht_operation(mac_ctx, pe_session,
678 &frm->VHTOperation);
679 /*
680 * we do not support multi users yet.
681 * populate_dot11f_vht_ext_bss_load( mac_ctx,
682 * &frm.VHTExtBssLoad );
683 */
684 is_vht_enabled = true;
685 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800687 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700688 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800689 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700690 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800691 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700692 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800693 }
694
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
696 pe_session);
697
698 if (pe_session->pLimStartBssReq) {
699 populate_dot11f_wpa(mac_ctx,
700 &(pe_session->pLimStartBssReq->rsnIE),
701 &frm->WPA);
702 populate_dot11f_rsn_opaque(mac_ctx,
703 &(pe_session->pLimStartBssReq->rsnIE),
704 &frm->RSNOpaque);
705 }
706
707 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
708 &frm->WMMCaps, pe_session);
709
710#if defined(FEATURE_WLAN_WAPI)
711 if (pe_session->pLimStartBssReq)
712 populate_dot11f_wapi(mac_ctx,
713 &(pe_session->pLimStartBssReq->rsnIE),
714 &frm->WAPI);
715#endif /* defined(FEATURE_WLAN_WAPI) */
716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 if (mac_ctx->lim.gpLimRemainOnChanReq)
718 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
719 sizeof(tSirRemainOnChnReq));
720 else
721 /*
722 * Only use CFG for non-listen mode. This CFG is not working for
723 * concurrency. In listening mode, probe rsp IEs is passed in
724 * the message from SME to PE.
725 */
726 addn_ie_present =
727 (pe_session->addIeParams.probeRespDataLen != 0);
728
729 if (addn_ie_present) {
730
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530731 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 pe_session->addIeParams.probeRespDataLen);
733 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700734 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 goto err_ret;
736 }
737
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530738 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 pe_session->addIeParams.probeRespData_buff,
740 pe_session->addIeParams.probeRespDataLen);
741 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
742
743 if (eSIR_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
744 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700745 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 goto err_ret;
747 }
748
749 sir_status = lim_strip_extcap_update_struct(mac_ctx,
750 add_ie, &addn_ie_len,
751 &extracted_ext_cap);
752 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700753 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530754 } else {
755 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 }
757
758 bytes = bytes + addn_ie_len;
759
760 if (preq_p2pie)
761 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
762 addn_ie_len);
763
764 if (p2p_ie != NULL) {
765 /* get NoA attribute stream P2P IE */
766 noalen = lim_get_noa_attr_stream(mac_ctx,
767 noa_stream, pe_session);
768 if (noalen != 0) {
769 total_noalen =
770 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
771 &noa_stream[0], noalen);
772 bytes = bytes + total_noalen;
773 }
774 }
775 }
776
Hu Wang411e0cc2016-10-28 14:56:01 +0800777 /*
778 * Extcap IE now support variable length, merge Extcap IE from addn_ie
779 * may change the frame size. Therefore, MUST merge ExtCap IE before
780 * dot11f get packed payload size.
781 */
782 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800783 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
784 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800785
786 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
787 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700788 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800789 status);
790 /* We'll fall back on the worst case scenario: */
791 payload = sizeof(tDot11fProbeResponse);
792 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700793 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800794 status);
795 }
796
797 bytes += payload + sizeof(tSirMacMgmtHdr);
798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530799 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530801 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700802 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 goto err_ret;
804 }
805 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530806 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
808 /* Next, we fill out the buffer descriptor: */
809 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
810 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
811 pe_session->selfMacAddr);
812
813 mac_hdr = (tpSirMacMgmtHdr) frame;
814
815 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 /* That done, pack the Probe Response: */
818 status =
819 dot11f_pack_probe_response(mac_ctx, frm,
820 frame + sizeof(tSirMacMgmtHdr),
821 payload, &payload);
822 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700823 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 status);
825 goto err_ret;
826 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700827 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 }
829
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700830 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530831 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530834 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
836 (mac_ctx->lim.gpLimRemainOnChanReq->length -
837 sizeof(tSirRemainOnChnReq)));
838
839 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530840 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &add_ie[0], addn_ie_len);
842
843 if (noalen != 0) {
844 if (total_noalen >
845 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700846 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 total_noalen);
848 goto err_ret;
849 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530850 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851 &noa_ie[0], total_noalen);
852 }
853 }
854
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800855 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530856 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
857 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 )
859 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
860
861 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530862 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 (uint16_t) bytes,
864 TXRX_FRM_802_11_MGMT,
865 ANI_TXDIR_TODS,
866 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700867 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530870 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700871 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
873 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530874 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530876 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 return;
878
879err_ret:
880 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530881 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530883 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 if (packet != NULL)
885 cds_packet_free((void *)packet);
886 return;
887
888} /* End lim_send_probe_rsp_mgmt_frame. */
889
890void
891lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
892 tSirMacAddr peerMacAddr,
893 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
894{
895 uint16_t i;
896 uint8_t *pFrame;
897 tDot11fAddTSRequest AddTSReq;
898 tDot11fWMMAddTSRequest WMMAddTSReq;
899 uint32_t nPayload, nBytes, nStatus;
900 tpSirMacMgmtHdr pMacHdr;
901 void *pPacket;
902#ifdef FEATURE_WLAN_ESE
903 uint32_t phyMode;
904#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530905 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 uint8_t txFlag = 0;
907 uint8_t smeSessionId = 0;
908
909 if (NULL == psessionEntry) {
910 return;
911 }
912
913 smeSessionId = psessionEntry->smeSessionId;
914
915 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530916 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917
918 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
919 AddTSReq.DialogToken.token = pAddTS->dialogToken;
920 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
921 if (pAddTS->lleTspecPresent) {
922 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
923 } else {
924 populate_dot11f_wmmtspec(&pAddTS->tspec,
925 &AddTSReq.WMMTSPEC);
926 }
927
928 if (pAddTS->lleTspecPresent) {
929 AddTSReq.num_WMMTCLAS = 0;
930 AddTSReq.num_TCLAS = pAddTS->numTclas;
931 for (i = 0; i < pAddTS->numTclas; ++i) {
932 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
933 &AddTSReq.TCLAS[i]);
934 }
935 } else {
936 AddTSReq.num_TCLAS = 0;
937 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
938 for (i = 0; i < pAddTS->numTclas; ++i) {
939 populate_dot11f_wmmtclas(pMac,
940 &pAddTS->tclasInfo[i],
941 &AddTSReq.WMMTCLAS[i]);
942 }
943 }
944
945 if (pAddTS->tclasProcPresent) {
946 if (pAddTS->lleTspecPresent) {
947 AddTSReq.TCLASSPROC.processing =
948 pAddTS->tclasProc;
949 AddTSReq.TCLASSPROC.present = 1;
950 } else {
951 AddTSReq.WMMTCLASPROC.version = 1;
952 AddTSReq.WMMTCLASPROC.processing =
953 pAddTS->tclasProc;
954 AddTSReq.WMMTCLASPROC.present = 1;
955 }
956 }
957
958 nStatus =
959 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
960 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700961 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
962 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 /* We'll fall back on the worst case scenario: */
964 nPayload = sizeof(tDot11fAddTSRequest);
965 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700966 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
967 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 }
969 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530970 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971
972 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
973 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
974 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
975
976 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
977 WMMAddTSReq.StatusCode.statusCode = 0;
978
979 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
980#ifdef FEATURE_WLAN_ESE
981 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
982
983 if (phyMode == WNI_CFG_PHY_MODE_11G
984 || phyMode == WNI_CFG_PHY_MODE_11A) {
985 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
986 } else {
987 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
988 }
989 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
990 &WMMAddTSReq.ESETrafStrmRateSet,
991 sizeof(uint8_t));
992#endif
993 /* fillWmeTspecIE */
994
995 nStatus =
996 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
997 &nPayload);
998 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700999 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 nStatus);
1001 /* We'll fall back on the worst case scenario: */
1002 nPayload = sizeof(tDot11fAddTSRequest);
1003 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001004 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
1005 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 }
1007 }
1008
1009 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1010
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301011 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301013 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001014 pe_err("Failed to allocate %d bytes for an Add TS Request",
1015 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 return;
1017 }
1018 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301019 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020
1021 /* Next, we fill out the buffer descriptor: */
1022 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1023 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1024 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1025
1026 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1027
1028#ifdef WLAN_FEATURE_11W
1029 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
1030#endif
1031
1032 /* That done, pack the struct: */
1033 if (!pAddTS->wmeTspecPresent) {
1034 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1035 pFrame +
1036 sizeof(tSirMacMgmtHdr),
1037 nPayload, &nPayload);
1038 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001039 pe_err("Failed to pack an Add TS Request "
1040 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 cds_packet_free((void *)pPacket);
1042 return; /* allocated! */
1043 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001044 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1045 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 }
1047 } else {
1048 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1049 pFrame +
1050 sizeof(tSirMacMgmtHdr),
1051 nPayload, &nPayload);
1052 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001053 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1054 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 cds_packet_free((void *)pPacket);
1056 return; /* allocated! */
1057 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001058 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1059 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 }
1061 }
1062
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001063 pe_debug("Sending an Add TS Request frame to");
1064 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001066 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301068 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1069 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 ) {
1071 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1072 }
1073
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301074 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001076 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1077 psessionEntry, eSIR_SUCCESS,
1078 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079
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,
Naveen Rawat296a5182017-09-25 14:02:48 -07001085 smeSessionId, 0, RATEID_DEFAULT);
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;
1241 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001242
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301243 if (pe_session->vhtCapability &&
1244 pe_session->vendor_vht_sap &&
1245 (assoc_req != NULL) &&
1246 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001247 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301248 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001249 frm.vendor_vht_ie.sub_type =
1250 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301251 frm.vendor_vht_ie.VHTCaps.present = 1;
1252 populate_dot11f_vht_caps(mac_ctx, pe_session,
1253 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001254 populate_dot11f_vht_operation(mac_ctx, pe_session,
1255 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 is_vht = true;
1257 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1259 pe_session);
1260
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001261 if (lim_is_sta_he_capable(sta) &&
1262 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001263 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001264 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001265 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001266 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001267 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001268 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269#ifdef WLAN_FEATURE_11W
1270 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
1271 if (wlan_cfg_get_int
1272 (mac_ctx, WNI_CFG_PMF_SA_QUERY_MAX_RETRIES,
1273 &max_retries) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001274 pe_err("get WNI_CFG_PMF_SA_QUERY_MAX_RETRIES failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 else if (wlan_cfg_get_int
1276 (mac_ctx,
1277 WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL,
1278 &retry_int) != eSIR_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001279 pe_err("get WNI_CFG_PMF_SA_QUERY_RETRY_INTERVAL failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 else
1281 populate_dot11f_timeout_interval(mac_ctx,
1282 &frm.TimeoutInterval,
1283 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1284 (max_retries -
1285 sta->pmfSaQueryRetryCount)
1286 * retry_int);
1287 }
1288#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001289
1290 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1291 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 }
1293
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301294 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295
1296 if (LIM_IS_AP_ROLE(pe_session) &&
1297 (pe_session->gLimProtectionControl !=
1298 WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE))
1299 lim_decide_ap_protection(mac_ctx, peer_addr,
1300 &beacon_params, pe_session);
1301
1302 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1303 pe_session);
1304 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1305 pe_session);
1306
1307 /*
1308 * Populate Do11capabilities after updating session with
1309 * Assos req details
1310 */
1311 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1312
1313 beacon_params.bssIdx = pe_session->bssIdx;
1314
1315 /* Send message to HAL about beacon parameter change. */
1316 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1317 && beacon_params.paramChangeBitmap) {
1318 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1319 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1320 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321
Arif Hussain1513cb22018-01-05 19:56:31 -08001322 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1323
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001325 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326
1327 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001328 if (addn_ie_len > 0 &&
1329 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1330 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 pe_session->addIeParams.assocRespData_buff,
1333 pe_session->addIeParams.assocRespDataLen);
1334
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 sizeof(extracted_ext_cap), 0);
1337
1338 stripoff_len = addn_ie_len;
1339 sir_status =
1340 lim_strip_extcap_update_struct
1341 (mac_ctx, &add_ie[0], &stripoff_len,
1342 &extracted_ext_cap);
1343 if (eSIR_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001344 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 } else {
1346 addn_ie_len = stripoff_len;
1347 extracted_flag = true;
1348 }
1349 bytes = bytes + addn_ie_len;
1350 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001351 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 addn_ie_len, assoc_req->addIEPresent);
1353 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001354
1355 /*
1356 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1357 * may change the frame size. Therefore, MUST merge ExtCap IE before
1358 * dot11f get packed payload size.
1359 */
1360 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001361 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1362 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001363
1364 /* Allocate a buffer for this frame: */
1365 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1366 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001367 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001368 status);
1369 return;
1370 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001371 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001372 status);
1373 }
1374
1375 bytes += sizeof(tSirMacMgmtHdr) + payload;
1376
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301377 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301379 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001380 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 return;
1382 }
1383 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301384 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385
1386 /* Next, we fill out the buffer descriptor: */
1387 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1388 (LIM_ASSOC == subtype) ?
1389 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1390 peer_addr,
1391 pe_session->selfMacAddr);
1392 mac_hdr = (tpSirMacMgmtHdr) frame;
1393
1394 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1395
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1397 frame + sizeof(tSirMacMgmtHdr),
1398 payload, &payload);
1399 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001400 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 status);
1402 cds_packet_free((void *)packet);
1403 return;
1404 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001405 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 status);
1407 }
1408
1409 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001410 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 status_code, aid);
1412 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001413 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 status_code, aid);
1415
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301416 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417
1418 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301419 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 &add_ie[0], addn_ie_len);
1421
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001422 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301424 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1425 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1427
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301428 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001430 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
1431 pe_session, eSIR_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301433 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 TXRX_FRM_802_11_MGMT,
1435 ANI_TXDIR_TODS,
1436 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001437 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301438 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440
1441 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301442 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001443 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301444 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445
1446 /*
1447 * update the ANI peer station count.
1448 * FIXME_PROTECTION : take care of different type of station
1449 * counter inside this function.
1450 */
1451 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1452
1453}
1454
1455void
1456lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1457 tSirMacAddr peer,
1458 uint8_t wmmTspecPresent,
1459 tSirMacTSInfo *pTsinfo,
1460 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1461{
1462 uint8_t *pFrame;
1463 tpSirMacMgmtHdr pMacHdr;
1464 tDot11fDelTS DelTS;
1465 tDot11fWMMDelTS WMMDelTS;
1466 uint32_t nBytes, nPayload, nStatus;
1467 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301468 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 uint8_t txFlag = 0;
1470 uint8_t smeSessionId = 0;
1471
1472 if (NULL == psessionEntry) {
1473 return;
1474 }
1475
1476 smeSessionId = psessionEntry->smeSessionId;
1477
1478 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480
1481 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1482 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1483 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1484
1485 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1486 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 /* We'll fall back on the worst case scenario: */
1489 nPayload = sizeof(tDot11fDelTS);
1490 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001491 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1492 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 }
1494 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301495 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496
1497 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1498 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1499 WMMDelTS.DialogToken.token = 0;
1500 WMMDelTS.StatusCode.statusCode = 0;
1501 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1502 nStatus =
1503 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1504 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001505 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 /* We'll fall back on the worst case scenario: */
1507 nPayload = sizeof(tDot11fDelTS);
1508 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001509 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1510 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 }
1512 }
1513
1514 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1515
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301516 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1518 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301519 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001520 pe_err("Failed to allocate %d bytes for an Add TS Response",
1521 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 return;
1523 }
1524 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526
1527 /* Next, we fill out the buffer descriptor: */
1528 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1529 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1530 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1531
1532 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1533
1534#ifdef WLAN_FEATURE_11W
1535 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
1536#endif
1537
1538 /* That done, pack the struct: */
1539 if (!wmmTspecPresent) {
1540 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1541 pFrame + sizeof(tSirMacMgmtHdr),
1542 nPayload, &nPayload);
1543 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001544 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 nStatus);
1546 cds_packet_free((void *)pPacket);
1547 return; /* allocated! */
1548 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001549 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1550 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 }
1552 } else {
1553 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1554 pFrame + sizeof(tSirMacMgmtHdr),
1555 nPayload, &nPayload);
1556 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001557 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 nStatus);
1559 cds_packet_free((void *)pPacket);
1560 return; /* allocated! */
1561 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001562 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1563 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 }
1565 }
1566
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001567 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1568 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001570 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301572 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1573 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 ) {
1575 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1576 }
1577
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301578 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001580 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
1581 psessionEntry, eSIR_SUCCESS,
1582 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301583 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 TXRX_FRM_802_11_MGMT,
1585 ANI_TXDIR_TODS,
1586 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001587 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301588 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301589 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301591 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001592 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593
1594} /* End lim_send_delts_req_action_frame. */
1595
1596/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301597 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1598 * @context: pointer to global mac
1599 * @buf: buffer
1600 * @tx_complete : Sent status
1601 * @params; tx completion params
1602 *
1603 * Return: This returns QDF_STATUS
1604 */
1605
1606static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1607 qdf_nbuf_t buf,
1608 uint32_t tx_complete,
1609 void *params)
1610{
1611 uint16_t assoc_ack_status;
1612 uint16_t reason_code;
1613 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1614
1615 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001616 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301617 assoc_ack_status = ACKED;
1618 reason_code = eSIR_SUCCESS;
1619 } else {
1620 assoc_ack_status = NOT_ACKED;
1621 reason_code = eSIR_FAILURE;
1622 }
1623 if (buf)
1624 qdf_nbuf_free(buf);
1625
1626 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1627 NULL, assoc_ack_status, reason_code);
1628 return QDF_STATUS_SUCCESS;
1629}
1630
1631/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 * lim_send_assoc_req_mgmt_frame() - Send association request
1633 * @mac_ctx: Handle to MAC context
1634 * @mlm_assoc_req: Association request information
1635 * @pe_session: PE session information
1636 *
1637 * Builds and transmits association request frame to AP.
1638 *
1639 * Return: Void
1640 */
1641
1642void
1643lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1644 tLimMlmAssocReq *mlm_assoc_req,
1645 tpPESession pe_session)
1646{
Naveen Rawat72475db2017-12-13 18:07:35 -08001647 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 tDot11fAssocRequest *frm;
1649 uint16_t caps;
1650 uint8_t *frame;
1651 tSirRetStatus sir_status;
1652 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001653 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1655 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301656 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 uint16_t add_ie_len;
1658 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001659 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 uint8_t tx_flag = 0;
1662 uint8_t sme_sessionid = 0;
1663 bool vht_enabled = false;
1664 tDot11fIEExtCap extr_ext_cap;
1665 bool extr_ext_flag = true;
1666 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001667 uint32_t ie_offset = 0;
1668 uint8_t *p_ext_cap = NULL;
1669 tDot11fIEExtCap bcn_ext_cap;
1670 uint8_t *bcn_ie = NULL;
1671 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301672 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001673 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674
1675 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001676 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301677 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 return;
1679 }
1680
1681 sme_sessionid = pe_session->smeSessionId;
1682
1683 /* check this early to avoid unncessary operation */
1684 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001685 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301686 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 return;
1688 }
1689 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1690 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1691
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301692 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001694 pe_err("Unable to allocate memory");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301695 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 return;
1697 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001698 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301700 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301701 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 0);
1703 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1704 add_ie, &add_ie_len, &extr_ext_cap);
1705 if (eSIR_SUCCESS != sir_status) {
1706 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001707 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 } else {
1709 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1710 extr_ext_cap.bytes;
1711
1712 if (p_ext_cap->interworking_service)
1713 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001714 extr_ext_cap.num_bytes =
1715 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1716 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 }
1718 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001719 pe_debug("No addn IE or peer dosen't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 extr_ext_flag = false;
1721 }
1722
1723 caps = mlm_assoc_req->capabilityInfo;
1724#if defined(FEATURE_WLAN_WAPI)
1725 /*
1726 * According to WAPI standard:
1727 * 7.3.1.4 Capability Information field
1728 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1729 * in transmitted Association or Reassociation management frames.
1730 * APs ignore the Privacy subfield within received Association and
1731 * Reassociation management frames.
1732 */
1733 if (pe_session->encryptType == eSIR_ED_WPI)
1734 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1735#endif
1736 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1737
1738 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1739 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1740 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1741 &frm->SuppRates, pe_session);
1742
1743 qos_enabled = (pe_session->limQosEnabled) &&
1744 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1745
1746 wme_enabled = (pe_session->limWmeEnabled) &&
1747 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1748
1749 /* We prefer .11e asociations: */
1750 if (qos_enabled)
1751 wme_enabled = false;
1752
1753 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1754 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1755
1756 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001757 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 power_caps = true;
1759
1760 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1761 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1763 LIM_ASSOC, pe_session);
1764
1765 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1767 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1768 if (power_caps == false) {
1769 power_caps = true;
1770 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1771 LIM_ASSOC, pe_session);
1772 }
1773 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001775 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1776 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777
1778 populate_dot11f_ext_supp_rates(mac_ctx,
1779 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1780 pe_session);
1781
Gupta, Kapil54a16992016-01-13 19:34:02 +05301782 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1783 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1785 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001786
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 /*
1788 * The join request *should* contain zero or one of the WPA and RSN
1789 * IEs. The payload send along with the request is a
1790 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1791 * typedef struct sSirRSNie
1792 * {
1793 * uint16_t length;
1794 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1795 * } tSirRSNie, *tpSirRSNie;
1796 * So, we should be able to make the following two calls harmlessly,
1797 * since they do nothing if they don't find the given IE in the
1798 * bytestream with which they're provided.
1799 * The net effect of this will be to faithfully transmit whatever
1800 * security IE is in the join request.
1801 * However, if we're associating for the purpose of WPS
1802 * enrollment, and we've been configured to indicate that by
1803 * eliding the WPA or RSN IE, we just skip this:
1804 */
1805 if (add_ie_len && add_ie)
1806 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1807
1808 if (NULL == wps_ie) {
1809 populate_dot11f_rsn_opaque(mac_ctx,
1810 &(pe_session->pLimJoinReq->rsnIE),
1811 &frm->RSNOpaque);
1812 populate_dot11f_wpa_opaque(mac_ctx,
1813 &(pe_session->pLimJoinReq->rsnIE),
1814 &frm->WPAOpaque);
1815#if defined(FEATURE_WLAN_WAPI)
1816 populate_dot11f_wapi_opaque(mac_ctx,
1817 &(pe_session->pLimJoinReq->rsnIE),
1818 &frm->WAPIOpaque);
1819#endif /* defined(FEATURE_WLAN_WAPI) */
1820 }
1821 /* include WME EDCA IE as well */
1822 if (wme_enabled) {
1823 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1824 pe_session, &frm->WMMInfoStation);
1825
1826 if (wsm_enabled)
1827 populate_dot11f_wmm_caps(&frm->WMMCaps);
1828 }
1829
1830 /*
1831 * Populate HT IEs, when operating in 11n and
1832 * when AP is also operating in 11n mode
1833 */
1834 if (pe_session->htCapability &&
1835 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001836 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001838 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1839 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001840 } else if (pe_session->he_with_wep_tkip) {
1841 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1842 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001844 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 +05301845 frm->HTCaps.supportedChannelWidthSet,
1846 frm->HTCaps.mimoPowerSave,
1847 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1848 frm->HTCaps.shortGI40MHz,
1849 frm->HTCaps.dsssCckMode40MHz,
1850 frm->HTCaps.maxRxAMPDUFactor);
1851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 if (pe_session->vhtCapability &&
1853 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001854 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001856 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1857 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001859 if (pe_session->enableHtSmps &&
1860 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001861 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001862 populate_dot11f_operating_mode(mac_ctx,
1863 &frm->OperatingMode, pe_session);
1864 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001865 } else if (pe_session->he_with_wep_tkip) {
1866 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1867 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 if (!vht_enabled &&
1871 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001872 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301873 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001874 frm->vendor_vht_ie.sub_type =
1875 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301876 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhishek Singh68844282018-01-25 16:48:41 +05301877 if (!mac_ctx->roam.configParam.enable_subfee_vendor_vhtie &&
1878 pe_session->vht_config.su_beam_formee) {
1879 pe_debug("Disable SU beamformee for vendor IE");
1880 pe_session->vht_config.su_beam_formee = 0;
1881 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301883 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 vht_enabled = true;
1885 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301886 if (pe_session->is_ext_caps_present)
1887 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1888 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301890 if (mac_ctx->roam.configParam.qcn_ie_support)
1891 populate_dot11f_qcn_ie(&frm->QCN_IE);
1892
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001893 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001894 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001895 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001896 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001897 } else if (pe_session->he_with_wep_tkip) {
1898 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1899 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001900 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 tSirBssDescription *bssdescr;
1904
1905 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001906 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 (unsigned int) bssdescr->mdie[0],
1908 (unsigned int) bssdescr->mdie[1],
1909 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 populate_mdie(mac_ctx, &frm->MobilityDomain,
1911 pe_session->pLimJoinReq->bssDescription.mdie);
1912 } else {
1913 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001914 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916
1917#ifdef FEATURE_WLAN_ESE
1918 /*
1919 * ESE Version IE will be included in association request
1920 * when ESE is enabled on DUT through ini and it is also
1921 * advertised by the peer AP to which we are trying to
1922 * associate to.
1923 */
1924 if (pe_session->is_ese_version_ie_present &&
1925 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1926 populate_dot11f_ese_version(&frm->ESEVersion);
1927 /* For ESE Associations fill the ESE IEs */
1928 if (pe_session->isESEconnection &&
1929 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1930#ifndef FEATURE_DISABLE_RM
1931 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1932#endif
1933 }
1934#endif
1935
Hu Wang411e0cc2016-10-28 14:56:01 +08001936 /*
1937 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1938 * may change the frame size. Therefore, MUST merge ExtCap IE before
1939 * dot11f get packed payload size.
1940 */
1941 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001942 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1943
1944 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1945 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1946 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1947 DOT11F_FF_BEACONINTERVAL_LEN +
1948 DOT11F_FF_CAPABILITIES_LEN;
1949
1950 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1951 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1952 bcn_ie = pe_session->beacon + ie_offset;
1953 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001954 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001955 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001956 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001957 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1958 &bcn_ext_cap);
1959 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1960 false);
1961 }
1962 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001963
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001964 if (eSIR_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
1965 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001966 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001967
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301968 if (lim_is_fils_connection(pe_session)) {
1969 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1970 aes_block_size_len = AES_BLOCK_SIZE;
1971 }
1972
1973 /*
1974 * Do unpack to populate the add_ie buffer to frm structure
1975 * before packing the frm structure. In this way, the IE ordering
1976 * which the latest 802.11 spec mandates is maintained.
1977 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001978 if (add_ie_len) {
1979 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301980 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001981 if (DOT11F_FAILED(ret)) {
1982 pe_err("unpack failed, ret: 0x%x", ret);
1983 goto end;
1984 }
1985 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1988 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001989 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 status);
1991 /* We'll fall back on the worst case scenario: */
1992 payload = sizeof(tDot11fAssocRequest);
1993 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001994 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 status);
1996 }
1997
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301998 bytes = payload + sizeof(tSirMacMgmtHdr) +
1999 aes_block_size_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302001 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302003 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002004 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005
2006 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302007 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 pe_session->peSessionId,
2009 pe_session->limMlmState));
2010
2011 /* Update PE session id */
2012 assoc_cnf.sessionId = pe_session->peSessionId;
2013
2014 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2015
2016 cds_packet_free((void *)packet);
2017
2018 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2019 (uint32_t *) &assoc_cnf);
2020
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302021 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 }
2023 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025
2026 /* Next, we fill out the buffer descriptor: */
2027 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2028 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2029 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 /* That done, pack the Assoc Request: */
2031 status = dot11f_pack_assoc_request(mac_ctx, frm,
2032 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2033 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002034 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302036 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002038 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 }
2040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302042 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002044 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 }
2046
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302047 if (lim_is_fils_connection(pe_session)) {
2048 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2049 frame, &payload);
2050 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2051 cds_packet_free((void *)packet);
2052 qdf_mem_free(frm);
2053 return;
2054 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 }
2056
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302057 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002059 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 } else {
2061 /*
2062 * Store the Assoc request. This is sent to csr/hdd in
2063 * join cnf response.
2064 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302065 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 frame + sizeof(tSirMacMgmtHdr), payload);
2067 pe_session->assocReqLen = payload;
2068 }
2069
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002070 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302071 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2072 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 )
2074 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2075
Anurag Chouhan6d760662016-02-20 16:05:43 +05302076 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2077 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302081 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302083
2084 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002085 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002086 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
2087 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
2088 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2089 pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302090 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302091 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2093 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302094 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002095 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302096 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302097 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302098 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002099
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302100 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002101 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302102 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302103 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
2104 pe_session, SENT_FAIL, eSIR_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 }
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302107end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302109 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302111 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 return;
2113}
2114
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302116 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302117 * @context: pointer to global mac
2118 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302119 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302120 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302121 *
2122 * Return: This returns QDF_STATUS
2123 */
2124
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302125static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2126 qdf_nbuf_t buf,
2127 uint32_t tx_complete,
2128 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302129{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302130 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302131 uint16_t auth_ack_status;
2132 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302133
Naveen Rawat684e8b12017-09-20 15:54:44 -07002134 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002135 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2136 "success" : "fail");
2137 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302138 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302139 auth_ack_status = ACKED;
2140 reason_code = eSIR_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302141 /* 'Change' timer for future activations */
2142 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2143 } else {
2144 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302145 auth_ack_status = NOT_ACKED;
2146 reason_code = eSIR_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302147 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302148
2149 if (buf)
2150 qdf_nbuf_free(buf);
2151
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302152 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2153 NULL, auth_ack_status, reason_code);
2154
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302155 return QDF_STATUS_SUCCESS;
2156}
2157
2158/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2160 *
2161 * @mac_ctx: Pointer to Global MAC structure
2162 * @auth_frame: Pointer to Authentication frame structure
2163 * @peer_addr: MAC address of destination peer
2164 * @wep_bit: wep bit in frame control for Authentication frame3
2165 * @session: PE session information
2166 *
2167 * This function is called by lim_process_mlm_messages(). Authentication frame
2168 * is formatted and sent when this function is called.
2169 *
2170 * Return: void
2171 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172void
2173lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2174 tpSirMacAuthFrameBody auth_frame,
2175 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302176 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302177 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178{
2179 uint8_t *frame, *body;
2180 uint32_t frame_len = 0, body_len = 0;
2181 tpSirMacMgmtHdr mac_hdr;
2182 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302183 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 uint8_t tx_flag = 0;
2185 uint8_t sme_sessionid = 0;
2186 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002187 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002188 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189
2190 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002191 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 return;
2193 }
2194
2195 sme_sessionid = session->smeSessionId;
2196
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302197 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002198 /*
2199 * Auth frame3 to be sent with encrypted framebody
2200 *
2201 * Allocate buffer for Authenticaton frame of size
2202 * equal to management frame header length plus 2 bytes
2203 * each for auth algorithm number, transaction number,
2204 * status code, 128 bytes for challenge text and
2205 * 4 bytes each for IV & ICV.
2206 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002207 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2208 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002209
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302210 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002211 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002212
2213 goto alloc_packet;
2214 }
2215
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302216 pe_info("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002217 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218 auth_frame->authTransactionSeqNumber,
2219 auth_frame->authStatusCode,
2220 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2221 MAC_ADDR_ARRAY(peer_addr));
2222
2223 switch (auth_frame->authTransactionSeqNumber) {
2224 case SIR_MAC_AUTH_FRAME_1:
2225 /*
2226 * Allocate buffer for Authenticaton frame of size
2227 * equal to management frame header length plus 2 bytes
2228 * each for auth algorithm number, transaction number
2229 * and status code.
2230 */
2231
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002232 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2233 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302235 frame_len += lim_create_fils_auth_data(mac_ctx,
2236 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2238 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2239 0 != session->ftPEContext.pFTPreAuthReq->
2240 ft_ies_length) {
2241 ft_ies_length = session->ftPEContext.
2242 pFTPreAuthReq->ft_ies_length;
2243 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002244 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 ft_ies_length);
2246 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002247 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 frame_len += (2 + SIR_MDIE_SIZE);
2249 }
2250 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251 break;
2252
2253 case SIR_MAC_AUTH_FRAME_2:
2254 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2255 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2256 (auth_frame->authStatusCode !=
2257 eSIR_MAC_SUCCESS_STATUS))) {
2258 /*
2259 * Allocate buffer for Authenticaton frame of size
2260 * equal to management frame header length plus
2261 * 2 bytes each for auth algorithm number,
2262 * transaction number and status code.
2263 */
2264
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002265 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2266 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 } else {
2268 /*
2269 * Shared Key algorithm with challenge text
2270 * to be sent.
2271 *
2272 * Allocate buffer for Authenticaton frame of size
2273 * equal to management frame header length plus
2274 * 2 bytes each for auth algorithm number,
2275 * transaction number, status code and 128 bytes
2276 * for challenge text.
2277 */
2278
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002279 challenge_req = true;
2280 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302281 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2282 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002283 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 }
2285 break;
2286
2287 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002288 /*
2289 * Auth frame3 to be sent without encrypted framebody
2290 *
2291 * Allocate buffer for Authenticaton frame of size equal
2292 * to management frame header length plus 2 bytes each
2293 * for auth algorithm number, transaction number and
2294 * status code.
2295 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002297 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2298 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 break;
2300
2301 case SIR_MAC_AUTH_FRAME_4:
2302 /*
2303 * Allocate buffer for Authenticaton frame of size equal
2304 * to management frame header length plus 2 bytes each
2305 * for auth algorithm number, transaction number and
2306 * status code.
2307 */
2308
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002309 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2310 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311
2312 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002313 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002314 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002315 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 } /* switch (auth_frame->authTransactionSeqNumber) */
2317
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002318alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302319 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 (void **)&packet);
2321
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302322 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002323 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 return;
2325 }
2326
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302327 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328
2329 /* Prepare BD */
2330 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2331 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2332 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302333 if (wep_challenge_len)
2334 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2335 else
2336 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337
2338 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002339 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 (uint8_t *) session->bssId,
2342 sizeof(tSirMacAddr));
2343
2344 /* Prepare Authentication frame body */
2345 body = frame + sizeof(tSirMacMgmtHdr);
2346
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302347 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302348 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002349
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002350 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 MAC_ADDR_ARRAY(mac_hdr->da));
2352
2353 } else {
2354 *((uint16_t *) (body)) =
2355 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2356 body += sizeof(uint16_t);
2357 body_len -= sizeof(uint16_t);
2358
2359 *((uint16_t *) (body)) =
2360 sir_swap_u16if_needed(
2361 auth_frame->authTransactionSeqNumber);
2362 body += sizeof(uint16_t);
2363 body_len -= sizeof(uint16_t);
2364
2365 *((uint16_t *) (body)) =
2366 sir_swap_u16if_needed(auth_frame->authStatusCode);
2367 body += sizeof(uint16_t);
2368 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002369
2370 if (challenge_req) {
2371 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302372 /* copy challenge IE id, len, challenge text */
2373 *body = auth_frame->type;
2374 body++;
2375 body_len -= sizeof(uint8_t);
2376 *body = auth_frame->length;
2377 body++;
2378 body_len -= sizeof(uint8_t);
2379 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002380 body_len);
2381 pe_err("Incomplete challenge info: length: %d, expected: %d",
2382 body_len,
2383 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2384 body += body_len;
2385 body_len = 0;
2386 } else {
2387 /* copy challenge IE id, len, challenge text */
2388 *body = auth_frame->type;
2389 body++;
2390 *body = auth_frame->length;
2391 body++;
2392 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302393 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2394 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002395
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302396 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2397 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002398 }
2399 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2402 (auth_frame->authTransactionSeqNumber ==
2403 SIR_MAC_AUTH_FRAME_1) &&
2404 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2405
2406 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302407 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 session->ftPEContext.
2409 pFTPreAuthReq->ft_ies,
2410 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002411 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002412 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2413 QDF_TRACE_LEVEL_DEBUG,
2414 (uint8_t *) body,
2415 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 } else if (NULL != session->ftPEContext.
2417 pFTPreAuthReq->pbssDescription) {
2418 /* MDID attr is 54 */
2419 *body = SIR_MDIE_ELEMENT_ID;
2420 body++;
2421 *body = SIR_MDIE_SIZE;
2422 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302423 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 &session->ftPEContext.pFTPreAuthReq->
2425 pbssDescription->mdie[0],
2426 SIR_MDIE_SIZE);
2427 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302428 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002429 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302430 /* TODO MDIE */
2431 pe_debug("appending fils Auth data");
2432 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002435 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2436 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 auth_frame->authTransactionSeqNumber,
2438 auth_frame->authStatusCode,
2439 (auth_frame->authStatusCode ==
2440 eSIR_MAC_SUCCESS_STATUS),
2441 MAC_ADDR_ARRAY(mac_hdr->da));
2442 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002443 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2444 QDF_TRACE_LEVEL_DEBUG,
2445 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302447 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002448 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302449 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002451 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302452 lim_get_rf_band(session->currentOperChannel))
2453 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2454 || (session->pePersona == QDF_P2P_GO_MODE))
2455 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456
Anurag Chouhan6d760662016-02-20 16:05:43 +05302457 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2458 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2460
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302461 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302464 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002465 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002466 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
2467 session, eSIR_SUCCESS, eSIR_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302468 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2469 (uint16_t)frame_len,
2470 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2471 7, lim_tx_complete, frame,
2472 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002473 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302474 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2475 session->peSessionId, qdf_status));
2476 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2477 pe_err("*** Could not send Auth frame, retCode=%X ***",
2478 qdf_status);
2479 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2480 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2481 session, SENT_FAIL, eSIR_FAILURE);
2482 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302483 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 return;
2485}
2486
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002487QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488{
2489 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002490 tpDphHashNode sta_ds;
2491 tLimMlmDeauthReq *deauth_req;
2492 tLimMlmDeauthCnf deauth_cnf;
2493 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002495 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2496 if (deauth_req) {
2497 if (tx_timer_running(
2498 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2499 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002502 session_entry = pe_find_session_by_session_id(mac_ctx,
2503 deauth_req->sessionId);
2504 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002505 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002506 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 eSIR_SME_INVALID_PARAMETERS;
2508 goto end;
2509 }
2510
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002511 sta_ds =
2512 dph_lookup_hash_entry(mac_ctx,
2513 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002514 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002515 &session_entry->dph.dphHashTable);
2516 if (sta_ds == NULL) {
2517 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 goto end;
2519 }
2520
2521 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002522 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2523 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2524 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2525 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302526#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002527 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302528#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002529 (session_entry->isFastRoamIniFeatureEnabled) ||
2530 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002531 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002532 session_entry,
2533 session_entry->peSessionId,
2534 deauth_req->reasonCode,
2535 deauth_req->deauthTrigger);
2536 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002537 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002538 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002539#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002540 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002541#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002542 " isLFR %d"
2543 " is11r %d, Deauth reason %d Trigger = %d",
2544 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002545#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002546 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002547#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002548 session_entry->isFastRoamIniFeatureEnabled,
2549 session_entry->is11Rconnection,
2550 deauth_req->reasonCode,
2551 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002552 }
2553 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002554 qdf_mem_free(deauth_req);
2555 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302557 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002559 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2560 &deauth_req->peer_macaddr);
2561 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2562 deauth_cnf.aid = deauth_req->aid;
2563 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564
2565 /* Free up buffer allocated */
2566 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002567 qdf_mem_free(deauth_req);
2568 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002570 lim_post_sme_message(mac_ctx,
2571 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302572 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573}
2574
2575/**
2576 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2577 *
2578 * @mac_ctx: Handle to MAC context
2579 *
2580 * Sends disassoc confirmation to SME. Removes disassoc request stored
2581 * in lim.
2582 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302583 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 */
2585
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302586QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587{
2588 uint16_t aid;
2589 tpDphHashNode sta_ds;
2590 tLimMlmDisassocCnf disassoc_cnf;
2591 tpPESession pe_session;
2592 tLimMlmDisassocReq *disassoc_req;
2593
2594 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2595 if (disassoc_req) {
2596 if (tx_timer_running(
2597 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2598 lim_deactivate_and_change_timer(mac_ctx,
2599 eLIM_DISASSOC_ACK_TIMER);
2600
2601 pe_session = pe_find_session_by_session_id(
2602 mac_ctx, disassoc_req->sessionId);
2603 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002604 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 disassoc_cnf.resultCode =
2606 eSIR_SME_INVALID_PARAMETERS;
2607 goto end;
2608 }
2609
2610 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002611 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 &pe_session->dph.dphHashTable);
2613 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002614 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2616 goto end;
2617 }
2618 /* Receive path cleanup with dummy packet */
2619 if (eSIR_SUCCESS !=
2620 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2621 disassoc_cnf.resultCode =
2622 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002623 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 goto end;
2625 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002626 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002627 (disassoc_req->reasonCode !=
2628 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002629 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002630 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 /* Delete FT session if there exists one */
2633 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302636 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302638 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302640 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 }
2642end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302643 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002644 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302645 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 disassoc_cnf.aid = disassoc_req->aid;
2647 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2648
2649 /* Update PE session ID */
2650 disassoc_cnf.sessionId = disassoc_req->sessionId;
2651
2652 if (disassoc_req != NULL) {
2653 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302654 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2656 }
2657
2658 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2659 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661}
2662
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302663QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002664 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302665 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002667 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302668
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002669 pe_debug("tx_success: %d", tx_success);
2670
2671 return lim_send_disassoc_cnf(max_ctx);
2672}
2673
2674static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2675 qdf_nbuf_t buf,
2676 uint32_t tx_success,
2677 void *params)
2678{
2679 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2680 QDF_STATUS status_code;
2681 struct scheduler_msg msg = {0};
2682
2683 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302684
2685 if (buf)
2686 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002687 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2688 msg.bodyptr = params;
2689 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302690
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002691 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2692 if (status_code != QDF_STATUS_SUCCESS)
2693 pe_err("posting message: %X to LIM failed, reason: %d",
2694 msg.type, status_code);
2695 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696}
2697
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302698QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002699 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302700 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002702 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302703
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002704 pe_debug("tx_success: %d", tx_success);
2705
2706 return lim_send_deauth_cnf(mac_ctx);
2707}
2708
2709static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2710 qdf_nbuf_t buf,
2711 uint32_t tx_success,
2712 void *params)
2713{
2714 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2715 QDF_STATUS status_code;
2716 struct scheduler_msg msg = {0};
2717
2718 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302719
2720 if (buf)
2721 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002722 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2723 msg.bodyptr = params;
2724 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302725
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002726 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2727 if (status_code != QDF_STATUS_SUCCESS)
2728 pe_err("posting message: %X to LIM failed, reason: %d",
2729 msg.type, status_code);
2730 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731}
2732
2733/**
2734 * \brief This function is called to send Disassociate frame.
2735 *
2736 *
2737 * \param pMac Pointer to Global MAC structure
2738 *
2739 * \param nReason Indicates the reason that need to be sent in
2740 * Disassociation frame
2741 *
2742 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2743 * sent
2744 *
2745 *
2746 */
2747
2748void
2749lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2750 uint16_t nReason,
2751 tSirMacAddr peer,
2752 tpPESession psessionEntry, bool waitForAck)
2753{
2754 tDot11fDisassociation frm;
2755 uint8_t *pFrame;
2756 tpSirMacMgmtHdr pMacHdr;
2757 uint32_t nBytes, nPayload, nStatus;
2758 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302759 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760 uint8_t txFlag = 0;
2761 uint32_t val = 0;
2762 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 if (NULL == psessionEntry) {
2765 return;
2766 }
2767
2768 /*
2769 * In case when cac timer is running for this SAP session then
2770 * avoid sending disassoc out. It is violation of dfs specification.
2771 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302772 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2773 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302775 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776 FL
2777 ("CAC timer is running, drop disassoc from going out"));
2778 return;
2779 }
2780 smeSessionId = psessionEntry->smeSessionId;
2781
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302782 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783
2784 frm.Reason.code = nReason;
2785
2786 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2787 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002788 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789 nStatus);
2790 /* We'll fall back on the worst case scenario: */
2791 nPayload = sizeof(tDot11fDisassociation);
2792 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002793 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2794 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 }
2796
2797 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302799 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302801 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002802 pe_err("Failed to allocate %d bytes for a Disassociation",
2803 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 return;
2805 }
2806 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302807 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002808
2809 /* Next, we fill out the buffer descriptor: */
2810 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2811 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2812 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2813
2814 /* Prepare the BSSID */
2815 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2816
2817#ifdef WLAN_FEATURE_11W
2818 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2819#endif
2820
2821 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2822 sizeof(tSirMacMgmtHdr),
2823 nPayload, &nPayload);
2824 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002825 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 nStatus);
2827 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002828 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002830 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2831 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 }
2833
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002834 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002836 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2838 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2839
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002840 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302841 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2842 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 ) {
2844 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2845 }
2846
Sushant Kaushik46556062015-12-02 16:57:47 +05302847 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848
2849 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302850 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 psessionEntry->peSessionId,
2852 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002853 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2854 psessionEntry, eSIR_SUCCESS,
2855 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 /* Queue Disassociation frame in high priority WQ */
2857 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302858 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2860 TXRX_FRM_802_11_MGMT,
2861 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002862 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002863 txFlag, smeSessionId, false, 0,
2864 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302865 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302866 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302867 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868
2869 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2870
2871 if (tx_timer_change
2872 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2873 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002874 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 return;
2876 } else if (TX_SUCCESS !=
2877 tx_timer_activate(&pMac->lim.limTimers.
2878 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002879 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 lim_deactivate_and_change_timer(pMac,
2881 eLIM_DISASSOC_ACK_TIMER);
2882 return;
2883 }
2884 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302885 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 psessionEntry->peSessionId,
2887 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002888 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2889 psessionEntry,
2890 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302892 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 TXRX_FRM_802_11_MGMT,
2894 ANI_TXDIR_TODS,
2895 7,
2896 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002897 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302898 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302899 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302900 psessionEntry->peSessionId, qdf_status));
2901 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002902 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302903 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 /* Pkt will be freed up by the callback */
2905 }
2906 }
2907} /* End lim_send_disassoc_mgmt_frame. */
2908
2909/**
2910 * \brief This function is called to send a Deauthenticate frame
2911 *
2912 *
2913 * \param pMac Pointer to global MAC structure
2914 *
2915 * \param nReason Indicates the reason that need to be sent in the
2916 * Deauthenticate frame
2917 *
2918 * \param peeer address of the STA to which the frame is to be sent
2919 *
2920 *
2921 */
2922
2923void
2924lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
2925 uint16_t nReason,
2926 tSirMacAddr peer,
2927 tpPESession psessionEntry, bool waitForAck)
2928{
2929 tDot11fDeAuth frm;
2930 uint8_t *pFrame;
2931 tpSirMacMgmtHdr pMacHdr;
2932 uint32_t nBytes, nPayload, nStatus;
2933 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302934 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 uint8_t txFlag = 0;
2936 uint32_t val = 0;
2937#ifdef FEATURE_WLAN_TDLS
2938 uint16_t aid;
2939 tpDphHashNode pStaDs;
2940#endif
2941 uint8_t smeSessionId = 0;
2942
2943 if (NULL == psessionEntry) {
2944 return;
2945 }
2946
2947 /*
2948 * In case when cac timer is running for this SAP session then
2949 * avoid deauth frame out. It is violation of dfs specification.
2950 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302951 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2952 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302954 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 FL
2956 ("CAC timer is running, drop the deauth from going out"));
2957 return;
2958 }
2959 smeSessionId = psessionEntry->smeSessionId;
2960
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302961 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962
2963 frm.Reason.code = nReason;
2964
2965 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
2966 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002967 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 nStatus);
2969 /* We'll fall back on the worst case scenario: */
2970 nPayload = sizeof(tDot11fDeAuth);
2971 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002972 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
2973 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 }
2975
2976 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2977
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302980 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002981 pe_err("Failed to allocate %d bytes for a De-Authentication",
2982 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 return;
2984 }
2985 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302986 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987
2988 /* Next, we fill out the buffer descriptor: */
2989 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2990 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
2991 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2992
2993 /* Prepare the BSSID */
2994 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2995
2996#ifdef WLAN_FEATURE_11W
2997 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
2998#endif
2999
3000 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
3001 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3002 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003003 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 nStatus);
3005 cds_packet_free((void *)pPacket);
3006 return;
3007 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003008 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3009 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003011 pe_debug("***Sessionid %d Sending Deauth frame with "
3012 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3013 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014 psessionEntry->peSessionId, nReason, waitForAck,
3015 MAC_ADDR_ARRAY(pMacHdr->da),
3016 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3017
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003018 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303019 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3020 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 ) {
3022 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3023 }
3024
Sushant Kaushik46556062015-12-02 16:57:47 +05303025 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026#ifdef FEATURE_WLAN_TDLS
3027 pStaDs =
3028 dph_lookup_hash_entry(pMac, peer, &aid,
3029 &psessionEntry->dph.dphHashTable);
3030#endif
3031
3032 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303033 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 psessionEntry->peSessionId,
3035 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003036 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3037 psessionEntry,
3038 eSIR_SUCCESS, eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303040 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3042 TXRX_FRM_802_11_MGMT,
3043 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003044 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003045 txFlag, smeSessionId, false, 0,
3046 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303047 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303048 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303049 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303051 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003052 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303053 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054
3055 /* Call lim_process_deauth_ack_timeout which will send
3056 * DeauthCnf for this frame
3057 */
3058 lim_process_deauth_ack_timeout(pMac);
3059 return;
3060 }
3061
3062 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3063
3064 if (tx_timer_change
3065 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3066 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003067 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 return;
3069 } else if (TX_SUCCESS !=
3070 tx_timer_activate(&pMac->lim.limTimers.
3071 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003072 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 lim_deactivate_and_change_timer(pMac,
3074 eLIM_DEAUTH_ACK_TIMER);
3075 return;
3076 }
3077 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303078 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 psessionEntry->peSessionId,
3080 pMacHdr->fc.subType));
3081#ifdef FEATURE_WLAN_TDLS
3082 if ((NULL != pStaDs)
3083 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3084 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003085 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3086 psessionEntry,
3087 eSIR_SUCCESS,
3088 eSIR_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303089 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3091 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3092 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003093 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 } else {
3095#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003096 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3097 psessionEntry,
3098 eSIR_SUCCESS,
3099 eSIR_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3103 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3104 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003105 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106#ifdef FEATURE_WLAN_TDLS
3107 }
3108#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303109 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303110 psessionEntry->peSessionId, qdf_status));
3111 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003112 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303113 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 /* Pkt will be freed up by the callback */
3115 }
3116 }
3117
3118} /* End lim_send_deauth_mgmt_frame. */
3119
3120#ifdef ANI_SUPPORT_11H
3121/**
3122 * \brief Send a Measurement Report Action frame
3123 *
3124 *
3125 * \param pMac Pointer to the global MAC structure
3126 *
3127 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3128 *
3129 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3130 *
3131 *
3132 */
3133
3134tSirRetStatus
3135lim_send_meas_report_frame(tpAniSirGlobal pMac,
3136 tpSirMacMeasReqActionFrame pMeasReqFrame,
3137 tSirMacAddr peer, tpPESession psessionEntry)
3138{
3139 tDot11fMeasurementReport frm;
3140 uint8_t *pFrame;
3141 tSirRetStatus nSirStatus;
3142 tpSirMacMgmtHdr pMacHdr;
3143 uint32_t nBytes, nPayload, nStatus;
3144 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303147 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148
3149 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3150 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3151 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3152
3153 switch (pMeasReqFrame->measReqIE.measType) {
3154 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3155 nSirStatus =
3156 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3157 &frm.MeasurementReport);
3158 break;
3159 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3160 nSirStatus =
3161 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3162 &frm.MeasurementReport);
3163 break;
3164 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3165 nSirStatus =
3166 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3167 &frm.MeasurementReport);
3168 break;
3169 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003170 pe_err("Unknown measurement type %d in limSen"
3171 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 pMeasReqFrame->measReqIE.measType);
3173 return eSIR_FAILURE;
3174 }
3175
3176 if (eSIR_SUCCESS != nSirStatus)
3177 return eSIR_FAILURE;
3178
3179 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3180 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003181 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 nStatus);
3183 /* We'll fall back on the worst case scenario: */
3184 nPayload = sizeof(tDot11fMeasurementReport);
3185 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003186 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3187 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 }
3189
3190 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3191
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303192 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3194 (uint16_t) nBytes, (void **)&pFrame,
3195 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303196 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003197 pe_err("Failed to allocate %d bytes for a "
3198 "De-Authentication", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 return eSIR_FAILURE;
3200 }
3201 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303202 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203
3204 /* Next, we fill out the buffer descriptor: */
3205 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3206 SIR_MAC_MGMT_ACTION, peer);
3207 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3208
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303209 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210
3211#ifdef WLAN_FEATURE_11W
3212 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3213#endif
3214
3215 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3216 sizeof(tSirMacMgmtHdr),
3217 nPayload, &nPayload);
3218 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003219 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 nStatus);
3221 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3222 (void *)pFrame, (void *)pPacket);
3223 return eSIR_FAILURE; /* allocated! */
3224 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003225 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3226 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 }
3228
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303229 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 ((psessionEntry) ? psessionEntry->
3231 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303232 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3234 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003235 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303236 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303237 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303239 qdf_status));
3240 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003241 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303242 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 /* Pkt will be freed up by the callback */
3244 return eSIR_FAILURE; /* just allocated... */
3245 }
3246
3247 return eSIR_SUCCESS;
3248
3249} /* End lim_send_meas_report_frame. */
3250
3251/**
3252 * \brief Send a TPC Request Action frame
3253 *
3254 *
3255 * \param pMac Pointer to the global MAC datastructure
3256 *
3257 * \param peer MAC address to which the frame should be sent
3258 *
3259 *
3260 */
3261
3262void
3263lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3264 tSirMacAddr peer, tpPESession psessionEntry)
3265{
3266 tDot11fTPCRequest frm;
3267 uint8_t *pFrame;
3268 tpSirMacMgmtHdr pMacHdr;
3269 uint32_t nBytes, nPayload, nStatus;
3270 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303273 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274
3275 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3276 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3277 frm.DialogToken.token = 1;
3278 frm.TPCRequest.present = 1;
3279
3280 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3281 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003282 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 /* We'll fall back on the worst case scenario: */
3284 nPayload = sizeof(tDot11fTPCRequest);
3285 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003286 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3287 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 }
3289
3290 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3291
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3294 (uint16_t) nBytes, (void **)&pFrame,
3295 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303296 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003297 pe_err("Failed to allocate %d bytes for a TPC"
3298 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 return;
3300 }
3301 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303302 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303
3304 /* Next, we fill out the buffer descriptor: */
3305 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3306 SIR_MAC_MGMT_ACTION, peer);
3307 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3308
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303309 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310
3311#ifdef WLAN_FEATURE_11W
3312 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3313#endif
3314
3315 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3316 sizeof(tSirMacMgmtHdr),
3317 nPayload, &nPayload);
3318 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003319 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 nStatus);
3321 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3322 (void *)pFrame, (void *)pPacket);
3323 return; /* allocated! */
3324 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003325 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3326 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 }
3328
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303329 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 ((psessionEntry) ? psessionEntry->
3331 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3334 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003335 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303336 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303337 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303339 qdf_status));
3340 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003341 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303342 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 /* Pkt will be freed up by the callback */
3344 }
3345
3346} /* End lim_send_tpc_request_frame. */
3347
3348/**
3349 * \brief Send a TPC Report Action frame
3350 *
3351 *
3352 * \param pMac Pointer to the global MAC datastructure
3353 *
3354 * \param pTpcReqFrame Pointer to the received TPC Request
3355 *
3356 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3357 *
3358 *
3359 */
3360
3361tSirRetStatus
3362lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3363 tpSirMacTpcReqActionFrame pTpcReqFrame,
3364 tSirMacAddr peer, tpPESession psessionEntry)
3365{
3366 tDot11fTPCReport frm;
3367 uint8_t *pFrame;
3368 tpSirMacMgmtHdr pMacHdr;
3369 uint32_t nBytes, nPayload, nStatus;
3370 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303371 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303373 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374
3375 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3376 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3377 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3378
3379 frm.TPCReport.tx_power = 0;
3380 frm.TPCReport.link_margin = 0;
3381 frm.TPCReport.present = 1;
3382
3383 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3384 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003385 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 /* We'll fall back on the worst case scenario: */
3387 nPayload = sizeof(tDot11fTPCReport);
3388 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003389 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3390 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 }
3392
3393 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3394
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396 cds_packet_alloc(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3397 (uint16_t) nBytes, (void **)&pFrame,
3398 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303399 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003400 pe_err("Failed to allocate %d bytes for a TPC"
3401 " Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 return eSIR_FAILURE;
3403 }
3404 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303405 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406
3407 /* Next, we fill out the buffer descriptor: */
3408 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3409 SIR_MAC_MGMT_ACTION, peer);
3410
3411 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3412
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303413 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414
3415#ifdef WLAN_FEATURE_11W
3416 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3417#endif
3418
3419 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3420 sizeof(tSirMacMgmtHdr),
3421 nPayload, &nPayload);
3422 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003423 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 nStatus);
3425 cds_packet_free(pMac->hHdd, TXRX_FRM_802_11_MGMT,
3426 (void *)pFrame, (void *)pPacket);
3427 return eSIR_FAILURE; /* allocated! */
3428 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003429 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3430 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303432 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 ((psessionEntry) ? psessionEntry->
3434 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303435 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3437 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003438 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303439 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003440 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3441 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3442 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003444 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303445 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 /* Pkt will be freed up by the callback */
3447 return eSIR_FAILURE; /* just allocated... */
3448 }
3449
3450 return eSIR_SUCCESS;
3451
3452} /* End lim_send_tpc_report_frame. */
3453#endif /* ANI_SUPPORT_11H */
3454
3455/**
3456 * \brief Send a Channel Switch Announcement
3457 *
3458 *
3459 * \param pMac Pointer to the global MAC datastructure
3460 *
3461 * \param peer MAC address to which this frame will be sent
3462 *
3463 * \param nMode
3464 *
3465 * \param nNewChannel
3466 *
3467 * \param nCount
3468 *
3469 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3470 *
3471 *
3472 */
3473
3474tSirRetStatus
3475lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3476 tSirMacAddr peer,
3477 uint8_t nMode,
3478 uint8_t nNewChannel,
3479 uint8_t nCount, tpPESession psessionEntry)
3480{
3481 tDot11fChannelSwitch frm;
3482 uint8_t *pFrame;
3483 tpSirMacMgmtHdr pMacHdr;
3484 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3485 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 uint8_t txFlag = 0;
3488
3489 uint8_t smeSessionId = 0;
3490
3491 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003492 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 return eSIR_FAILURE;
3494 }
3495 smeSessionId = psessionEntry->smeSessionId;
3496
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303497 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498
3499 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3500 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3501 frm.ChanSwitchAnn.switchMode = nMode;
3502 frm.ChanSwitchAnn.newChannel = nNewChannel;
3503 frm.ChanSwitchAnn.switchCount = nCount;
3504 frm.ChanSwitchAnn.present = 1;
3505
3506 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3507 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003508 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 nStatus);
3510 /* We'll fall back on the worst case scenario: */
3511 nPayload = sizeof(tDot11fChannelSwitch);
3512 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003513 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3514 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 }
3516
3517 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3518
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303519 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3521 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003523 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 return eSIR_FAILURE;
3525 }
3526 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303527 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528
3529 /* Next, we fill out the buffer descriptor: */
3530 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3531 SIR_MAC_MGMT_ACTION, peer,
3532 psessionEntry->selfMacAddr);
3533 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303534 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3536
3537#ifdef WLAN_FEATURE_11W
3538 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
3539#endif
3540
3541 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3542 sizeof(tSirMacMgmtHdr),
3543 nPayload, &nPayload);
3544 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003545 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546 nStatus);
3547 cds_packet_free((void *)pPacket);
3548 return eSIR_FAILURE; /* allocated! */
3549 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003550 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3551 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 }
3553
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003554 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303555 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3556 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 ) {
3558 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3559 }
3560
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303561 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303563 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 TXRX_FRM_802_11_MGMT,
3565 ANI_TXDIR_TODS,
3566 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003567 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303568 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303569 psessionEntry->peSessionId, qdf_status));
3570 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003571 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303572 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 /* Pkt will be freed up by the callback */
3574 return eSIR_FAILURE;
3575 }
3576
3577 return eSIR_SUCCESS;
3578
3579} /* End lim_send_channel_switch_mgmt_frame. */
3580
Abhishek Singh518323d2015-10-19 17:42:01 +05303581/**
3582 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3583 * action frame over the air .
3584 * @mac_ctx: pointer to global mac structure
3585 * @peer: Destination mac.
3586 * @mode: channel switch mode
3587 * @new_op_class: new op class
3588 * @new_channel: new channel to switch
3589 * @count: channel switch count
3590 *
3591 * This function is called to send ECSA frame.
3592 *
3593 * Return: success if frame is sent else return failure
3594 */
3595
3596tSirRetStatus
3597lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3598 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3599 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3600{
3601 tDot11fext_channel_switch_action_frame frm;
3602 uint8_t *frame;
3603 tpSirMacMgmtHdr mac_hdr;
3604 uint32_t num_bytes, n_payload, status;
3605 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303607 uint8_t txFlag = 0;
3608 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303609 uint8_t ch_spacing;
3610 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303611
3612 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003613 pe_err("Session entry is NULL!!!");
Abhishek Singh518323d2015-10-19 17:42:01 +05303614 return eSIR_FAILURE;
3615 }
3616
3617 sme_session_id = session_entry->smeSessionId;
3618
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303619 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303620
3621 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3622 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3623
3624 frm.ext_chan_switch_ann_action.switch_mode = mode;
3625 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3626 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3627 frm.ext_chan_switch_ann_action.switch_count = count;
3628
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303629 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3630 mac_ctx->scan.countryCodeCurrent, new_channel,
3631 new_op_class);
3632 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3633
3634 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3635 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3636 frm.WiderBWChanSwitchAnn.newChanWidth =
3637 wide_bw_ie->newChanWidth;
3638 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3639 wide_bw_ie->newCenterChanFreq0;
3640 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3641 wide_bw_ie->newCenterChanFreq1;
3642 frm.WiderBWChanSwitchAnn.present = 1;
3643 pe_debug("wrapper: width:%d f0:%d f1:%d",
3644 frm.WiderBWChanSwitchAnn.newChanWidth,
3645 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3646 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3647 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303648
3649 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3650 &frm, &n_payload);
3651 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003652 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303653 status);
3654 /* We'll fall back on the worst case scenario*/
3655 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3656 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003657 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303658 status);
3659 }
3660
3661 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3662
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303663 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303664 (void **) &frame, (void **) &packet);
3665
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303666 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003667 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303668 num_bytes);
3669 return eSIR_FAILURE;
3670 }
3671
3672 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303673 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303674
3675 /* Next, we fill out the buffer descriptor */
3676 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3677 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3678 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303679 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303680 (uint8_t *) session_entry->bssId,
3681 sizeof(tSirMacAddr));
3682
3683 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3684 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3685 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003686 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303687 cds_packet_free((void *)packet);
3688 return eSIR_FAILURE;
3689 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003690 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303691 status);
3692 }
3693
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003694 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303695 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303696 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3697 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303698 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3699 }
3700
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003701 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 +05303702 MAC_ADDR_ARRAY(mac_hdr->da),
3703 frm.ext_chan_switch_ann_action.switch_count,
3704 frm.ext_chan_switch_ann_action.switch_mode,
3705 frm.ext_chan_switch_ann_action.new_channel,
3706 frm.ext_chan_switch_ann_action.op_class);
3707
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303708 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303709 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303710 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303711 TXRX_FRM_802_11_MGMT,
3712 ANI_TXDIR_TODS,
3713 7,
3714 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003715 txFlag, sme_session_id, 0,
3716 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303717 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303718 session_entry->peSessionId, qdf_status));
3719 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003720 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303721 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303722 /* Pkt will be freed up by the callback */
3723 return eSIR_FAILURE;
3724 }
3725 return eSIR_SUCCESS;
3726} /* End lim_send_extended_chan_switch_action_frame */
3727
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303728
3729/**
3730 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3731 * sent over the air
3732 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303733 * @context: pointer to global mac
3734 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303735 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303736 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303737 *
3738 * Return: This returns QDF_STATUS
3739 */
3740
3741static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303742 void *context,
3743 qdf_nbuf_t buf,
3744 uint32_t tx_complete,
3745 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303746{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003747 pe_debug("tx_complete: %d", tx_complete);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303748 return QDF_STATUS_SUCCESS;
3749}
3750
3751/**
3752 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3753 * p2p oper chan change confirm action frame
3754 * @mac_ctx: pointer to global mac structure
3755 * @peer: Destination mac.
3756 * @session_entry: session entry
3757 *
3758 * This function is called to send p2p oper chan change confirm action frame.
3759 *
3760 * Return: success if frame is sent else return failure
3761 */
3762
3763tSirRetStatus
3764lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3765 tSirMacAddr peer, tpPESession session_entry)
3766{
3767 tDot11fp2p_oper_chan_change_confirm frm;
3768 uint8_t *frame;
3769 tpSirMacMgmtHdr mac_hdr;
3770 uint32_t num_bytes, n_payload, status;
3771 void *packet;
3772 QDF_STATUS qdf_status;
3773 uint8_t tx_flag = 0;
3774 uint8_t sme_session_id = 0;
3775
3776 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003777 pe_err("Session entry is NULL!!!");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303778 return eSIR_FAILURE;
3779 }
3780
3781 sme_session_id = session_entry->smeSessionId;
3782
3783 qdf_mem_set(&frm, sizeof(frm), 0);
3784
3785 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3786
3787 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3788 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3789 frm.p2p_action_subtype.subtype = 0x04;
3790 frm.DialogToken.token = 0x0;
3791
3792 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003793 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303794 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3795 }
3796
3797 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003798 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303799 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3800 populate_dot11f_operating_mode(mac_ctx,
3801 &frm.OperatingMode, session_entry);
3802 }
3803
3804 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3805 &frm, &n_payload);
3806 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003807 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303808 /* We'll fall back on the worst case scenario*/
3809 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3810 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003811 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3812 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303813 }
3814
3815 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3816
3817 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3818 (void **) &frame, (void **) &packet);
3819
3820 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003821 pe_err("Failed to allocate %d bytes", num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303822 return eSIR_FAILURE;
3823 }
3824
3825 qdf_mem_set(frame, num_bytes, 0);
3826
3827 /* Next, fill out the buffer descriptor */
3828 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3829 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3830 mac_hdr = (tpSirMacMgmtHdr) frame;
3831 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3832 (uint8_t *) session_entry->bssId,
3833 sizeof(tSirMacAddr));
3834
3835 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3836 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3837 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003838 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303839 cds_packet_free((void *)packet);
3840 return eSIR_FAILURE;
3841 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003842 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303843 status);
3844 }
3845
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003846 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303847 lim_get_rf_band(session_entry->currentOperChannel)) ||
3848 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3849 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3850 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3851 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003852 pe_debug("Send frame on channel %d to mac "
3853 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303854 MAC_ADDR_ARRAY(peer));
3855
3856 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3857 session_entry->peSessionId, mac_hdr->fc.subType));
3858
3859 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3860 (uint16_t)num_bytes,
3861 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3862 7, lim_tx_complete, frame,
3863 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003864 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303865
3866 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3867 session_entry->peSessionId, qdf_status));
3868 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003869 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303870 /* Pkt will be freed up by the callback */
3871 return eSIR_FAILURE;
3872 }
3873 return eSIR_SUCCESS;
3874}
3875
3876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877tSirRetStatus
3878lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3879 tSirMacAddr peer,
3880 uint8_t nMode, tpPESession psessionEntry)
3881{
3882 tDot11fOperatingMode frm;
3883 uint8_t *pFrame;
3884 tpSirMacMgmtHdr pMacHdr;
3885 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3886 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303887 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 uint8_t txFlag = 0;
3889
3890 uint8_t smeSessionId = 0;
3891
3892 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003893 pe_err("Session entry is NULL!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 return eSIR_FAILURE;
3895 }
3896 smeSessionId = psessionEntry->smeSessionId;
3897
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303898 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899
3900 frm.Category.category = SIR_MAC_ACTION_VHT;
3901 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3902 frm.OperatingMode.chanWidth = nMode;
3903 frm.OperatingMode.rxNSS = 0;
3904 frm.OperatingMode.rxNSSType = 0;
3905
3906 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3907 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003908 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 nStatus);
3910 /* We'll fall back on the worst case scenario: */
3911 nPayload = sizeof(tDot11fOperatingMode);
3912 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003913 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3914 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 }
3916
3917 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3918
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303919 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3921 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303922 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003923 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
3924 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 return eSIR_FAILURE;
3926 }
3927 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303928 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929
3930 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303931 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003932 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3933 SIR_MAC_MGMT_ACTION, peer,
3934 psessionEntry->selfMacAddr);
3935 else
3936 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3937 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
3938 psessionEntry->selfMacAddr);
3939 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303940 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3942 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
3943 sizeof(tSirMacMgmtHdr),
3944 nPayload, &nPayload);
3945 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003946 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 nStatus);
3948 cds_packet_free((void *)pPacket);
3949 return eSIR_FAILURE; /* allocated! */
3950 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003951 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
3952 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003954 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303955 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3956 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 ) {
3958 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3959 }
3960
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303961 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303963 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964 TXRX_FRM_802_11_MGMT,
3965 ANI_TXDIR_TODS,
3966 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003967 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303968 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303969 psessionEntry->peSessionId, qdf_status));
3970 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003971 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303972 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973 /* Pkt will be freed up by the callback */
3974 return eSIR_FAILURE;
3975 }
3976
3977 return eSIR_SUCCESS;
3978}
3979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980/**
3981 * \brief Send a Neighbor Report Request Action frame
3982 *
3983 *
3984 * \param pMac Pointer to the global MAC structure
3985 *
3986 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3987 *
3988 * \param peer mac address of peer station.
3989 *
3990 * \param psessionEntry address of session entry.
3991 *
3992 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
3993 *
3994 *
3995 */
3996
3997tSirRetStatus
3998lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
3999 tpSirMacNeighborReportReq pNeighborReq,
4000 tSirMacAddr peer, tpPESession psessionEntry)
4001{
4002 tSirRetStatus statusCode = eSIR_SUCCESS;
4003 tDot11fNeighborReportRequest frm;
4004 uint8_t *pFrame;
4005 tpSirMacMgmtHdr pMacHdr;
4006 uint32_t nBytes, nPayload, nStatus;
4007 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304008 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 uint8_t txFlag = 0;
4010 uint8_t smeSessionId = 0;
4011
4012 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004013 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004014 return eSIR_FAILURE;
4015 }
4016 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304017 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004018
4019 frm.Category.category = SIR_MAC_ACTION_RRM;
4020 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4021 frm.DialogToken.token = pNeighborReq->dialogToken;
4022
4023 if (pNeighborReq->ssid_present) {
4024 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4025 }
4026
4027 nStatus =
4028 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4029 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004030 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 nStatus);
4032 /* We'll fall back on the worst case scenario: */
4033 nPayload = sizeof(tDot11fNeighborReportRequest);
4034 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004035 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4036 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
4038
4039 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4040
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4043 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304044 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004045 pe_err("Failed to allocate %d bytes for a Neighbor "
4046 "Report Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 return eSIR_FAILURE;
4048 }
4049 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051
4052 /* Copy necessary info to BD */
4053 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4054 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4055
4056 /* Update A3 with the BSSID */
4057 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4058
4059 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4060
4061#ifdef WLAN_FEATURE_11W
4062 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4063#endif
4064
4065 /* Now, we're ready to "pack" the frames */
4066 nStatus = dot11f_pack_neighbor_report_request(pMac,
4067 &frm,
4068 pFrame +
4069 sizeof(tSirMacMgmtHdr),
4070 nPayload, &nPayload);
4071
4072 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004073 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 nStatus);
4075
4076 /* FIXME - Need to convert to tSirRetStatus */
4077 statusCode = eSIR_FAILURE;
4078 goto returnAfterError;
4079 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004080 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4081 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 }
4083
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004084 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304085 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004087 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304088 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4089 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 ) {
4091 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4092 }
4093
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304094 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304096 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 pPacket,
4098 (uint16_t) nBytes,
4099 TXRX_FRM_802_11_MGMT,
4100 ANI_TXDIR_TODS,
4101 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004102 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304103 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304104 psessionEntry->peSessionId, qdf_status));
4105 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004106 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 statusCode = eSIR_FAILURE;
4108 /* Pkt will be freed up by the callback */
4109 return statusCode;
4110 } else
4111 return eSIR_SUCCESS;
4112
4113returnAfterError:
4114 cds_packet_free((void *)pPacket);
4115
4116 return statusCode;
4117} /* End lim_send_neighbor_report_request_frame. */
4118
4119/**
4120 * \brief Send a Link Report Action frame
4121 *
4122 *
4123 * \param pMac Pointer to the global MAC structure
4124 *
4125 * \param pLinkReport Address of a tSirMacLinkReport
4126 *
4127 * \param peer mac address of peer station.
4128 *
4129 * \param psessionEntry address of session entry.
4130 *
4131 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4132 *
4133 *
4134 */
4135
4136tSirRetStatus
4137lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4138 tpSirMacLinkReport pLinkReport,
4139 tSirMacAddr peer, tpPESession psessionEntry)
4140{
4141 tSirRetStatus statusCode = eSIR_SUCCESS;
4142 tDot11fLinkMeasurementReport frm;
4143 uint8_t *pFrame;
4144 tpSirMacMgmtHdr pMacHdr;
4145 uint32_t nBytes, nPayload, nStatus;
4146 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304147 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 uint8_t txFlag = 0;
4149 uint8_t smeSessionId = 0;
4150
4151 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004152 pe_err("(psession == NULL) in Request to send Link Report action frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 return eSIR_FAILURE;
4154 }
4155
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304156 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157
4158 frm.Category.category = SIR_MAC_ACTION_RRM;
4159 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4160 frm.DialogToken.token = pLinkReport->dialogToken;
4161
4162 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4163 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4164 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4165 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4166 /* such case this way than changing the frame parser. */
4167 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4168 frm.TPCEleLen.TPCLen = 2;
4169 frm.TxPower.txPower = pLinkReport->txPower;
4170 frm.LinkMargin.linkMargin = 0;
4171
4172 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4173 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4174 frm.RCPI.rcpi = pLinkReport->rcpi;
4175 frm.RSNI.rsni = pLinkReport->rsni;
4176
4177 nStatus =
4178 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4179 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004180 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 /* We'll fall back on the worst case scenario: */
4182 nPayload = sizeof(tDot11fLinkMeasurementReport);
4183 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004184 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4185 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 }
4187
4188 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4189
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304190 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4192 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304193 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004194 pe_err("Failed to allocate %d bytes for a Link "
4195 "Report", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 return eSIR_FAILURE;
4197 }
4198 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304199 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200
4201 /* Copy necessary info to BD */
4202 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4203 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4204
4205 /* Update A3 with the BSSID */
4206 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4207
4208 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4209
4210#ifdef WLAN_FEATURE_11W
4211 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4212#endif
4213
4214 /* Now, we're ready to "pack" the frames */
4215 nStatus = dot11f_pack_link_measurement_report(pMac,
4216 &frm,
4217 pFrame +
4218 sizeof(tSirMacMgmtHdr),
4219 nPayload, &nPayload);
4220
4221 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004222 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223
4224 /* FIXME - Need to convert to tSirRetStatus */
4225 statusCode = eSIR_FAILURE;
4226 goto returnAfterError;
4227 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004228 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 nStatus);
4230 }
4231
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004232 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 lim_print_mac_addr(pMac, peer, LOGW);
4234
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004235 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304236 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4237 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4239 }
4240
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304241 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304243 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 pPacket,
4245 (uint16_t) nBytes,
4246 TXRX_FRM_802_11_MGMT,
4247 ANI_TXDIR_TODS,
4248 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004249 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304250 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304251 psessionEntry->peSessionId, qdf_status));
4252 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004253 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 statusCode = eSIR_FAILURE;
4255 /* Pkt will be freed up by the callback */
4256 return statusCode;
4257 } else
4258 return eSIR_SUCCESS;
4259
4260returnAfterError:
4261 cds_packet_free((void *)pPacket);
4262
4263 return statusCode;
4264} /* End lim_send_link_report_action_frame. */
4265
4266/**
4267 * \brief Send a Beacon Report Action frame
4268 *
4269 *
4270 * \param pMac Pointer to the global MAC structure
4271 *
4272 * \param dialog_token dialog token to be used in the action frame.
4273 *
4274 * \param num_report number of reports in pRRMReport.
4275 *
4276 * \param pRRMReport Address of a tSirMacRadioMeasureReport.
4277 *
4278 * \param peer mac address of peer station.
4279 *
4280 * \param psessionEntry address of session entry.
4281 *
4282 * \return eSIR_SUCCESS on success, eSIR_FAILURE else
4283 *
4284 *
4285 */
4286
4287tSirRetStatus
4288lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
4289 uint8_t dialog_token,
4290 uint8_t num_report,
4291 tpSirMacRadioMeasureReport pRRMReport,
4292 tSirMacAddr peer,
4293 tpPESession psessionEntry)
4294{
4295 tSirRetStatus statusCode = eSIR_SUCCESS;
4296 uint8_t *pFrame;
4297 tpSirMacMgmtHdr pMacHdr;
4298 uint32_t nBytes, nPayload, nStatus;
4299 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304300 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 uint8_t i;
4302 uint8_t txFlag = 0;
4303 uint8_t smeSessionId = 0;
4304
4305 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304306 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004308 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 return eSIR_MEM_ALLOC_FAILED;
4310 }
4311
4312 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004313 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304314 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 return eSIR_FAILURE;
4316 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004318 smeSessionId = psessionEntry->smeSessionId;
4319
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004320 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304321 dialog_token, num_report);
4322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323 frm->Category.category = SIR_MAC_ACTION_RRM;
4324 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4325 frm->DialogToken.token = dialog_token;
4326
4327 frm->num_MeasurementReport =
4328 (num_report >
4329 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4330 num_report;
4331
4332 for (i = 0; i < frm->num_MeasurementReport; i++) {
4333 frm->MeasurementReport[i].type = pRRMReport[i].type;
4334 frm->MeasurementReport[i].token = pRRMReport[i].token;
4335 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4336 switch (pRRMReport[i].type) {
4337 case SIR_MAC_RRM_BEACON_TYPE:
4338 populate_dot11f_beacon_report(pMac,
4339 &frm->MeasurementReport[i],
4340 &pRRMReport[i].report.
4341 beaconReport);
4342 frm->MeasurementReport[i].incapable =
4343 pRRMReport[i].incapable;
4344 frm->MeasurementReport[i].refused =
4345 pRRMReport[i].refused;
4346 frm->MeasurementReport[i].present = 1;
4347 break;
4348 default:
4349 frm->MeasurementReport[i].incapable =
4350 pRRMReport[i].incapable;
4351 frm->MeasurementReport[i].refused =
4352 pRRMReport[i].refused;
4353 frm->MeasurementReport[i].present = 1;
4354 break;
4355 }
4356 }
4357
4358 nStatus =
4359 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4360 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004361 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 nStatus);
4363 /* We'll fall back on the worst case scenario: */
4364 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304365 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366 return eSIR_FAILURE;
4367 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004368 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4369 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 }
4371
4372 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4373
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304374 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4376 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304377 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004378 pe_err("Failed to allocate %d bytes for a Radio Measure "
4379 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304380 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 return eSIR_FAILURE;
4382 }
4383 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304384 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385
4386 /* Copy necessary info to BD */
4387 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4388 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4389
4390 /* Update A3 with the BSSID */
4391 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4392
4393 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4394
4395#ifdef WLAN_FEATURE_11W
4396 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4397#endif
4398
4399 /* Now, we're ready to "pack" the frames */
4400 nStatus = dot11f_pack_radio_measurement_report(pMac,
4401 frm,
4402 pFrame +
4403 sizeof(tSirMacMgmtHdr),
4404 nPayload, &nPayload);
4405
4406 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004407 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 nStatus);
4409
4410 /* FIXME - Need to convert to tSirRetStatus */
4411 statusCode = eSIR_FAILURE;
4412 goto returnAfterError;
4413 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004414 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4415 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 }
4417
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004418 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419 lim_print_mac_addr(pMac, peer, LOGW);
4420
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004421 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304422 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4423 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 ) {
4425 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4426 }
4427
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304428 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304430 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 pPacket,
4432 (uint16_t) nBytes,
4433 TXRX_FRM_802_11_MGMT,
4434 ANI_TXDIR_TODS,
4435 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004436 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304437 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304438 psessionEntry->peSessionId, qdf_status));
4439 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004440 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 statusCode = eSIR_FAILURE;
4442 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304443 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 return statusCode;
4445 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304446 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 return eSIR_SUCCESS;
4448 }
4449
4450returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 cds_packet_free((void *)pPacket);
4453 return statusCode;
4454}
4455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456#ifdef WLAN_FEATURE_11W
4457/**
4458 * \brief Send SA query request action frame to peer
4459 *
4460 * \sa lim_send_sa_query_request_frame
4461 *
4462 *
4463 * \param pMac The global tpAniSirGlobal object
4464 *
4465 * \param transId Transaction identifier
4466 *
4467 * \param peer The Mac address of the station to which this action frame is addressed
4468 *
4469 * \param psessionEntry The PE session entry
4470 *
4471 * \return eSIR_SUCCESS if setup completes successfully
4472 * eSIR_FAILURE is some problem is encountered
4473 */
4474
4475tSirRetStatus lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
4476 tSirMacAddr peer,
4477 tpPESession psessionEntry)
4478{
4479
4480 tDot11fSaQueryReq frm; /* SA query request action frame */
4481 uint8_t *pFrame;
4482 tSirRetStatus nSirStatus;
4483 tpSirMacMgmtHdr pMacHdr;
4484 uint32_t nBytes, nPayload, nStatus;
4485 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304486 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 uint8_t txFlag = 0;
4488 uint8_t smeSessionId = 0;
4489
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304490 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4492 /* 11w action field is :
4493 action: 0 --> SA Query Request action frame
4494 action: 1 --> SA Query Response action frame */
4495 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4496 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304497 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498
4499 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4500 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004501 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 nStatus);
4503 /* We'll fall back on the worst case scenario: */
4504 nPayload = sizeof(tDot11fSaQueryReq);
4505 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004506 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4507 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 }
4509
4510 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304511 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304513 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004514 pe_err("Failed to allocate %d bytes for a SA Query Request "
4515 "action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 return eSIR_FAILURE;
4517 }
4518 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304519 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520
4521 /* Copy necessary info to BD */
4522 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4523 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4524
4525 /* Update A3 with the BSSID */
4526 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4527
4528 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4529
4530 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4531 /* in the FC */
4532 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4533
4534 /* Pack 11w SA Query Request frame */
4535 nStatus = dot11f_pack_sa_query_req(pMac,
4536 &frm,
4537 pFrame + sizeof(tSirMacMgmtHdr),
4538 nPayload, &nPayload);
4539
4540 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004541 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 nStatus);
4543 /* FIXME - Need to convert to tSirRetStatus */
4544 nSirStatus = eSIR_FAILURE;
4545 goto returnAfterError;
4546 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004547 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 nStatus);
4549 }
4550
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004551 pe_debug("Sending an SA Query Request to");
4552 lim_print_mac_addr(pMac, peer, LOGD);
4553 pe_debug("Sending an SA Query Request from ");
4554 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004556 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304558 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4559 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560#endif
4561 ) {
4562 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4563 }
4564 smeSessionId = psessionEntry->smeSessionId;
4565
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304566 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 pPacket,
4568 (uint16_t) nBytes,
4569 TXRX_FRM_802_11_MGMT,
4570 ANI_TXDIR_TODS,
4571 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004572 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304573 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004574 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 nSirStatus = eSIR_FAILURE;
4576 /* Pkt will be freed up by the callback */
4577 return nSirStatus;
4578 } else {
4579 return eSIR_SUCCESS;
4580 }
4581
4582returnAfterError:
4583 cds_packet_free((void *)pPacket);
4584 return nSirStatus;
4585} /* End lim_send_sa_query_request_frame */
4586
4587/**
4588 * \brief Send SA query response action frame to peer
4589 *
4590 * \sa lim_send_sa_query_response_frame
4591 *
4592 *
4593 * \param pMac The global tpAniSirGlobal object
4594 *
4595 * \param transId Transaction identifier received in SA query request action frame
4596 *
4597 * \param peer The Mac address of the AP to which this action frame is addressed
4598 *
4599 * \param psessionEntry The PE session entry
4600 *
4601 * \return eSIR_SUCCESS if setup completes successfully
4602 * eSIR_FAILURE is some problem is encountered
4603 */
4604
4605tSirRetStatus lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
4606 uint8_t *transId, tSirMacAddr peer,
4607 tpPESession psessionEntry)
4608{
4609
4610 tDot11fSaQueryRsp frm; /* SA query reponse action frame */
4611 uint8_t *pFrame;
4612 tSirRetStatus nSirStatus;
4613 tpSirMacMgmtHdr pMacHdr;
4614 uint32_t nBytes, nPayload, nStatus;
4615 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304616 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 uint8_t txFlag = 0;
4618 uint8_t smeSessionId = 0;
4619
4620 smeSessionId = psessionEntry->smeSessionId;
4621
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304622 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4624 /*11w action field is :
4625 action: 0 --> SA query request action frame
4626 action: 1 --> SA query response action frame */
4627 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4628 /*11w SA query response transId is same as
4629 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304630 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631
4632 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4633 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004634 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 nStatus);
4636 /* We'll fall back on the worst case scenario: */
4637 nPayload = sizeof(tDot11fSaQueryRsp);
4638 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004639 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4640 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 }
4642
4643 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304644 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304646 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004647 pe_err("Failed to allocate %d bytes for a SA query response"
4648 " action frame", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 return eSIR_FAILURE;
4650 }
4651 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304652 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653
4654 /* Copy necessary info to BD */
4655 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4656 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4657
4658 /* Update A3 with the BSSID */
4659 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4660
4661 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4662
4663 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4664 /* in the FC */
4665 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4666
4667 /* Pack 11w SA query response frame */
4668 nStatus = dot11f_pack_sa_query_rsp(pMac,
4669 &frm,
4670 pFrame + sizeof(tSirMacMgmtHdr),
4671 nPayload, &nPayload);
4672
4673 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004674 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 nStatus);
4676 /* FIXME - Need to convert to tSirRetStatus */
4677 nSirStatus = eSIR_FAILURE;
4678 goto returnAfterError;
4679 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004680 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681 nStatus);
4682 }
4683
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004684 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004685 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004687 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304689 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4690 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691#endif
4692 ) {
4693 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4694 }
4695
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304696 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304698 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 pPacket,
4700 (uint16_t) nBytes,
4701 TXRX_FRM_802_11_MGMT,
4702 ANI_TXDIR_TODS,
4703 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004704 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304705 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304706 psessionEntry->peSessionId, qdf_status));
4707 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004708 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 nSirStatus = eSIR_FAILURE;
4710 /* Pkt will be freed up by the callback */
4711 return nSirStatus;
4712 } else {
4713 return eSIR_SUCCESS;
4714 }
4715
4716returnAfterError:
4717 cds_packet_free((void *)pPacket);
4718 return nSirStatus;
4719} /* End lim_send_sa_query_response_frame */
4720#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004721
4722/**
4723 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4724 * @mac_ctx: mac context
4725 * @peer_mac: Peer MAC address
4726 * @tid: TID for which addba response is being sent
4727 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004728 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004729 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004730 *
4731 * This function is called when ADDBA request is successful. ADDBA response is
4732 * setup by calling addba_response_setup API and frame is then sent out OTA.
4733 *
4734 * Return: QDF_STATUS
4735 */
4736QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004737 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004738 tpPESession session, uint8_t addba_extn_present,
4739 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004740{
4741
4742 tDot11faddba_rsp frm;
4743 uint8_t *frame_ptr;
4744 tpSirMacMgmtHdr mgmt_hdr;
4745 uint32_t num_bytes, payload_size, status;
4746 void *pkt_ptr;
4747 QDF_STATUS qdf_status;
4748 uint8_t tx_flag = 0;
4749 uint8_t sme_sessionid = 0;
4750 uint16_t buff_size, status_code, batimeout;
4751 uint8_t peer_id, dialog_token;
4752 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4753 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004754 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004755
4756 sme_sessionid = session->smeSessionId;
4757
4758 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4759 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004760 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004761 return QDF_STATUS_E_FAILURE;
4762 }
4763
Mohit Khannac4c22252017-11-20 11:06:33 -08004764 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4765 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004766 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004767 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004768 return QDF_STATUS_E_FAILURE;
4769 }
4770
4771 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4772 &status_code, &buff_size, &batimeout);
4773
Mohit Khannac4c22252017-11-20 11:06:33 -08004774 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004775 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4776 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4777 frm.Action.action = SIR_MAC_ADDBA_RSP;
4778
4779 frm.DialogToken.token = dialog_token;
4780 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004781 if (mac_ctx->reject_addba_req) {
4782 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4783 pe_err("refused addba req");
4784 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004785 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004786 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004787 if (mac_ctx->usr_cfg_ba_buff_size)
4788 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004789 frm.addba_param_set.amsdu_supp = amsdu_support;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004790 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004791 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004792 if (addba_extn_present) {
4793 frm.addba_extn_element.present = 1;
4794 frm.addba_extn_element.no_fragmentation = 1;
4795 if (lim_is_session_he_capable(session)) {
4796 he_frag = lim_get_session_he_frag_cap(session);
4797 if (he_frag != 0) {
4798 frm.addba_extn_element.no_fragmentation = 0;
4799 frm.addba_extn_element.he_frag_operation =
4800 he_frag;
4801 }
4802 }
4803 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004804
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004805 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004806 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004807 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004808 tid, frm.DialogToken.token, frm.Status.status,
4809 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004810 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4811 addba_extn_present,
4812 lim_is_session_he_capable(session),
4813 frm.addba_extn_element.no_fragmentation,
4814 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004815
4816 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4817 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004818 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004819 status);
4820 /* We'll fall back on the worst case scenario: */
4821 payload_size = sizeof(tDot11faddba_rsp);
4822 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004823 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 -08004824 }
4825
4826 num_bytes = payload_size + sizeof(*mgmt_hdr);
4827 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4828 (void **)&pkt_ptr);
4829 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004830 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4831 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004832 return QDF_STATUS_E_FAILURE;
4833 }
4834 qdf_mem_set(frame_ptr, num_bytes, 0);
4835
4836 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4837 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4838
4839 /* Update A3 with the BSSID */
4840 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4841 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4842
4843 /* ADDBA Response is a robust mgmt action frame,
4844 * set the "protect" (aka WEP) bit in the FC
4845 */
4846 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4847
4848 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4849 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4850 &payload_size);
4851
4852 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004853 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004854 status);
4855 qdf_status = QDF_STATUS_E_FAILURE;
4856 goto error_addba_rsp;
4857 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004858 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004859 status);
4860 }
4861
4862
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004863 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004864#ifdef WLAN_FEATURE_P2P
4865 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4866 (session->pePersona == QDF_P2P_GO_MODE)
4867#endif
4868 ) {
4869 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4870 }
4871
4872 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4873 session->peSessionId, mgmt_hdr->fc.subType));
4874 qdf_status = wma_tx_frame(mac_ctx, pkt_ptr, (uint16_t) num_bytes,
4875 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07004876 lim_tx_complete, frame_ptr, tx_flag, sme_sessionid, 0,
4877 RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004878 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4879 session->peSessionId, qdf_status));
4880 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004881 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004882 qdf_status);
4883 qdf_status = QDF_STATUS_E_FAILURE;
4884 /*
4885 * wma_tx_frame free memory in certain cases, free pkt_ptr
4886 * only if not freed already.
4887 */
4888 if (pkt_ptr)
4889 cds_packet_free((void *)pkt_ptr);
4890 return qdf_status;
4891 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004892 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004893 }
4894
4895error_addba_rsp:
4896 cds_packet_free((void *)pkt_ptr);
4897 return qdf_status;
4898}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304899
4900/**
4901 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4902 * @mac_ctx Pointer to Global MAC structure
4903 * @mb_msg: Received message info
4904 * @msg_len: Received message length
4905 * @packet: Packet to be transmitted
4906 * @frame: Received frame
4907 *
4908 * Return: None
4909 */
4910static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4911 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4912 void *packet, uint8_t *frame)
4913{
4914 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4915 QDF_STATUS qdf_status;
4916 uint8_t sme_session_id = 0;
4917 tpPESession session;
4918 uint16_t auth_ack_status;
4919 enum rateid min_rid = RATEID_DEFAULT;
4920
4921 sme_session_id = mb_msg->session_id;
4922 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
4923 if (session == NULL) {
4924 pe_err("session not found for given sme session");
4925 return;
4926 }
4927
4928 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4929 session->peSessionId, fc->subType));
4930
4931 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4932 min_rid = lim_get_min_session_txrate(session);
4933
4934 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4935 (uint16_t)msg_len,
4936 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4937 7, lim_tx_complete, frame,
4938 lim_auth_tx_complete_cnf,
4939 0, sme_session_id, false, 0, min_rid);
4940 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4941 session->peSessionId, qdf_status));
4942 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304943 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4944 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304945 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4946 auth_ack_status = SENT_FAIL;
4947 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
4948 session, auth_ack_status, eSIR_FAILURE);
4949 /* Pkt will be freed up by the callback */
4950 }
4951}
4952
4953void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
4954 struct scheduler_msg *msg)
4955{
4956 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
4957 uint32_t msg_len;
4958 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4959 uint8_t sme_session_id;
4960 QDF_STATUS qdf_status;
4961 uint8_t *frame;
4962 void *packet;
4963
4964 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
4965 pe_debug("sending fc->type: %d fc->subType: %d",
4966 fc->type, fc->subType);
4967
4968 sme_session_id = mb_msg->session_id;
4969
4970 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
4971 (void **)&packet);
4972 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4973 pe_err("call to bufAlloc failed for AUTH frame");
4974 return;
4975 }
4976
4977 qdf_mem_copy(frame, mb_msg->data, msg_len);
4978
4979 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
4980}