blob: 60056a2f62f995953a65aa8606442f67832f18e9 [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 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * \file lim_send_management_frames.c
21 *
22 * \brief Code for preparing and sending 802.11 Management frames
23 *
24 *
25 */
26
27#include "sir_api.h"
28#include "ani_global.h"
29#include "sir_mac_prot_def.h"
30#include "cfg_api.h"
31#include "utils_api.h"
32#include "lim_types.h"
33#include "lim_utils.h"
34#include "lim_security_utils.h"
35#include "lim_prop_exts_utils.h"
36#include "dot11f.h"
37#include "lim_sta_hash_api.h"
38#include "sch_api.h"
39#include "lim_send_messages.h"
40#include "lim_assoc_utils.h"
41#include "lim_ft.h"
42#ifdef WLAN_FEATURE_11W
43#include "wni_cfg.h"
44#endif
45
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053048#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053049#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "cds_utils.h"
51#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053053#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
55#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080056#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070057#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053058#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61/**
62 *
63 * \brief This function is called to add the sequence number to the
64 * management frames
65 *
66 * \param pMac Pointer to Global MAC structure
67 *
68 * \param pMacHdr Pointer to MAC management header
69 *
70 * The pMacHdr argument points to the MAC management header. The
71 * sequence number stored in the pMac structure will be incremented
72 * and updated to the MAC management header. The start sequence
73 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
74 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
75 * number will roll over.
76 *
77 */
Jeff Johnson38112a32016-10-07 07:30:50 -070078static void lim_add_mgmt_seq_num(tpAniSirGlobal pMac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079{
80 if (pMac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
81 pMac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
82 }
83
84 pMac->mgmtSeqNum++;
85
86 pMacHdr->seqControl.seqNumLo = (pMac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
87 pMacHdr->seqControl.seqNumHi =
88 ((pMac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
89}
90
91/**
92 *
93 * \brief This function is called before sending a p2p action frame
94 * inorder to add sequence numbers to action packets
95 *
96 * \param pMac Pointer to Global MAC structure
97 *
98 * \param pBD Pointer to the frame buffer that needs to be populate
99 *
100 * The pMacHdr argument points to the MAC management header. The
101 * sequence number stored in the pMac structure will be incremented
102 * and updated to the MAC management header. The start sequence
103 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
104 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
105 * number will roll over.
106 *
107 */
108void lim_populate_p2p_mac_header(tpAniSirGlobal pMac, uint8_t *pBD)
109{
110 tpSirMacMgmtHdr pMacHdr;
111
112 /* / Prepare MAC management header */
113 pMacHdr = (tpSirMacMgmtHdr) (pBD);
114
115 /* Prepare sequence number */
116 lim_add_mgmt_seq_num(pMac, pMacHdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700117 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 pMacHdr->seqControl.seqNumLo,
119 pMacHdr->seqControl.seqNumHi, pMac->mgmtSeqNum);
120}
121
122/**
123 * lim_populate_mac_header() - Fill in 802.11 header of frame
124 *
125 * @mac_ctx: Pointer to Global MAC structure
126 * @buf: Pointer to the frame buffer that needs to be populate
127 * @type: 802.11 Type of the frame
128 * @sub_type: 802.11 Subtype of the frame
129 * @peer_addr: dst address
130 * @self_mac_addr: local mac address
131 *
132 * This function is called by various LIM modules to prepare the
133 * 802.11 frame MAC header
134 *
135 * The buf argument points to the beginning of the frame buffer to
136 * which - a) The 802.11 MAC header is set b) Following this MAC header
137 * will be the MGMT frame payload The payload itself is populated by the
138 * caller API
139 *
140 * Return: None
141 */
142
143void lim_populate_mac_header(tpAniSirGlobal mac_ctx, uint8_t *buf,
144 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
145 tSirMacAddr self_mac_addr)
146{
147 tpSirMacMgmtHdr mac_hdr;
148
149 /* Prepare MAC management header */
150 mac_hdr = (tpSirMacMgmtHdr) (buf);
151
152 /* Prepare FC */
153 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
154 mac_hdr->fc.type = type;
155 mac_hdr->fc.subType = sub_type;
156
157 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530158 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
160
161 /* Prepare Address 2 */
162 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
163
164 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530165 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
167
168 /* Prepare sequence number */
169 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700170 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 mac_hdr->seqControl.seqNumLo,
172 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
173}
174
175/**
176 * lim_send_probe_req_mgmt_frame() - send probe request management frame
177 * @mac_ctx: Pointer to Global MAC structure
178 * @ssid: SSID to be sent in Probe Request frame
179 * @bssid: BSSID to be sent in Probe Request frame
180 * @channel: Channel # on which the Probe Request is going out
181 * @self_macaddr: self MAC address
182 * @dot11mode: self dotllmode
183 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
184 * frame
185 * @additional_ie: if additional_ielen is non zero, include this field in the
186 * Probe Request frame
187 *
188 * This function is called by various LIM modules to send Probe Request frame
189 * during active scan/learn phase.
190 * Probe request is sent out in the following scenarios:
191 * --heartbeat failure: session needed
192 * --join req: session needed
193 * --foreground scan: no session
194 * --background scan: no session
195 * --sch_beacon_processing: to get EDCA parameters: session needed
196 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700197 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700199QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200lim_send_probe_req_mgmt_frame(tpAniSirGlobal mac_ctx,
201 tSirMacSSid *ssid,
202 tSirMacAddr bssid,
203 uint8_t channel,
204 tSirMacAddr self_macaddr,
205 uint32_t dot11mode,
Sandeep Puligilla06ae8902018-04-16 19:02:47 -0700206 uint16_t *additional_ielen, uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207{
208 tDot11fProbeRequest pr;
209 uint32_t status, bytes, payload;
210 uint8_t *frame;
211 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530212 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 tpPESession pesession;
214 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700215 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 uint8_t txflag = 0;
217 uint8_t sme_sessionid = 0;
218 bool is_vht_enabled = false;
219 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700220 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530221 bool extracted_ext_cap_flag = false;
222 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700223 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530224 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225
Arif Hussain4c265132018-04-23 18:55:26 -0700226 if (additional_ielen)
227 addn_ielen = *additional_ielen;
228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* The probe req should not send 11ac capabilieties if band is 2.4GHz,
230 * unless enableVhtFor24GHz is enabled in INI. So if enableVhtFor24GHz
231 * is false and dot11mode is 11ac set it to 11n.
232 */
233 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumarb074f2f2018-09-15 15:32:11 +0530234 (false == mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 (WNI_CFG_DOT11_MODE_11AC == dot11mode ||
236 WNI_CFG_DOT11_MODE_11AC_ONLY == dot11mode))
237 dot11mode = WNI_CFG_DOT11_MODE_11N;
238 /*
239 * session context may or may not be present, when probe request needs
240 * to be sent out. Following cases exist:
241 * --heartbeat failure: session needed
242 * --join req: session needed
243 * --foreground scan: no session
244 * --background scan: no session
245 * --sch_beacon_processing: to get EDCA parameters: session needed
246 * If session context does not exist, some IEs will be populated from
247 * CFGs, e.g. Supported and Extended rate set IEs
248 */
249 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
250
251 if (pesession != NULL)
252 sme_sessionid = pesession->smeSessionId;
253
254 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
255 /* and then hand it off to 'dot11f_pack_probe_request' (for */
256 /* serialization). We start by zero-initializing the structure: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258
259 /* & delegating to assorted helpers: */
260 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
261
262 if (addn_ielen && additional_ie)
263 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
264
265 /*
266 * Don't include 11b rate if it is a P2P serach or probe request is
267 * sent by P2P Client
268 */
269 if ((WNI_CFG_DOT11_MODE_11B != dot11mode) && (p2pie != NULL) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530270 ((pesession != NULL) &&
271 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 /*
273 * In the below API pass channel number > 14, do that it fills
274 * only 11a rates in supported rates
275 */
276 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
277 pesession);
278 } else {
279 populate_dot11f_supp_rates(mac_ctx, channel,
280 &pr.SuppRates, pesession);
281
282 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
283 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
284 &pr.ExtSuppRates);
285 }
286 }
287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 /*
289 * Table 7-14 in IEEE Std. 802.11k-2008 says
290 * DS params "can" be present in RRM is disabled and "is" present if
291 * RRM is enabled. It should be ok even if we add it into probe req when
292 * RRM is not enabled.
293 */
294 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
295 /* Call RRM module to get the tx power for management used. */
296 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
297 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299
300 if (pesession != NULL) {
301 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
302 /* Include HT Capability IE */
303 if (pesession->htCapability)
304 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
305 } else { /* pesession == NULL */
306 if (IS_DOT11_MODE_HT(dot11mode))
307 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
308 }
309
310 /*
311 * Set channelbonding information as "disabled" when tunned to a
312 * 2.4 GHz channel
313 */
314 if (channel <= SIR_11B_CHANNEL_END) {
315 if (mac_ctx->roam.configParam.channelBondingMode24GHz
316 == PHY_SINGLE_CHANNEL_CENTERED) {
317 pr.HTCaps.supportedChannelWidthSet =
318 eHT_CHANNEL_WIDTH_20MHZ;
319 pr.HTCaps.shortGI40MHz = 0;
320 } else {
321 pr.HTCaps.supportedChannelWidthSet =
322 eHT_CHANNEL_WIDTH_40MHZ;
323 }
324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 if (pesession != NULL) {
326 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
327 /* Include VHT Capability IE */
328 if (pesession->vhtCapability) {
329 populate_dot11f_vht_caps(mac_ctx, pesession,
330 &pr.VHTCaps);
331 is_vht_enabled = true;
332 }
333 } else {
334 if (IS_DOT11_MODE_VHT(dot11mode)) {
335 populate_dot11f_vht_caps(mac_ctx, pesession,
336 &pr.VHTCaps);
337 is_vht_enabled = true;
338 }
339 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 if (pesession != NULL)
341 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
342 pesession);
343
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800344 if (IS_DOT11_MODE_HE(dot11mode) && NULL != pesession)
345 lim_update_session_he_capable(mac_ctx, pesession);
346
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700347 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700348 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800349
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700350 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530351 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
352 sizeof(tDot11fIEExtCap));
353 sir_status = lim_strip_extcap_update_struct(mac_ctx,
354 additional_ie,
355 &addn_ielen,
356 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700357 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700358 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530359 } else {
360 struct s_ext_cap *p_ext_cap =
361 (struct s_ext_cap *)
362 extracted_ext_cap.bytes;
363 if (p_ext_cap->interworking_service)
364 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 extracted_ext_cap.num_bytes =
366 lim_compute_ext_cap_ie_length
367 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530368 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800369 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700370 if (additional_ielen)
371 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530372 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530373 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
374 SIR_MAC_QCN_OUI_TYPE_SIZE,
375 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530377 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Wu Gao93816212018-08-31 16:49:54 +0800378 if (mac_ctx->mlme_cfg->sta.qcn_ie_support && !qcn_ie)
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530379 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380
Hu Wang411e0cc2016-10-28 14:56:01 +0800381 /*
382 * Extcap IE now support variable length, merge Extcap IE from addn_ie
383 * may change the frame size. Therefore, MUST merge ExtCap IE before
384 * dot11f get packed payload size.
385 */
386 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800387 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800388
389 /* That's it-- now we pack it. First, how much space are we going to */
390 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
391 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700392 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800393 status);
394 /* We'll fall back on the worst case scenario: */
395 payload = sizeof(tDot11fProbeRequest);
396 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800398 status);
399 }
400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
402
403 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530404 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530406 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700407 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700408 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 }
410 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530411 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412
413 /* Next, we fill out the buffer descriptor: */
414 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
415 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
416
417 /* That done, pack the Probe Request: */
418 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
419 sizeof(tSirMacMgmtHdr),
420 payload, &payload);
421 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700422 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700424 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428 /* Append any AddIE if present. */
429 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530430 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 additional_ie, addn_ielen);
432 payload += addn_ielen;
433 }
434
435 /* If this probe request is sent during P2P Search State, then we need
436 * to send it at OFDM rate.
437 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530438 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /*
440 * For unicast probe req mgmt from Join function we don't set
441 * above variables. So we need to add one more check whether it
442 * is pePersona is P2P_CLIENT or not
443 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530444 ((pesession != NULL) &&
445 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
447 }
448
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530449 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 wma_tx_frame(mac_ctx, packet,
451 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
452 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
453 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700454 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530455 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700456 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700458 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 }
460
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700461 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462} /* End lim_send_probe_req_mgmt_frame. */
463
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464static QDF_STATUS lim_get_addn_ie_for_probe_resp(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 uint8_t *addIE, uint16_t *addnIELen,
466 uint8_t probeReqP2pIe)
467{
468 /* If Probe request doesn't have P2P IE, then take out P2P IE
469 from additional IE */
470 if (!probeReqP2pIe) {
471 uint8_t *tempbuf = NULL;
472 uint16_t tempLen = 0;
473 int left = *addnIELen;
474 uint8_t *ptr = addIE;
475 uint8_t elem_id, elem_len;
476
477 if (NULL == addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700478 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700479 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
481
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530482 tempbuf = qdf_mem_malloc(left);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 if (NULL == tempbuf) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700484 pe_err("Unable to allocate memory to store addn IE");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700485 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 }
487
488 while (left >= 2) {
489 elem_id = ptr[0];
490 elem_len = ptr[1];
491 left -= 2;
492 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700493 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700496 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 }
498 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
499 (memcmp
500 (&ptr[2], SIR_MAC_P2P_OUI,
501 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 elem_len + 2);
504 tempLen += (elem_len + 2);
505 }
506 left -= elem_len;
507 ptr += (elem_len + 2);
508 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530511 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700513 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514}
515
516/**
517 * lim_send_probe_rsp_mgmt_frame() - Send probe response
518 *
519 * @mac_ctx: Handle for mac context
520 * @peer_macaddr: Mac address of requesting peer
521 * @ssid: SSID for response
522 * @n_staid: Station ID, currently unused.
523 * @pe_session: PE session id
524 * @keepalive: Keep alive flag. Currently unused.
525 * @preq_p2pie: P2P IE in incoming probe request
526 *
527 * Builds and sends probe response frame to the requesting peer
528 *
529 * Return: void
530 */
531
532void
533lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
534 tSirMacAddr peer_macaddr,
535 tpAniSSID ssid,
536 short n_staid,
537 uint8_t keepalive,
538 tpPESession pe_session, uint8_t preq_p2pie)
539{
540 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700541 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800542 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 tpSirMacMgmtHdr mac_hdr;
544 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700545 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530546 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 uint32_t addn_ie_present = false;
548
549 uint16_t addn_ie_len = 0;
550 uint32_t wps_ap = 0, tmp;
551 uint8_t tx_flag = 0;
552 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700553 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 uint8_t noalen = 0;
555 uint8_t total_noalen = 0;
556 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
557 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
558 uint8_t sme_sessionid = 0;
559 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530560 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530561 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562
563 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700564 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 return;
566
567 if (NULL == pe_session)
568 return;
569
570 /*
571 * In case when cac timer is running for this SAP session then
572 * avoid sending probe rsp out. It is violation of dfs specification.
573 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530574 if (((pe_session->pePersona == QDF_SAP_MODE) ||
575 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530577 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 FL("CAC timer is running, probe response dropped"));
579 return;
580 }
581 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530582 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700584 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 return;
586 }
587
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 /*
589 * Fill out 'frm', after which we'll just hand the struct off to
590 * 'dot11f_pack_probe_response'.
591 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593
594 /*
595 * Timestamp to be updated by TFP, below.
596 *
597 * Beacon Interval:
598 */
599 if (LIM_IS_AP_ROLE(pe_session)) {
600 frm->BeaconInterval.interval =
601 mac_ctx->sch.schObject.gSchBeaconInterval;
602 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530603 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 frm->BeaconInterval.interval = (uint16_t) cfg;
605 }
606
607 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
608 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
609 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
610 &frm->SuppRates, pe_session);
611
612 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
613 pe_session->currentOperChannel);
614 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
615
616 if (LIM_IS_AP_ROLE(pe_session)) {
617 if (pe_session->wps_state != SAP_WPS_DISABLED)
618 populate_dot11f_probe_res_wpsi_es(mac_ctx,
619 &frm->WscProbeRes,
620 pe_session);
621 } else {
622 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700623 &tmp) != QDF_STATUS_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700624 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
626 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
627
628 if (wps_ap)
629 populate_dot11f_wsc_in_probe_res(mac_ctx,
630 &frm->WscProbeRes);
631
632 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
633 eLIM_WSC_ENROLL_BEGIN) {
634 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
635 &frm->WscProbeRes);
636 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
637 eLIM_WSC_ENROLL_IN_PROGRESS;
638 }
639
640 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
641 eLIM_WSC_ENROLL_END) {
642 de_populate_dot11f_wsc_registrar_info_in_probe_res(
643 mac_ctx, &frm->WscProbeRes);
644 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
645 eLIM_WSC_ENROLL_NOOP;
646 }
647 }
648
649 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
650 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
651
652 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
653 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
654
655 populate_dot11f_ext_supp_rates(mac_ctx,
656 POPULATE_DOT11F_RATES_OPERATIONAL,
657 &frm->ExtSuppRates, pe_session);
658
659 /* Populate HT IEs, when operating in 11n */
660 if (pe_session->htCapability) {
661 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
662 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
663 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700665 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
667 populate_dot11f_vht_operation(mac_ctx, pe_session,
668 &frm->VHTOperation);
669 /*
670 * we do not support multi users yet.
671 * populate_dot11f_vht_ext_bss_load( mac_ctx,
672 * &frm.VHTExtBssLoad );
673 */
674 is_vht_enabled = true;
675 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800677 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700678 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800679 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700680 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800681 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700682 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800683 }
684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
686 pe_session);
687
688 if (pe_session->pLimStartBssReq) {
689 populate_dot11f_wpa(mac_ctx,
690 &(pe_session->pLimStartBssReq->rsnIE),
691 &frm->WPA);
692 populate_dot11f_rsn_opaque(mac_ctx,
693 &(pe_session->pLimStartBssReq->rsnIE),
694 &frm->RSNOpaque);
695 }
696
697 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
698 &frm->WMMCaps, pe_session);
699
700#if defined(FEATURE_WLAN_WAPI)
701 if (pe_session->pLimStartBssReq)
702 populate_dot11f_wapi(mac_ctx,
703 &(pe_session->pLimStartBssReq->rsnIE),
704 &frm->WAPI);
705#endif /* defined(FEATURE_WLAN_WAPI) */
706
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 if (mac_ctx->lim.gpLimRemainOnChanReq)
708 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
709 sizeof(tSirRemainOnChnReq));
710 else
711 /*
712 * Only use CFG for non-listen mode. This CFG is not working for
713 * concurrency. In listening mode, probe rsp IEs is passed in
714 * the message from SME to PE.
715 */
716 addn_ie_present =
717 (pe_session->addIeParams.probeRespDataLen != 0);
718
719 if (addn_ie_present) {
720
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530721 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 pe_session->addIeParams.probeRespDataLen);
723 if (NULL == add_ie) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700724 pe_err("add_ie allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 goto err_ret;
726 }
727
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530728 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 pe_session->addIeParams.probeRespData_buff,
730 pe_session->addIeParams.probeRespDataLen);
731 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
732
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700733 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700735 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 goto err_ret;
737 }
738
739 sir_status = lim_strip_extcap_update_struct(mac_ctx,
740 add_ie, &addn_ie_len,
741 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700742 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700743 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530744 } else {
745 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 }
747
748 bytes = bytes + addn_ie_len;
749
750 if (preq_p2pie)
751 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
752 addn_ie_len);
753
754 if (p2p_ie != NULL) {
755 /* get NoA attribute stream P2P IE */
756 noalen = lim_get_noa_attr_stream(mac_ctx,
757 noa_stream, pe_session);
758 if (noalen != 0) {
759 total_noalen =
760 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
761 &noa_stream[0], noalen);
762 bytes = bytes + total_noalen;
763 }
764 }
765 }
766
Hu Wang411e0cc2016-10-28 14:56:01 +0800767 /*
768 * Extcap IE now support variable length, merge Extcap IE from addn_ie
769 * may change the frame size. Therefore, MUST merge ExtCap IE before
770 * dot11f get packed payload size.
771 */
772 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800773 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
774 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800775
776 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
777 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700778 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800779 status);
780 /* We'll fall back on the worst case scenario: */
781 payload = sizeof(tDot11fProbeResponse);
782 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700783 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800784 status);
785 }
786
787 bytes += payload + sizeof(tSirMacMgmtHdr);
788
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530789 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530791 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700792 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 goto err_ret;
794 }
795 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530796 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797
798 /* Next, we fill out the buffer descriptor: */
799 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
800 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
801 pe_session->selfMacAddr);
802
803 mac_hdr = (tpSirMacMgmtHdr) frame;
804
805 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 /* That done, pack the Probe Response: */
808 status =
809 dot11f_pack_probe_response(mac_ctx, frm,
810 frame + sizeof(tSirMacMgmtHdr),
811 payload, &payload);
812 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700813 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 status);
815 goto err_ret;
816 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700817 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 }
819
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700820 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530821 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
826 (mac_ctx->lim.gpLimRemainOnChanReq->length -
827 sizeof(tSirRemainOnChnReq)));
828
829 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 &add_ie[0], addn_ie_len);
832
833 if (noalen != 0) {
834 if (total_noalen >
835 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700836 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 total_noalen);
838 goto err_ret;
839 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530840 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &noa_ie[0], total_noalen);
842 }
843 }
844
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800845 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530846 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
847 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 )
849 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
850
851 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530852 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 (uint16_t) bytes,
854 TXRX_FRM_802_11_MGMT,
855 ANI_TXDIR_TODS,
856 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700857 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
859 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530860 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700861 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862
863 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530864 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530866 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 return;
868
869err_ret:
870 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530871 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530873 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 if (packet != NULL)
875 cds_packet_free((void *)packet);
876 return;
877
878} /* End lim_send_probe_rsp_mgmt_frame. */
879
880void
881lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
882 tSirMacAddr peerMacAddr,
883 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
884{
885 uint16_t i;
886 uint8_t *pFrame;
887 tDot11fAddTSRequest AddTSReq;
888 tDot11fWMMAddTSRequest WMMAddTSReq;
889 uint32_t nPayload, nBytes, nStatus;
890 tpSirMacMgmtHdr pMacHdr;
891 void *pPacket;
892#ifdef FEATURE_WLAN_ESE
893 uint32_t phyMode;
894#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530895 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 uint8_t txFlag = 0;
897 uint8_t smeSessionId = 0;
898
899 if (NULL == psessionEntry) {
900 return;
901 }
902
903 smeSessionId = psessionEntry->smeSessionId;
904
905 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530906 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907
908 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
909 AddTSReq.DialogToken.token = pAddTS->dialogToken;
910 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
911 if (pAddTS->lleTspecPresent) {
912 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
913 } else {
914 populate_dot11f_wmmtspec(&pAddTS->tspec,
915 &AddTSReq.WMMTSPEC);
916 }
917
918 if (pAddTS->lleTspecPresent) {
919 AddTSReq.num_WMMTCLAS = 0;
920 AddTSReq.num_TCLAS = pAddTS->numTclas;
921 for (i = 0; i < pAddTS->numTclas; ++i) {
922 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
923 &AddTSReq.TCLAS[i]);
924 }
925 } else {
926 AddTSReq.num_TCLAS = 0;
927 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
928 for (i = 0; i < pAddTS->numTclas; ++i) {
929 populate_dot11f_wmmtclas(pMac,
930 &pAddTS->tclasInfo[i],
931 &AddTSReq.WMMTCLAS[i]);
932 }
933 }
934
935 if (pAddTS->tclasProcPresent) {
936 if (pAddTS->lleTspecPresent) {
937 AddTSReq.TCLASSPROC.processing =
938 pAddTS->tclasProc;
939 AddTSReq.TCLASSPROC.present = 1;
940 } else {
941 AddTSReq.WMMTCLASPROC.version = 1;
942 AddTSReq.WMMTCLASPROC.processing =
943 pAddTS->tclasProc;
944 AddTSReq.WMMTCLASPROC.present = 1;
945 }
946 }
947
948 nStatus =
949 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
950 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700951 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
952 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 /* We'll fall back on the worst case scenario: */
954 nPayload = sizeof(tDot11fAddTSRequest);
955 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700956 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
957 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 }
959 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961
962 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
963 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
964 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
965
966 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
967 WMMAddTSReq.StatusCode.statusCode = 0;
968
969 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
970#ifdef FEATURE_WLAN_ESE
971 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
972
973 if (phyMode == WNI_CFG_PHY_MODE_11G
974 || phyMode == WNI_CFG_PHY_MODE_11A) {
975 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
976 } else {
977 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
978 }
979 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
980 &WMMAddTSReq.ESETrafStrmRateSet,
981 sizeof(uint8_t));
982#endif
983 /* fillWmeTspecIE */
984
985 nStatus =
986 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
987 &nPayload);
988 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700989 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 nStatus);
991 /* We'll fall back on the worst case scenario: */
992 nPayload = sizeof(tDot11fAddTSRequest);
993 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700994 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
995 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 }
997 }
998
999 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1000
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301001 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301003 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001004 pe_err("Failed to allocate %d bytes for an Add TS Request",
1005 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 return;
1007 }
1008 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
1011 /* Next, we fill out the buffer descriptor: */
1012 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1013 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1014 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1015
1016 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1017
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019
1020 /* That done, pack the struct: */
1021 if (!pAddTS->wmeTspecPresent) {
1022 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1023 pFrame +
1024 sizeof(tSirMacMgmtHdr),
1025 nPayload, &nPayload);
1026 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001027 pe_err("Failed to pack an Add TS Request "
1028 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 cds_packet_free((void *)pPacket);
1030 return; /* allocated! */
1031 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001032 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1033 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 }
1035 } else {
1036 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1037 pFrame +
1038 sizeof(tSirMacMgmtHdr),
1039 nPayload, &nPayload);
1040 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001041 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1042 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 cds_packet_free((void *)pPacket);
1044 return; /* allocated! */
1045 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001046 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1047 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 }
1049 }
1050
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001051 pe_debug("Sending an Add TS Request frame to");
1052 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001054 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301056 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1057 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 ) {
1059 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1060 }
1061
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301062 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001064 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001065 psessionEntry, QDF_STATUS_SUCCESS,
1066 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
1068 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301069 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 TXRX_FRM_802_11_MGMT,
1071 ANI_TXDIR_TODS,
1072 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001073 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301074 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301075 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001077 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1078 pe_err("Could not send an Add TS Request (%X",
1079 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080} /* End lim_send_addts_req_action_frame. */
1081
1082/**
1083 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1084 * @mac_ctx: Handle for mac context
1085 * @status_code: Status code for assoc response frame
1086 * @aid: Association ID
1087 * @peer_addr: Mac address of requesting peer
1088 * @subtype: Assoc/Reassoc
1089 * @sta: Pointer to station node
1090 * @pe_session: PE session id.
1091 *
1092 * Builds and sends association response frame to the requesting peer.
1093 *
1094 * Return: void
1095 */
1096
1097void
1098lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1099 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1100 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1101{
1102 static tDot11fAssocResponse frm;
1103 uint8_t *frame;
1104 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001105 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 uint8_t lle_mode = 0, addts;
1107 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001108 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301110 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 tUpdateBeaconParams beacon_params;
1112 uint8_t tx_flag = 0;
1113 uint32_t addn_ie_len = 0;
1114 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1115 tpSirAssocReq assoc_req = NULL;
1116 uint8_t sme_session = 0;
1117 bool is_vht = false;
1118 uint16_t stripoff_len = 0;
1119 tDot11fIEExtCap extracted_ext_cap;
1120 bool extracted_flag = false;
1121#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301122 uint8_t retry_int;
1123 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124#endif
1125
1126 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001127 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 return;
1129 }
1130
1131 sme_session = pe_session->smeSessionId;
1132
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301133 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
1135 limGetQosMode(pe_session, &qos_mode);
1136 limGetWmeMode(pe_session, &wme_mode);
1137
1138 /*
1139 * An Add TS IE is added only if the AP supports it and
1140 * the requesting STA sent a traffic spec.
1141 */
1142 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1143
1144 frm.Status.status = status_code;
1145
1146 frm.AID.associd = aid | LIM_AID_MASK;
1147
1148 if (NULL == sta) {
1149 populate_dot11f_supp_rates(mac_ctx,
1150 POPULATE_DOT11F_RATES_OPERATIONAL,
1151 &frm.SuppRates, pe_session);
1152 populate_dot11f_ext_supp_rates(mac_ctx,
1153 POPULATE_DOT11F_RATES_OPERATIONAL,
1154 &frm.ExtSuppRates, pe_session);
1155 } else {
1156 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1157 &frm.ExtSuppRates,
1158 sta->supportedRates.llbRates,
1159 sta->supportedRates.llaRates);
1160 }
1161
1162 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001163 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 assoc_req = (tpSirAssocReq)
1165 pe_session->parsedAssocReq[sta->assocId];
1166 /*
1167 * populate P2P IE in AssocRsp when assocReq from the peer
1168 * includes P2P IE
1169 */
1170 if (assoc_req != NULL && assoc_req->addIEPresent)
1171 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1172 &frm.P2PAssocRes,
1173 assoc_req);
1174 }
1175
1176 if (NULL != sta) {
1177 if (eHAL_SET == qos_mode) {
1178 if (sta->lleEnabled) {
1179 lle_mode = 1;
1180 populate_dot11f_edca_param_set(mac_ctx,
1181 &frm.EDCAParamSet, pe_session);
1182 }
1183 }
1184
1185 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1186 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1187 pe_session);
1188
1189 if (sta->wsmEnabled)
1190 populate_dot11f_wmm_caps(&frm.WMMCaps);
1191 }
1192
1193 if (sta->mlmStaContext.htCapability &&
1194 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001195 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 populate_dot11f_ht_caps(mac_ctx, pe_session,
1197 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001198 /*
1199 * Check the STA capability and
1200 * update the HTCaps accordingly
1201 */
1202 frm.HTCaps.supportedChannelWidthSet = (
1203 sta->htSupportedChannelWidthSet <
1204 pe_session->htSupportedChannelWidthSet) ?
1205 sta->htSupportedChannelWidthSet :
1206 pe_session->htSupportedChannelWidthSet;
1207 if (!frm.HTCaps.supportedChannelWidthSet)
1208 frm.HTCaps.shortGI40MHz = 0;
1209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1211 pe_session);
1212 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001213 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 +05301214 frm.HTCaps.supportedChannelWidthSet,
1215 frm.HTCaps.mimoPowerSave,
1216 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1217 frm.HTCaps.shortGI40MHz,
1218 frm.HTCaps.dsssCckMode40MHz,
1219 frm.HTCaps.maxRxAMPDUFactor);
1220
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 if (sta->mlmStaContext.vhtCapability &&
1222 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001223 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 populate_dot11f_vht_caps(mac_ctx, pe_session,
1225 &frm.VHTCaps);
1226 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301227 &frm.VHTOperation);
1228 is_vht = true;
1229 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001230
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301231 if (pe_session->vhtCapability &&
1232 pe_session->vendor_vht_sap &&
1233 (assoc_req != NULL) &&
1234 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001235 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301236 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001237 frm.vendor_vht_ie.sub_type =
1238 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301239 frm.vendor_vht_ie.VHTCaps.present = 1;
1240 populate_dot11f_vht_caps(mac_ctx, pe_session,
1241 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001242 populate_dot11f_vht_operation(mac_ctx, pe_session,
1243 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 is_vht = true;
1245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1247 pe_session);
1248
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001249 if (lim_is_sta_he_capable(sta) &&
1250 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001251 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001252 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001253 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001254 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001255 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001256 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257#ifdef WLAN_FEATURE_11W
1258 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301259 max_retries =
1260 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1261 retry_int =
1262 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1263 populate_dot11f_timeout_interval(mac_ctx,
1264 &frm.TimeoutInterval,
1265 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1266 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 sta->pmfSaQueryRetryCount)
1268 * retry_int);
1269 }
1270#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001271
1272 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1273 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 }
1275
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301276 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277
1278 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301279 (pe_session->gLimProtectionControl !=
1280 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1281 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1282 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283
1284 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1285 pe_session);
1286 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1287 pe_session);
1288
1289 /*
1290 * Populate Do11capabilities after updating session with
1291 * Assos req details
1292 */
1293 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1294
1295 beacon_params.bssIdx = pe_session->bssIdx;
1296
1297 /* Send message to HAL about beacon parameter change. */
1298 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1299 && beacon_params.paramChangeBitmap) {
1300 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1301 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303
Arif Hussain1513cb22018-01-05 19:56:31 -08001304 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001307 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308
1309 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001310 if (addn_ie_len > 0 &&
1311 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1312 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301313 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 pe_session->addIeParams.assocRespData_buff,
1315 pe_session->addIeParams.assocRespDataLen);
1316
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301317 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 sizeof(extracted_ext_cap), 0);
1319
1320 stripoff_len = addn_ie_len;
1321 sir_status =
1322 lim_strip_extcap_update_struct
1323 (mac_ctx, &add_ie[0], &stripoff_len,
1324 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001325 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001326 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 } else {
1328 addn_ie_len = stripoff_len;
1329 extracted_flag = true;
1330 }
1331 bytes = bytes + addn_ie_len;
1332 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001333 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 addn_ie_len, assoc_req->addIEPresent);
1335 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001336
1337 /*
1338 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1339 * may change the frame size. Therefore, MUST merge ExtCap IE before
1340 * dot11f get packed payload size.
1341 */
1342 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001343 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1344 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001345
1346 /* Allocate a buffer for this frame: */
1347 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1348 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001349 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001350 status);
1351 return;
1352 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001353 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001354 status);
1355 }
1356
1357 bytes += sizeof(tSirMacMgmtHdr) + payload;
1358
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301359 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301361 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001362 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 return;
1364 }
1365 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301366 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367
1368 /* Next, we fill out the buffer descriptor: */
1369 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1370 (LIM_ASSOC == subtype) ?
1371 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1372 peer_addr,
1373 pe_session->selfMacAddr);
1374 mac_hdr = (tpSirMacMgmtHdr) frame;
1375
1376 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1377
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1379 frame + sizeof(tSirMacMgmtHdr),
1380 payload, &payload);
1381 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001382 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 status);
1384 cds_packet_free((void *)packet);
1385 return;
1386 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001387 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 status);
1389 }
1390
1391 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001392 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 status_code, aid);
1394 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001395 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 status_code, aid);
1397
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301398 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399
1400 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301401 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 &add_ie[0], addn_ie_len);
1403
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001404 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301406 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1407 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1409
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301410 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001412 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001413 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301415 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 TXRX_FRM_802_11_MGMT,
1417 ANI_TXDIR_TODS,
1418 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001419 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301420 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422
1423 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301424 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001425 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301426 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427
1428 /*
1429 * update the ANI peer station count.
1430 * FIXME_PROTECTION : take care of different type of station
1431 * counter inside this function.
1432 */
1433 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1434
1435}
1436
1437void
1438lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1439 tSirMacAddr peer,
1440 uint8_t wmmTspecPresent,
1441 tSirMacTSInfo *pTsinfo,
1442 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1443{
1444 uint8_t *pFrame;
1445 tpSirMacMgmtHdr pMacHdr;
1446 tDot11fDelTS DelTS;
1447 tDot11fWMMDelTS WMMDelTS;
1448 uint32_t nBytes, nPayload, nStatus;
1449 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301450 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 uint8_t txFlag = 0;
1452 uint8_t smeSessionId = 0;
1453
1454 if (NULL == psessionEntry) {
1455 return;
1456 }
1457
1458 smeSessionId = psessionEntry->smeSessionId;
1459
1460 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301461 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462
1463 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1464 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1465 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1466
1467 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1468 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001469 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 /* We'll fall back on the worst case scenario: */
1471 nPayload = sizeof(tDot11fDelTS);
1472 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001473 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1474 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 }
1476 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301477 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478
1479 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1480 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1481 WMMDelTS.DialogToken.token = 0;
1482 WMMDelTS.StatusCode.statusCode = 0;
1483 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1484 nStatus =
1485 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1486 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_err("Failed to calculate the packed size for a WMM 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 WMM Del TS (0x%08x)",
1492 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 }
1494 }
1495
1496 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1497
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301498 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1500 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301501 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001502 pe_err("Failed to allocate %d bytes for an Add TS Response",
1503 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 return;
1505 }
1506 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301507 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508
1509 /* Next, we fill out the buffer descriptor: */
1510 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1511 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1512 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1513
1514 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517
1518 /* That done, pack the struct: */
1519 if (!wmmTspecPresent) {
1520 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1521 pFrame + sizeof(tSirMacMgmtHdr),
1522 nPayload, &nPayload);
1523 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001524 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 nStatus);
1526 cds_packet_free((void *)pPacket);
1527 return; /* allocated! */
1528 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001529 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1530 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 }
1532 } else {
1533 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1534 pFrame + sizeof(tSirMacMgmtHdr),
1535 nPayload, &nPayload);
1536 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001537 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 nStatus);
1539 cds_packet_free((void *)pPacket);
1540 return; /* allocated! */
1541 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001542 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1543 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 }
1545 }
1546
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001547 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1548 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001550 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301552 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1553 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 ) {
1555 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1556 }
1557
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301558 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001560 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001561 psessionEntry, QDF_STATUS_SUCCESS,
1562 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301563 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 TXRX_FRM_802_11_MGMT,
1565 ANI_TXDIR_TODS,
1566 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001567 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301568 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301569 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301571 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001572 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573
1574} /* End lim_send_delts_req_action_frame. */
1575
1576/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301577 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1578 * @context: pointer to global mac
1579 * @buf: buffer
1580 * @tx_complete : Sent status
1581 * @params; tx completion params
1582 *
1583 * Return: This returns QDF_STATUS
1584 */
1585
1586static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1587 qdf_nbuf_t buf,
1588 uint32_t tx_complete,
1589 void *params)
1590{
1591 uint16_t assoc_ack_status;
1592 uint16_t reason_code;
1593 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1594
1595 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001596 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301597 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001598 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301599 } else {
1600 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001601 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301602 }
1603 if (buf)
1604 qdf_nbuf_free(buf);
1605
1606 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1607 NULL, assoc_ack_status, reason_code);
1608 return QDF_STATUS_SUCCESS;
1609}
1610
1611/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 * lim_send_assoc_req_mgmt_frame() - Send association request
1613 * @mac_ctx: Handle to MAC context
1614 * @mlm_assoc_req: Association request information
1615 * @pe_session: PE session information
1616 *
1617 * Builds and transmits association request frame to AP.
1618 *
1619 * Return: Void
1620 */
1621
1622void
1623lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1624 tLimMlmAssocReq *mlm_assoc_req,
1625 tpPESession pe_session)
1626{
Naveen Rawat72475db2017-12-13 18:07:35 -08001627 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 tDot11fAssocRequest *frm;
1629 uint16_t caps;
1630 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001631 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001633 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1635 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301636 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 uint16_t add_ie_len;
1638 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001639 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 uint8_t tx_flag = 0;
1642 uint8_t sme_sessionid = 0;
1643 bool vht_enabled = false;
1644 tDot11fIEExtCap extr_ext_cap;
1645 bool extr_ext_flag = true;
1646 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001647 uint32_t ie_offset = 0;
1648 uint8_t *p_ext_cap = NULL;
1649 tDot11fIEExtCap bcn_ext_cap;
1650 uint8_t *bcn_ie = NULL;
1651 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301652 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001653 enum rateid min_rid = RATEID_DEFAULT;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301654 uint8_t *mbo_ie = NULL;
1655 uint8_t mbo_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656
1657 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001658 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301659 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 return;
1661 }
1662
1663 sme_sessionid = pe_session->smeSessionId;
1664
1665 /* check this early to avoid unncessary operation */
1666 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001667 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301668 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 return;
1670 }
1671 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1672 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1673
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301674 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 if (NULL == frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001676 pe_err("Unable to allocate memory");
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 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001680 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301682 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301683 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 0);
1685 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1686 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001687 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001689 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 } else {
1691 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1692 extr_ext_cap.bytes;
1693
1694 if (p_ext_cap->interworking_service)
1695 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001696 extr_ext_cap.num_bytes =
1697 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1698 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 }
1700 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001701 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 extr_ext_flag = false;
1703 }
1704
1705 caps = mlm_assoc_req->capabilityInfo;
1706#if defined(FEATURE_WLAN_WAPI)
1707 /*
1708 * According to WAPI standard:
1709 * 7.3.1.4 Capability Information field
1710 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1711 * in transmitted Association or Reassociation management frames.
1712 * APs ignore the Privacy subfield within received Association and
1713 * Reassociation management frames.
1714 */
1715 if (pe_session->encryptType == eSIR_ED_WPI)
1716 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1717#endif
1718 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1719
1720 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1721 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1722 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1723 &frm->SuppRates, pe_session);
1724
1725 qos_enabled = (pe_session->limQosEnabled) &&
1726 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1727
1728 wme_enabled = (pe_session->limWmeEnabled) &&
1729 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1730
1731 /* We prefer .11e asociations: */
1732 if (qos_enabled)
1733 wme_enabled = false;
1734
1735 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1736 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1737
1738 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001739 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 power_caps = true;
1741
1742 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1743 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1745 LIM_ASSOC, pe_session);
1746
1747 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1749 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1750 if (power_caps == false) {
1751 power_caps = true;
1752 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1753 LIM_ASSOC, pe_session);
1754 }
1755 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001757 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1758 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759
1760 populate_dot11f_ext_supp_rates(mac_ctx,
1761 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1762 pe_session);
1763
Gupta, Kapil54a16992016-01-13 19:34:02 +05301764 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1765 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1767 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 /*
1770 * The join request *should* contain zero or one of the WPA and RSN
1771 * IEs. The payload send along with the request is a
1772 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1773 * typedef struct sSirRSNie
1774 * {
1775 * uint16_t length;
1776 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1777 * } tSirRSNie, *tpSirRSNie;
1778 * So, we should be able to make the following two calls harmlessly,
1779 * since they do nothing if they don't find the given IE in the
1780 * bytestream with which they're provided.
1781 * The net effect of this will be to faithfully transmit whatever
1782 * security IE is in the join request.
1783 * However, if we're associating for the purpose of WPS
1784 * enrollment, and we've been configured to indicate that by
1785 * eliding the WPA or RSN IE, we just skip this:
1786 */
1787 if (add_ie_len && add_ie)
1788 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1789
1790 if (NULL == wps_ie) {
1791 populate_dot11f_rsn_opaque(mac_ctx,
1792 &(pe_session->pLimJoinReq->rsnIE),
1793 &frm->RSNOpaque);
1794 populate_dot11f_wpa_opaque(mac_ctx,
1795 &(pe_session->pLimJoinReq->rsnIE),
1796 &frm->WPAOpaque);
1797#if defined(FEATURE_WLAN_WAPI)
1798 populate_dot11f_wapi_opaque(mac_ctx,
1799 &(pe_session->pLimJoinReq->rsnIE),
1800 &frm->WAPIOpaque);
1801#endif /* defined(FEATURE_WLAN_WAPI) */
1802 }
1803 /* include WME EDCA IE as well */
1804 if (wme_enabled) {
1805 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1806 pe_session, &frm->WMMInfoStation);
1807
1808 if (wsm_enabled)
1809 populate_dot11f_wmm_caps(&frm->WMMCaps);
1810 }
1811
1812 /*
1813 * Populate HT IEs, when operating in 11n and
1814 * when AP is also operating in 11n mode
1815 */
1816 if (pe_session->htCapability &&
1817 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001818 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001820 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1821 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001822 } else if (pe_session->he_with_wep_tkip) {
1823 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1824 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001826 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 +05301827 frm->HTCaps.supportedChannelWidthSet,
1828 frm->HTCaps.mimoPowerSave,
1829 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1830 frm->HTCaps.shortGI40MHz,
1831 frm->HTCaps.dsssCckMode40MHz,
1832 frm->HTCaps.maxRxAMPDUFactor);
1833
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 if (pe_session->vhtCapability &&
1835 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001836 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001838 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1839 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001841 if (pe_session->enableHtSmps &&
1842 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001843 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001844 populate_dot11f_operating_mode(mac_ctx,
1845 &frm->OperatingMode, pe_session);
1846 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001847 } else if (pe_session->he_with_wep_tkip) {
1848 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1849 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 if (!vht_enabled &&
1853 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001854 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301855 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001856 frm->vendor_vht_ie.sub_type =
1857 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301858 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301859 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301860 pe_session->vht_config.su_beam_formee) {
1861 pe_debug("Disable SU beamformee for vendor IE");
1862 pe_session->vht_config.su_beam_formee = 0;
1863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301865 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 vht_enabled = true;
1867 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301868 if (pe_session->is_ext_caps_present)
1869 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1870 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871
Wu Gao93816212018-08-31 16:49:54 +08001872 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301873 populate_dot11f_qcn_ie(&frm->QCN_IE);
1874
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001875 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001876 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001877 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001878 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001879 } else if (pe_session->he_with_wep_tkip) {
1880 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1881 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001882 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 tSirBssDescription *bssdescr;
1886
1887 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001888 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 (unsigned int) bssdescr->mdie[0],
1890 (unsigned int) bssdescr->mdie[1],
1891 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 populate_mdie(mac_ctx, &frm->MobilityDomain,
1893 pe_session->pLimJoinReq->bssDescription.mdie);
1894 } else {
1895 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001896 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898
1899#ifdef FEATURE_WLAN_ESE
1900 /*
1901 * ESE Version IE will be included in association request
1902 * when ESE is enabled on DUT through ini and it is also
1903 * advertised by the peer AP to which we are trying to
1904 * associate to.
1905 */
1906 if (pe_session->is_ese_version_ie_present &&
1907 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1908 populate_dot11f_ese_version(&frm->ESEVersion);
1909 /* For ESE Associations fill the ESE IEs */
1910 if (pe_session->isESEconnection &&
1911 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1912#ifndef FEATURE_DISABLE_RM
1913 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1914#endif
1915 }
1916#endif
1917
Hu Wang411e0cc2016-10-28 14:56:01 +08001918 /*
1919 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1920 * may change the frame size. Therefore, MUST merge ExtCap IE before
1921 * dot11f get packed payload size.
1922 */
1923 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001924 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1925
1926 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1927 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1928 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1929 DOT11F_FF_BEACONINTERVAL_LEN +
1930 DOT11F_FF_CAPABILITIES_LEN;
1931
1932 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1933 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1934 bcn_ie = pe_session->beacon + ie_offset;
1935 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001936 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001937 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001938 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001939 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1940 &bcn_ext_cap);
1941 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1942 false);
1943 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001944 /*
1945 * TWT extended capabilities should be populated after the
1946 * intersection of beacon caps and self caps is done because
1947 * the bits for TWT are unique to STA and AP and cannot be
1948 * intersected.
1949 */
1950 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1951 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001952 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001953
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001954 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001955 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001956 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001957
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301958 if (lim_is_fils_connection(pe_session)) {
1959 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1960 aes_block_size_len = AES_BLOCK_SIZE;
1961 }
1962
1963 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301964 * MBO IE needs to be appendded at the end of the assoc request
1965 * frame and is not parsed and unpacked by the frame parser
1966 * as the supplicant can send multiple TLVs with same Attribute
1967 * in the MBO IE and the frame parser does not support multiple
1968 * TLVs with same attribute in a single IE.
1969 * Strip off the MBO IE from add_ie and append it at the end.
1970 */
1971 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
1972 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
1973 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
1974 if (!mbo_ie) {
1975 pe_err("Failed to allocate mbo_ie");
1976 goto end;
1977 }
1978
1979 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
1980 SIR_MAC_EID_VENDOR, ONE_BYTE,
1981 SIR_MAC_MBO_OUI,
1982 SIR_MAC_MBO_OUI_SIZE,
1983 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
1984 if (QDF_IS_STATUS_ERROR(qdf_status)) {
1985 pe_err("Failed to strip MBO IE");
1986 goto free_mbo_ie;
1987 }
1988
1989 /* Include the EID and length fields */
1990 mbo_ie_len = mbo_ie[1] + 2;
1991 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
1992 }
1993
1994 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301995 * Do unpack to populate the add_ie buffer to frm structure
1996 * before packing the frm structure. In this way, the IE ordering
1997 * which the latest 802.11 spec mandates is maintained.
1998 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001999 if (add_ie_len) {
2000 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302001 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002002 if (DOT11F_FAILED(ret)) {
2003 pe_err("unpack failed, ret: 0x%x", ret);
2004 goto end;
2005 }
2006 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2009 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002010 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 status);
2012 /* We'll fall back on the worst case scenario: */
2013 payload = sizeof(tDot11fAssocRequest);
2014 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002015 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 status);
2017 }
2018
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302019 bytes = payload + sizeof(tSirMacMgmtHdr) +
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302020 aes_block_size_len + mbo_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302022 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302024 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002025 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026
2027 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302028 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 pe_session->peSessionId,
2030 pe_session->limMlmState));
2031
2032 /* Update PE session id */
2033 assoc_cnf.sessionId = pe_session->peSessionId;
2034
2035 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2036
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2038 (uint32_t *) &assoc_cnf);
2039
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302040 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 }
2042 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302043 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044
2045 /* Next, we fill out the buffer descriptor: */
2046 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2047 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2048 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 /* That done, pack the Assoc Request: */
2050 status = dot11f_pack_assoc_request(mac_ctx, frm,
2051 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2052 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002053 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302055 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002057 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 }
2059
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302060 /* Copy the MBO IE to the end of the frame */
2061 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2062 mbo_ie, mbo_ie_len);
2063 payload = payload + mbo_ie_len;
2064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302066 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002068 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 }
2070
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302071 if (lim_is_fils_connection(pe_session)) {
2072 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2073 frame, &payload);
2074 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2075 cds_packet_free((void *)packet);
2076 qdf_mem_free(frm);
2077 return;
2078 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 }
2080
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302081 pe_session->assocReq = qdf_mem_malloc(payload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 if (NULL == pe_session->assocReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002083 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 } else {
2085 /*
2086 * Store the Assoc request. This is sent to csr/hdd in
2087 * join cnf response.
2088 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302089 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 frame + sizeof(tSirMacMgmtHdr), payload);
2091 pe_session->assocReqLen = payload;
2092 }
2093
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002094 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302095 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2096 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 )
2098 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2099
Anurag Chouhan6d760662016-02-20 16:05:43 +05302100 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2101 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302105 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302107
2108 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002109 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002110 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002111 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002112 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002113 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302114 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302115 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2117 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302118 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002119 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302120 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302121 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302122 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002123
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302124 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002125 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302127 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002128 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302131free_mbo_ie:
2132 if (mbo_ie)
2133 qdf_mem_free(mbo_ie);
2134
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302135end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302137 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302139 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 return;
2141}
2142
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002144 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2145 * @context: pointer to global mac
2146 * @buf: buffer which is nothing but entire ADD BA frame
2147 * @tx_complete : Sent status
2148 * @params; tx completion params
2149 *
2150 * Return: This returns QDF_STATUS
2151 */
2152static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2153 qdf_nbuf_t buf,
2154 uint32_t tx_complete,
2155 void *params)
2156{
2157 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2158 tSirMacMgmtHdr *mac_hdr;
2159 tDot11faddba_rsp rsp;
2160 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2161 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2162 uint8_t peer_id;
2163 void *peer;
2164 uint32_t frame_len;
2165 QDF_STATUS status;
2166 uint8_t *data;
2167
2168 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2169 pe_debug("Add ba response successfully sent");
2170 else
2171 pe_debug("Fail to send add ba response");
2172
2173 if (!buf) {
2174 pe_err("Addba response frame buffer is NULL");
2175 return QDF_STATUS_E_FAILURE;
2176 }
2177
2178 data = qdf_nbuf_data(buf);
2179
2180 if (!data) {
2181 pe_err("Addba response frame is NULL");
2182 return QDF_STATUS_E_FAILURE;
2183 }
2184
2185 mac_hdr = (tSirMacMgmtHdr *)data;
2186 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2187 frame_len = sizeof(rsp);
2188 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2189 sizeof(*mac_hdr), frame_len,
2190 &rsp, false);
2191
2192 if (DOT11F_FAILED(status)) {
2193 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2194 status, frame_len);
2195 goto error;
2196 }
2197
2198 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2199 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2200 if (!peer) {
2201 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2202 goto error;
2203 }
2204 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2205 tx_complete);
2206 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2207error:
2208 if (buf)
2209 qdf_nbuf_free(buf);
2210
2211 return QDF_STATUS_SUCCESS;
2212}
2213
2214/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302215 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302216 * @context: pointer to global mac
2217 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302218 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302219 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302220 *
2221 * Return: This returns QDF_STATUS
2222 */
2223
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302224static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2225 qdf_nbuf_t buf,
2226 uint32_t tx_complete,
2227 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302228{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302229 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302230 uint16_t auth_ack_status;
2231 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302232
Naveen Rawat684e8b12017-09-20 15:54:44 -07002233 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002234 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2235 "success" : "fail");
2236 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302237 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302238 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002239 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302240 /* 'Change' timer for future activations */
2241 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2242 } else {
2243 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302244 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002245 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302246 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302247
2248 if (buf)
2249 qdf_nbuf_free(buf);
2250
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302251 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2252 NULL, auth_ack_status, reason_code);
2253
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302254 return QDF_STATUS_SUCCESS;
2255}
2256
2257/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2259 *
2260 * @mac_ctx: Pointer to Global MAC structure
2261 * @auth_frame: Pointer to Authentication frame structure
2262 * @peer_addr: MAC address of destination peer
2263 * @wep_bit: wep bit in frame control for Authentication frame3
2264 * @session: PE session information
2265 *
2266 * This function is called by lim_process_mlm_messages(). Authentication frame
2267 * is formatted and sent when this function is called.
2268 *
2269 * Return: void
2270 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271void
2272lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2273 tpSirMacAuthFrameBody auth_frame,
2274 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302275 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302276 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277{
2278 uint8_t *frame, *body;
2279 uint32_t frame_len = 0, body_len = 0;
2280 tpSirMacMgmtHdr mac_hdr;
2281 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302282 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 uint8_t tx_flag = 0;
2284 uint8_t sme_sessionid = 0;
2285 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002286 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002287 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288
2289 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002290 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 return;
2292 }
2293
2294 sme_sessionid = session->smeSessionId;
2295
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302296 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002297 /*
2298 * Auth frame3 to be sent with encrypted framebody
2299 *
2300 * Allocate buffer for Authenticaton frame of size
2301 * equal to management frame header length plus 2 bytes
2302 * each for auth algorithm number, transaction number,
2303 * status code, 128 bytes for challenge text and
2304 * 4 bytes each for IV & ICV.
2305 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002306 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2307 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002308
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302309 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002310 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002311
2312 goto alloc_packet;
2313 }
2314
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002315 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002316 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 auth_frame->authTransactionSeqNumber,
2318 auth_frame->authStatusCode,
2319 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2320 MAC_ADDR_ARRAY(peer_addr));
2321
2322 switch (auth_frame->authTransactionSeqNumber) {
2323 case SIR_MAC_AUTH_FRAME_1:
2324 /*
2325 * Allocate buffer for Authenticaton frame of size
2326 * equal to management frame header length plus 2 bytes
2327 * each for auth algorithm number, transaction number
2328 * and status code.
2329 */
2330
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002331 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2332 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302334 frame_len += lim_create_fils_auth_data(mac_ctx,
2335 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2337 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2338 0 != session->ftPEContext.pFTPreAuthReq->
2339 ft_ies_length) {
2340 ft_ies_length = session->ftPEContext.
2341 pFTPreAuthReq->ft_ies_length;
2342 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002343 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 ft_ies_length);
2345 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002346 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 frame_len += (2 + SIR_MDIE_SIZE);
2348 }
2349 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 break;
2351
2352 case SIR_MAC_AUTH_FRAME_2:
2353 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2354 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2355 (auth_frame->authStatusCode !=
2356 eSIR_MAC_SUCCESS_STATUS))) {
2357 /*
2358 * Allocate buffer for Authenticaton frame of size
2359 * equal to management frame header length plus
2360 * 2 bytes each for auth algorithm number,
2361 * transaction number and status code.
2362 */
2363
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002364 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2365 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 } else {
2367 /*
2368 * Shared Key algorithm with challenge text
2369 * to be sent.
2370 *
2371 * Allocate buffer for Authenticaton frame of size
2372 * equal to management frame header length plus
2373 * 2 bytes each for auth algorithm number,
2374 * transaction number, status code and 128 bytes
2375 * for challenge text.
2376 */
2377
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002378 challenge_req = true;
2379 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302380 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2381 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002382 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 }
2384 break;
2385
2386 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002387 /*
2388 * Auth frame3 to be sent without encrypted framebody
2389 *
2390 * Allocate buffer for Authenticaton frame of size equal
2391 * to management frame header length plus 2 bytes each
2392 * for auth algorithm number, transaction number and
2393 * status code.
2394 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002396 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2397 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 break;
2399
2400 case SIR_MAC_AUTH_FRAME_4:
2401 /*
2402 * Allocate buffer for Authenticaton frame of size equal
2403 * to management frame header length plus 2 bytes each
2404 * for auth algorithm number, transaction number and
2405 * status code.
2406 */
2407
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002408 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2409 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410
2411 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002412 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002413 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002414 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 } /* switch (auth_frame->authTransactionSeqNumber) */
2416
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002417alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302418 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 (void **)&packet);
2420
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302421 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002422 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 return;
2424 }
2425
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302426 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427
2428 /* Prepare BD */
2429 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2430 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2431 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302432 if (wep_challenge_len)
2433 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2434 else
2435 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
2437 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002438 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302439 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 (uint8_t *) session->bssId,
2441 sizeof(tSirMacAddr));
2442
2443 /* Prepare Authentication frame body */
2444 body = frame + sizeof(tSirMacMgmtHdr);
2445
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302446 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302447 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002449 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 MAC_ADDR_ARRAY(mac_hdr->da));
2451
2452 } else {
2453 *((uint16_t *) (body)) =
2454 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2455 body += sizeof(uint16_t);
2456 body_len -= sizeof(uint16_t);
2457
2458 *((uint16_t *) (body)) =
2459 sir_swap_u16if_needed(
2460 auth_frame->authTransactionSeqNumber);
2461 body += sizeof(uint16_t);
2462 body_len -= sizeof(uint16_t);
2463
2464 *((uint16_t *) (body)) =
2465 sir_swap_u16if_needed(auth_frame->authStatusCode);
2466 body += sizeof(uint16_t);
2467 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002468
2469 if (challenge_req) {
2470 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302471 /* copy challenge IE id, len, challenge text */
2472 *body = auth_frame->type;
2473 body++;
2474 body_len -= sizeof(uint8_t);
2475 *body = auth_frame->length;
2476 body++;
2477 body_len -= sizeof(uint8_t);
2478 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002479 body_len);
2480 pe_err("Incomplete challenge info: length: %d, expected: %d",
2481 body_len,
2482 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2483 body += body_len;
2484 body_len = 0;
2485 } else {
2486 /* copy challenge IE id, len, challenge text */
2487 *body = auth_frame->type;
2488 body++;
2489 *body = auth_frame->length;
2490 body++;
2491 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302492 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2493 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002494
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302495 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2496 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002497 }
2498 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2501 (auth_frame->authTransactionSeqNumber ==
2502 SIR_MAC_AUTH_FRAME_1) &&
2503 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2504
2505 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302506 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 session->ftPEContext.
2508 pFTPreAuthReq->ft_ies,
2509 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002510 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002511 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2512 QDF_TRACE_LEVEL_DEBUG,
2513 (uint8_t *) body,
2514 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 } else if (NULL != session->ftPEContext.
2516 pFTPreAuthReq->pbssDescription) {
2517 /* MDID attr is 54 */
2518 *body = SIR_MDIE_ELEMENT_ID;
2519 body++;
2520 *body = SIR_MDIE_SIZE;
2521 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302522 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 &session->ftPEContext.pFTPreAuthReq->
2524 pbssDescription->mdie[0],
2525 SIR_MDIE_SIZE);
2526 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302527 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002528 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302529 /* TODO MDIE */
2530 pe_debug("appending fils Auth data");
2531 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002534 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2535 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 auth_frame->authTransactionSeqNumber,
2537 auth_frame->authStatusCode,
2538 (auth_frame->authStatusCode ==
2539 eSIR_MAC_SUCCESS_STATUS),
2540 MAC_ADDR_ARRAY(mac_hdr->da));
2541 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002542 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2543 QDF_TRACE_LEVEL_DEBUG,
2544 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302546 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002547 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302548 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002550 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302551 lim_get_rf_band(session->currentOperChannel))
2552 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2553 || (session->pePersona == QDF_P2P_GO_MODE))
2554 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555
Anurag Chouhan6d760662016-02-20 16:05:43 +05302556 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2557 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2559
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302560 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302563 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002564 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002565 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002566 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302567 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2568 (uint16_t)frame_len,
2569 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2570 7, lim_tx_complete, frame,
2571 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002572 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302573 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2574 session->peSessionId, qdf_status));
2575 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2576 pe_err("*** Could not send Auth frame, retCode=%X ***",
2577 qdf_status);
2578 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2579 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002580 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302581 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302582 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 return;
2584}
2585
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002586QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587{
2588 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002589 tpDphHashNode sta_ds;
2590 tLimMlmDeauthReq *deauth_req;
2591 tLimMlmDeauthCnf deauth_cnf;
2592 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002594 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2595 if (deauth_req) {
2596 if (tx_timer_running(
2597 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2598 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002601 session_entry = pe_find_session_by_session_id(mac_ctx,
2602 deauth_req->sessionId);
2603 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002604 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002605 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 eSIR_SME_INVALID_PARAMETERS;
2607 goto end;
2608 }
2609
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002610 sta_ds =
2611 dph_lookup_hash_entry(mac_ctx,
2612 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002613 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002614 &session_entry->dph.dphHashTable);
2615 if (sta_ds == NULL) {
2616 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 goto end;
2618 }
2619
2620 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002621 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2622 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2623 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2624 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302625#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002626 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302627#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002628 (session_entry->isFastRoamIniFeatureEnabled) ||
2629 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002630 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002631 session_entry,
2632 session_entry->peSessionId,
2633 deauth_req->reasonCode,
2634 deauth_req->deauthTrigger);
2635 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002636 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002637 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002638#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002639 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002640#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002641 " isLFR %d"
2642 " is11r %d, Deauth reason %d Trigger = %d",
2643 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002644#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002645 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002646#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002647 session_entry->isFastRoamIniFeatureEnabled,
2648 session_entry->is11Rconnection,
2649 deauth_req->reasonCode,
2650 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002651 }
2652 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002653 qdf_mem_free(deauth_req);
2654 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002658 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2659 &deauth_req->peer_macaddr);
2660 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2661 deauth_cnf.aid = deauth_req->aid;
2662 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663
2664 /* Free up buffer allocated */
2665 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002666 qdf_mem_free(deauth_req);
2667 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002669 lim_post_sme_message(mac_ctx,
2670 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672}
2673
2674/**
2675 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2676 *
2677 * @mac_ctx: Handle to MAC context
2678 *
2679 * Sends disassoc confirmation to SME. Removes disassoc request stored
2680 * in lim.
2681 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302682 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 */
2684
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302685QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686{
2687 uint16_t aid;
2688 tpDphHashNode sta_ds;
2689 tLimMlmDisassocCnf disassoc_cnf;
2690 tpPESession pe_session;
2691 tLimMlmDisassocReq *disassoc_req;
2692
2693 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2694 if (disassoc_req) {
2695 if (tx_timer_running(
2696 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2697 lim_deactivate_and_change_timer(mac_ctx,
2698 eLIM_DISASSOC_ACK_TIMER);
2699
2700 pe_session = pe_find_session_by_session_id(
2701 mac_ctx, disassoc_req->sessionId);
2702 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002703 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 disassoc_cnf.resultCode =
2705 eSIR_SME_INVALID_PARAMETERS;
2706 goto end;
2707 }
2708
2709 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002710 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 &pe_session->dph.dphHashTable);
2712 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002713 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2715 goto end;
2716 }
2717 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002718 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2720 disassoc_cnf.resultCode =
2721 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002722 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 goto end;
2724 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002725 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002726 (disassoc_req->reasonCode !=
2727 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002728 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002729 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 /* Delete FT session if there exists one */
2732 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302735 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302737 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302739 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 }
2741end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002743 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302744 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 disassoc_cnf.aid = disassoc_req->aid;
2746 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2747
2748 /* Update PE session ID */
2749 disassoc_cnf.sessionId = disassoc_req->sessionId;
2750
2751 if (disassoc_req != NULL) {
2752 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302753 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2755 }
2756
2757 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2758 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302759 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002760}
2761
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302762QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002763 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302764 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002766 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302767
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002768 pe_debug("tx_success: %d", tx_success);
2769
2770 return lim_send_disassoc_cnf(max_ctx);
2771}
2772
2773static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2774 qdf_nbuf_t buf,
2775 uint32_t tx_success,
2776 void *params)
2777{
2778 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2779 QDF_STATUS status_code;
2780 struct scheduler_msg msg = {0};
2781
2782 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302783
2784 if (buf)
2785 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002786 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2787 msg.bodyptr = params;
2788 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302789
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002790 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2791 if (status_code != QDF_STATUS_SUCCESS)
2792 pe_err("posting message: %X to LIM failed, reason: %d",
2793 msg.type, status_code);
2794 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795}
2796
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302797QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002798 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302799 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002801 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302802
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002803 pe_debug("tx_success: %d", tx_success);
2804
2805 return lim_send_deauth_cnf(mac_ctx);
2806}
2807
2808static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2809 qdf_nbuf_t buf,
2810 uint32_t tx_success,
2811 void *params)
2812{
2813 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2814 QDF_STATUS status_code;
2815 struct scheduler_msg msg = {0};
2816
2817 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302818
2819 if (buf)
2820 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002821 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2822 msg.bodyptr = params;
2823 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302824
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002825 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2826 if (status_code != QDF_STATUS_SUCCESS)
2827 pe_err("posting message: %X to LIM failed, reason: %d",
2828 msg.type, status_code);
2829 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830}
2831
2832/**
2833 * \brief This function is called to send Disassociate frame.
2834 *
2835 *
2836 * \param pMac Pointer to Global MAC structure
2837 *
2838 * \param nReason Indicates the reason that need to be sent in
2839 * Disassociation frame
2840 *
2841 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2842 * sent
2843 *
2844 *
2845 */
2846
2847void
2848lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2849 uint16_t nReason,
2850 tSirMacAddr peer,
2851 tpPESession psessionEntry, bool waitForAck)
2852{
2853 tDot11fDisassociation frm;
2854 uint8_t *pFrame;
2855 tpSirMacMgmtHdr pMacHdr;
2856 uint32_t nBytes, nPayload, nStatus;
2857 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302858 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 uint8_t txFlag = 0;
2860 uint32_t val = 0;
2861 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 if (NULL == psessionEntry) {
2864 return;
2865 }
2866
2867 /*
2868 * In case when cac timer is running for this SAP session then
2869 * avoid sending disassoc out. It is violation of dfs specification.
2870 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302871 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2872 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302874 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 FL
2876 ("CAC timer is running, drop disassoc from going out"));
2877 return;
2878 }
2879 smeSessionId = psessionEntry->smeSessionId;
2880
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302881 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002882
2883 frm.Reason.code = nReason;
2884
2885 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2886 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002887 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 nStatus);
2889 /* We'll fall back on the worst case scenario: */
2890 nPayload = sizeof(tDot11fDisassociation);
2891 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002892 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2893 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002894 }
2895
2896 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2897
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302898 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302900 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002901 pe_err("Failed to allocate %d bytes for a Disassociation",
2902 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002903 return;
2904 }
2905 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302906 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907
2908 /* Next, we fill out the buffer descriptor: */
2909 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2910 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2911 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2912
2913 /* Prepare the BSSID */
2914 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2915
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917
2918 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2919 sizeof(tSirMacMgmtHdr),
2920 nPayload, &nPayload);
2921 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002922 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 nStatus);
2924 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002925 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002927 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2928 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 }
2930
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002931 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002933 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2935 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2936
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002937 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302938 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2939 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 ) {
2941 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2942 }
2943
Sushant Kaushik46556062015-12-02 16:57:47 +05302944 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945
2946 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302947 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 psessionEntry->peSessionId,
2949 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002950 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002951 psessionEntry, QDF_STATUS_SUCCESS,
2952 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 /* Queue Disassociation frame in high priority WQ */
2954 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302955 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2957 TXRX_FRM_802_11_MGMT,
2958 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002959 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002960 txFlag, smeSessionId, false, 0,
2961 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302962 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302963 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302964 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965
2966 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2967
2968 if (tx_timer_change
2969 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2970 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002971 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 return;
2973 } else if (TX_SUCCESS !=
2974 tx_timer_activate(&pMac->lim.limTimers.
2975 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002976 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 lim_deactivate_and_change_timer(pMac,
2978 eLIM_DISASSOC_ACK_TIMER);
2979 return;
2980 }
2981 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302982 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 psessionEntry->peSessionId,
2984 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002985 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2986 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002987 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 TXRX_FRM_802_11_MGMT,
2991 ANI_TXDIR_TODS,
2992 7,
2993 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002994 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302995 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302996 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 psessionEntry->peSessionId, qdf_status));
2998 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002999 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303000 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001 /* Pkt will be freed up by the callback */
3002 }
3003 }
3004} /* End lim_send_disassoc_mgmt_frame. */
3005
3006/**
3007 * \brief This function is called to send a Deauthenticate frame
3008 *
3009 *
3010 * \param pMac Pointer to global MAC structure
3011 *
3012 * \param nReason Indicates the reason that need to be sent in the
3013 * Deauthenticate frame
3014 *
3015 * \param peeer address of the STA to which the frame is to be sent
3016 *
3017 *
3018 */
3019
3020void
3021lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
3022 uint16_t nReason,
3023 tSirMacAddr peer,
3024 tpPESession psessionEntry, bool waitForAck)
3025{
3026 tDot11fDeAuth frm;
3027 uint8_t *pFrame;
3028 tpSirMacMgmtHdr pMacHdr;
3029 uint32_t nBytes, nPayload, nStatus;
3030 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303031 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 uint8_t txFlag = 0;
3033 uint32_t val = 0;
3034#ifdef FEATURE_WLAN_TDLS
3035 uint16_t aid;
3036 tpDphHashNode pStaDs;
3037#endif
3038 uint8_t smeSessionId = 0;
3039
3040 if (NULL == psessionEntry) {
3041 return;
3042 }
3043
3044 /*
3045 * In case when cac timer is running for this SAP session then
3046 * avoid deauth frame out. It is violation of dfs specification.
3047 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303048 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
3049 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303051 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 FL
3053 ("CAC timer is running, drop the deauth from going out"));
3054 return;
3055 }
3056 smeSessionId = psessionEntry->smeSessionId;
3057
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303058 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059
3060 frm.Reason.code = nReason;
3061
3062 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
3063 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003064 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 nStatus);
3066 /* We'll fall back on the worst case scenario: */
3067 nPayload = sizeof(tDot11fDeAuth);
3068 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003069 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3070 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 }
3072
3073 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3074
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303075 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303077 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003078 pe_err("Failed to allocate %d bytes for a De-Authentication",
3079 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080 return;
3081 }
3082 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303083 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084
3085 /* Next, we fill out the buffer descriptor: */
3086 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3087 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
3088 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3089
3090 /* Prepare the BSSID */
3091 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094
3095 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
3096 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3097 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003098 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 nStatus);
3100 cds_packet_free((void *)pPacket);
3101 return;
3102 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003103 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3104 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003106 pe_debug("***Sessionid %d Sending Deauth frame with "
3107 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3108 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 psessionEntry->peSessionId, nReason, waitForAck,
3110 MAC_ADDR_ARRAY(pMacHdr->da),
3111 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3112
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003113 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303114 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3115 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 ) {
3117 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3118 }
3119
Sushant Kaushik46556062015-12-02 16:57:47 +05303120 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121#ifdef FEATURE_WLAN_TDLS
3122 pStaDs =
3123 dph_lookup_hash_entry(pMac, peer, &aid,
3124 &psessionEntry->dph.dphHashTable);
3125#endif
3126
3127 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303128 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 psessionEntry->peSessionId,
3130 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003131 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3132 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003133 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303135 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3137 TXRX_FRM_802_11_MGMT,
3138 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003139 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003140 txFlag, smeSessionId, false, 0,
3141 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303142 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303143 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303144 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303146 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003147 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
3150 /* Call lim_process_deauth_ack_timeout which will send
3151 * DeauthCnf for this frame
3152 */
3153 lim_process_deauth_ack_timeout(pMac);
3154 return;
3155 }
3156
3157 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3158
3159 if (tx_timer_change
3160 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3161 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003162 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 return;
3164 } else if (TX_SUCCESS !=
3165 tx_timer_activate(&pMac->lim.limTimers.
3166 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003167 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 lim_deactivate_and_change_timer(pMac,
3169 eLIM_DEAUTH_ACK_TIMER);
3170 return;
3171 }
3172 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303173 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 psessionEntry->peSessionId,
3175 pMacHdr->fc.subType));
3176#ifdef FEATURE_WLAN_TDLS
3177 if ((NULL != pStaDs)
3178 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3179 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003180 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3181 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003182 QDF_STATUS_SUCCESS,
3183 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303184 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3186 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3187 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003188 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 } else {
3190#endif
Krunal Sonic65fc492018-03-09 15:53:28 -08003191 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3192 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003193 QDF_STATUS_SUCCESS,
3194 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303196 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3198 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3199 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003200 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201#ifdef FEATURE_WLAN_TDLS
3202 }
3203#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303204 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303205 psessionEntry->peSessionId, qdf_status));
3206 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003207 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303208 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 /* Pkt will be freed up by the callback */
3210 }
3211 }
3212
3213} /* End lim_send_deauth_mgmt_frame. */
3214
3215#ifdef ANI_SUPPORT_11H
3216/**
3217 * \brief Send a Measurement Report Action frame
3218 *
3219 *
3220 * \param pMac Pointer to the global MAC structure
3221 *
3222 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3223 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003224 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 *
3226 *
3227 */
3228
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003229QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230lim_send_meas_report_frame(tpAniSirGlobal pMac,
3231 tpSirMacMeasReqActionFrame pMeasReqFrame,
3232 tSirMacAddr peer, tpPESession psessionEntry)
3233{
3234 tDot11fMeasurementReport frm;
3235 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003236 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 tpSirMacMgmtHdr pMacHdr;
3238 uint32_t nBytes, nPayload, nStatus;
3239 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303240 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303242 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
3244 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3245 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3246 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3247
3248 switch (pMeasReqFrame->measReqIE.measType) {
3249 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3250 nSirStatus =
3251 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3252 &frm.MeasurementReport);
3253 break;
3254 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3255 nSirStatus =
3256 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3257 &frm.MeasurementReport);
3258 break;
3259 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3260 nSirStatus =
3261 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3262 &frm.MeasurementReport);
3263 break;
3264 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003265 pe_err("Unknown measurement type %d in limSen"
3266 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003268 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 }
3270
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003271 if (QDF_STATUS_SUCCESS != nSirStatus)
3272 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273
3274 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3275 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003276 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 nStatus);
3278 /* We'll fall back on the worst case scenario: */
3279 nPayload = sizeof(tDot11fMeasurementReport);
3280 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003281 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3282 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 }
3284
3285 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3286
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003288 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 (uint16_t) nBytes, (void **)&pFrame,
3290 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003292 pe_err("Failed to allocate %d bytes for a "
3293 "De-Authentication", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003294 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 }
3296 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303297 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298
3299 /* Next, we fill out the buffer descriptor: */
3300 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3301 SIR_MAC_MGMT_ACTION, peer);
3302 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3303
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303304 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307
3308 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3309 sizeof(tSirMacMgmtHdr),
3310 nPayload, &nPayload);
3311 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003312 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003314 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003316 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003318 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3319 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 }
3321
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303322 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 ((psessionEntry) ? psessionEntry->
3324 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303325 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3327 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003328 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303329 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303330 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332 qdf_status));
3333 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003334 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303335 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003337 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 }
3339
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003340 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341
3342} /* End lim_send_meas_report_frame. */
3343
3344/**
3345 * \brief Send a TPC Request Action frame
3346 *
3347 *
3348 * \param pMac Pointer to the global MAC datastructure
3349 *
3350 * \param peer MAC address to which the frame should be sent
3351 *
3352 *
3353 */
3354
3355void
3356lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3357 tSirMacAddr peer, tpPESession psessionEntry)
3358{
3359 tDot11fTPCRequest frm;
3360 uint8_t *pFrame;
3361 tpSirMacMgmtHdr pMacHdr;
3362 uint32_t nBytes, nPayload, nStatus;
3363 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303364 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303366 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367
3368 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3369 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3370 frm.DialogToken.token = 1;
3371 frm.TPCRequest.present = 1;
3372
3373 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3374 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003375 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 /* We'll fall back on the worst case scenario: */
3377 nPayload = sizeof(tDot11fTPCRequest);
3378 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003379 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3380 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 }
3382
3383 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3384
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303385 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003386 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 (uint16_t) nBytes, (void **)&pFrame,
3388 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303389 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003390 pe_err("Failed to allocate %d bytes for a TPC"
3391 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 return;
3393 }
3394 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303395 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003396
3397 /* Next, we fill out the buffer descriptor: */
3398 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3399 SIR_MAC_MGMT_ACTION, peer);
3400 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3401
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303402 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405
3406 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3407 sizeof(tSirMacMgmtHdr),
3408 nPayload, &nPayload);
3409 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003410 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003412 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 (void *)pFrame, (void *)pPacket);
3414 return; /* allocated! */
3415 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003416 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3417 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 }
3419
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303420 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 ((psessionEntry) ? psessionEntry->
3422 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303423 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3425 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003426 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303427 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303428 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303430 qdf_status));
3431 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003432 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303433 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 /* Pkt will be freed up by the callback */
3435 }
3436
3437} /* End lim_send_tpc_request_frame. */
3438
3439/**
3440 * \brief Send a TPC Report Action frame
3441 *
3442 *
3443 * \param pMac Pointer to the global MAC datastructure
3444 *
3445 * \param pTpcReqFrame Pointer to the received TPC Request
3446 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003447 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 *
3449 *
3450 */
3451
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003452QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3454 tpSirMacTpcReqActionFrame pTpcReqFrame,
3455 tSirMacAddr peer, tpPESession psessionEntry)
3456{
3457 tDot11fTPCReport frm;
3458 uint8_t *pFrame;
3459 tpSirMacMgmtHdr pMacHdr;
3460 uint32_t nBytes, nPayload, nStatus;
3461 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303462 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303464 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465
3466 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3467 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3468 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3469
3470 frm.TPCReport.tx_power = 0;
3471 frm.TPCReport.link_margin = 0;
3472 frm.TPCReport.present = 1;
3473
3474 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3475 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003476 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 /* We'll fall back on the worst case scenario: */
3478 nPayload = sizeof(tDot11fTPCReport);
3479 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003480 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3481 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 }
3483
3484 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3485
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003487 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 (uint16_t) nBytes, (void **)&pFrame,
3489 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303490 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003491 pe_err("Failed to allocate %d bytes for a TPC"
3492 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003493 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 }
3495 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303496 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497
3498 /* Next, we fill out the buffer descriptor: */
3499 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3500 SIR_MAC_MGMT_ACTION, peer);
3501
3502 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3503
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303504 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507
3508 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3509 sizeof(tSirMacMgmtHdr),
3510 nPayload, &nPayload);
3511 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003512 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003513 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003514 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003516 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003518 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3519 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303521 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 ((psessionEntry) ? psessionEntry->
3523 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3526 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003527 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303528 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003529 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3530 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3531 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303532 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003533 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303534 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003536 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 }
3538
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003539 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540
3541} /* End lim_send_tpc_report_frame. */
3542#endif /* ANI_SUPPORT_11H */
3543
3544/**
3545 * \brief Send a Channel Switch Announcement
3546 *
3547 *
3548 * \param pMac Pointer to the global MAC datastructure
3549 *
3550 * \param peer MAC address to which this frame will be sent
3551 *
3552 * \param nMode
3553 *
3554 * \param nNewChannel
3555 *
3556 * \param nCount
3557 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003558 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 *
3560 *
3561 */
3562
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003563QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3565 tSirMacAddr peer,
3566 uint8_t nMode,
3567 uint8_t nNewChannel,
3568 uint8_t nCount, tpPESession psessionEntry)
3569{
3570 tDot11fChannelSwitch frm;
3571 uint8_t *pFrame;
3572 tpSirMacMgmtHdr pMacHdr;
3573 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3574 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303575 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 uint8_t txFlag = 0;
3577
3578 uint8_t smeSessionId = 0;
3579
3580 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003581 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003582 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 }
3584 smeSessionId = psessionEntry->smeSessionId;
3585
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303586 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587
3588 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3589 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3590 frm.ChanSwitchAnn.switchMode = nMode;
3591 frm.ChanSwitchAnn.newChannel = nNewChannel;
3592 frm.ChanSwitchAnn.switchCount = nCount;
3593 frm.ChanSwitchAnn.present = 1;
3594
3595 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3596 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003597 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 nStatus);
3599 /* We'll fall back on the worst case scenario: */
3600 nPayload = sizeof(tDot11fChannelSwitch);
3601 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003602 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3603 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 }
3605
3606 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3607
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303608 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3610 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303611 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003612 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003613 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 }
3615 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303616 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617
3618 /* Next, we fill out the buffer descriptor: */
3619 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3620 SIR_MAC_MGMT_ACTION, peer,
3621 psessionEntry->selfMacAddr);
3622 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303623 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627
3628 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3629 sizeof(tSirMacMgmtHdr),
3630 nPayload, &nPayload);
3631 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003632 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 nStatus);
3634 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003635 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003636 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003637 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3638 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 }
3640
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003641 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303642 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3643 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 ) {
3645 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3646 }
3647
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303648 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 TXRX_FRM_802_11_MGMT,
3652 ANI_TXDIR_TODS,
3653 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003654 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303655 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303656 psessionEntry->peSessionId, qdf_status));
3657 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003658 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303659 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003661 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 }
3663
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003664 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665
3666} /* End lim_send_channel_switch_mgmt_frame. */
3667
Abhishek Singh518323d2015-10-19 17:42:01 +05303668/**
3669 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3670 * action frame over the air .
3671 * @mac_ctx: pointer to global mac structure
3672 * @peer: Destination mac.
3673 * @mode: channel switch mode
3674 * @new_op_class: new op class
3675 * @new_channel: new channel to switch
3676 * @count: channel switch count
3677 *
3678 * This function is called to send ECSA frame.
3679 *
3680 * Return: success if frame is sent else return failure
3681 */
3682
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003683QDF_STATUS
Abhishek Singh518323d2015-10-19 17:42:01 +05303684lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3685 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3686 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3687{
3688 tDot11fext_channel_switch_action_frame frm;
3689 uint8_t *frame;
3690 tpSirMacMgmtHdr mac_hdr;
3691 uint32_t num_bytes, n_payload, status;
3692 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303693 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303694 uint8_t txFlag = 0;
3695 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303696 uint8_t ch_spacing;
3697 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303698
3699 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003700 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003701 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303702 }
3703
3704 sme_session_id = session_entry->smeSessionId;
3705
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303706 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303707
3708 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3709 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3710
3711 frm.ext_chan_switch_ann_action.switch_mode = mode;
3712 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3713 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3714 frm.ext_chan_switch_ann_action.switch_count = count;
3715
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303716 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3717 mac_ctx->scan.countryCodeCurrent, new_channel,
3718 new_op_class);
3719 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3720
3721 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3722 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3723 frm.WiderBWChanSwitchAnn.newChanWidth =
3724 wide_bw_ie->newChanWidth;
3725 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3726 wide_bw_ie->newCenterChanFreq0;
3727 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3728 wide_bw_ie->newCenterChanFreq1;
3729 frm.WiderBWChanSwitchAnn.present = 1;
3730 pe_debug("wrapper: width:%d f0:%d f1:%d",
3731 frm.WiderBWChanSwitchAnn.newChanWidth,
3732 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3733 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3734 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303735
3736 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3737 &frm, &n_payload);
3738 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003739 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303740 status);
3741 /* We'll fall back on the worst case scenario*/
3742 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3743 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003744 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303745 status);
3746 }
3747
3748 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3749
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303750 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303751 (void **) &frame, (void **) &packet);
3752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303753 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003754 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303755 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003756 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303757 }
3758
3759 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303760 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303761
3762 /* Next, we fill out the buffer descriptor */
3763 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3764 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3765 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303766 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303767 (uint8_t *) session_entry->bssId,
3768 sizeof(tSirMacAddr));
3769
gaolez4b62a9e2018-08-16 15:57:50 +08003770 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3771
Abhishek Singh518323d2015-10-19 17:42:01 +05303772 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3773 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3774 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003775 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303776 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003777 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303778 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003779 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303780 status);
3781 }
3782
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003783 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303784 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303785 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3786 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303787 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3788 }
3789
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003790 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 +05303791 MAC_ADDR_ARRAY(mac_hdr->da),
3792 frm.ext_chan_switch_ann_action.switch_count,
3793 frm.ext_chan_switch_ann_action.switch_mode,
3794 frm.ext_chan_switch_ann_action.new_channel,
3795 frm.ext_chan_switch_ann_action.op_class);
3796
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303797 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303798 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303800 TXRX_FRM_802_11_MGMT,
3801 ANI_TXDIR_TODS,
3802 7,
3803 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003804 txFlag, sme_session_id, 0,
3805 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303806 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303807 session_entry->peSessionId, qdf_status));
3808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003809 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303810 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303811 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003812 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303813 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003814 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303815} /* End lim_send_extended_chan_switch_action_frame */
3816
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303817
3818/**
3819 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3820 * sent over the air
3821 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303822 * @context: pointer to global mac
3823 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303824 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303825 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303826 *
3827 * Return: This returns QDF_STATUS
3828 */
3829
3830static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303831 void *context,
3832 qdf_nbuf_t buf,
3833 uint32_t tx_complete,
3834 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303835{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003836 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003837 if (buf)
3838 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303839 return QDF_STATUS_SUCCESS;
3840}
3841
3842/**
3843 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3844 * p2p oper chan change confirm action frame
3845 * @mac_ctx: pointer to global mac structure
3846 * @peer: Destination mac.
3847 * @session_entry: session entry
3848 *
3849 * This function is called to send p2p oper chan change confirm action frame.
3850 *
3851 * Return: success if frame is sent else return failure
3852 */
3853
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003854QDF_STATUS
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303855lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3856 tSirMacAddr peer, tpPESession session_entry)
3857{
3858 tDot11fp2p_oper_chan_change_confirm frm;
3859 uint8_t *frame;
3860 tpSirMacMgmtHdr mac_hdr;
3861 uint32_t num_bytes, n_payload, status;
3862 void *packet;
3863 QDF_STATUS qdf_status;
3864 uint8_t tx_flag = 0;
3865 uint8_t sme_session_id = 0;
3866
3867 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003868 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003869 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303870 }
3871
3872 sme_session_id = session_entry->smeSessionId;
3873
3874 qdf_mem_set(&frm, sizeof(frm), 0);
3875
3876 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3877
3878 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3879 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3880 frm.p2p_action_subtype.subtype = 0x04;
3881 frm.DialogToken.token = 0x0;
3882
3883 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003884 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303885 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3886 }
3887
3888 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003889 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303890 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3891 populate_dot11f_operating_mode(mac_ctx,
3892 &frm.OperatingMode, session_entry);
3893 }
3894
3895 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3896 &frm, &n_payload);
3897 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003898 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303899 /* We'll fall back on the worst case scenario*/
3900 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3901 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003902 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3903 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303904 }
3905
3906 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3907
3908 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3909 (void **) &frame, (void **) &packet);
3910
3911 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003912 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003913 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303914 }
3915
3916 qdf_mem_set(frame, num_bytes, 0);
3917
3918 /* Next, fill out the buffer descriptor */
3919 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3920 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3921 mac_hdr = (tpSirMacMgmtHdr) frame;
3922 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3923 (uint8_t *) session_entry->bssId,
3924 sizeof(tSirMacAddr));
3925
3926 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3927 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3928 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003929 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303930 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003931 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303932 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003933 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303934 status);
3935 }
3936
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003937 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303938 lim_get_rf_band(session_entry->currentOperChannel)) ||
3939 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3940 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3941 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3942 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003943 pe_debug("Send frame on channel %d to mac "
3944 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303945 MAC_ADDR_ARRAY(peer));
3946
3947 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3948 session_entry->peSessionId, mac_hdr->fc.subType));
3949
3950 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3951 (uint16_t)num_bytes,
3952 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3953 7, lim_tx_complete, frame,
3954 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003955 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303956
3957 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3958 session_entry->peSessionId, qdf_status));
3959 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003960 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303961 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003962 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303963 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003964 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303965}
3966
3967
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003968QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3970 tSirMacAddr peer,
3971 uint8_t nMode, tpPESession psessionEntry)
3972{
3973 tDot11fOperatingMode frm;
3974 uint8_t *pFrame;
3975 tpSirMacMgmtHdr pMacHdr;
3976 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3977 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303978 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 uint8_t txFlag = 0;
3980
3981 uint8_t smeSessionId = 0;
3982
3983 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003984 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003985 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 }
3987 smeSessionId = psessionEntry->smeSessionId;
3988
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303989 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990
3991 frm.Category.category = SIR_MAC_ACTION_VHT;
3992 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3993 frm.OperatingMode.chanWidth = nMode;
3994 frm.OperatingMode.rxNSS = 0;
3995 frm.OperatingMode.rxNSSType = 0;
3996
3997 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3998 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003999 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 nStatus);
4001 /* We'll fall back on the worst case scenario: */
4002 nPayload = sizeof(tDot11fOperatingMode);
4003 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004004 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
4005 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 }
4007
4008 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304010 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4012 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304013 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004014 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
4015 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004016 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 }
4018 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304019 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020
4021 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304022 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4024 SIR_MAC_MGMT_ACTION, peer,
4025 psessionEntry->selfMacAddr);
4026 else
4027 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4028 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
4029 psessionEntry->selfMacAddr);
4030 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304031 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
4033 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
4034 sizeof(tSirMacMgmtHdr),
4035 nPayload, &nPayload);
4036 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004037 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 nStatus);
4039 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004040 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004042 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
4043 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004045 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304046 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4047 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 ) {
4049 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4050 }
4051
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304052 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 TXRX_FRM_802_11_MGMT,
4056 ANI_TXDIR_TODS,
4057 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004058 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304059 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304060 psessionEntry->peSessionId, qdf_status));
4061 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004062 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304063 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004065 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 }
4067
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004068 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069}
4070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071/**
4072 * \brief Send a Neighbor Report Request Action frame
4073 *
4074 *
4075 * \param pMac Pointer to the global MAC structure
4076 *
4077 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4078 *
4079 * \param peer mac address of peer station.
4080 *
4081 * \param psessionEntry address of session entry.
4082 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004083 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 *
4085 *
4086 */
4087
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004088QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
4090 tpSirMacNeighborReportReq pNeighborReq,
4091 tSirMacAddr peer, tpPESession psessionEntry)
4092{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004093 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 tDot11fNeighborReportRequest frm;
4095 uint8_t *pFrame;
4096 tpSirMacMgmtHdr pMacHdr;
4097 uint32_t nBytes, nPayload, nStatus;
4098 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304099 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 uint8_t txFlag = 0;
4101 uint8_t smeSessionId = 0;
4102
4103 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004104 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004105 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 }
4107 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304108 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109
4110 frm.Category.category = SIR_MAC_ACTION_RRM;
4111 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4112 frm.DialogToken.token = pNeighborReq->dialogToken;
4113
4114 if (pNeighborReq->ssid_present) {
4115 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4116 }
4117
4118 nStatus =
4119 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4120 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004121 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 nStatus);
4123 /* We'll fall back on the worst case scenario: */
4124 nPayload = sizeof(tDot11fNeighborReportRequest);
4125 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004126 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4127 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 }
4129
4130 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4131
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304132 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4134 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304135 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004136 pe_err("Failed to allocate %d bytes for a Neighbor "
4137 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004138 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 }
4140 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304141 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142
4143 /* Copy necessary info to BD */
4144 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4145 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4146
4147 /* Update A3 with the BSSID */
4148 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4149
4150 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153
4154 /* Now, we're ready to "pack" the frames */
4155 nStatus = dot11f_pack_neighbor_report_request(pMac,
4156 &frm,
4157 pFrame +
4158 sizeof(tSirMacMgmtHdr),
4159 nPayload, &nPayload);
4160
4161 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004162 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 nStatus);
4164
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004165 /* FIXME - Need to convert to QDF_STATUS */
4166 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 goto returnAfterError;
4168 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004169 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4170 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 }
4172
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004173 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304174 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004176 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304177 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4178 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 ) {
4180 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4181 }
4182
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304183 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304185 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 pPacket,
4187 (uint16_t) nBytes,
4188 TXRX_FRM_802_11_MGMT,
4189 ANI_TXDIR_TODS,
4190 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004191 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304192 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304193 psessionEntry->peSessionId, qdf_status));
4194 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004195 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004196 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 /* Pkt will be freed up by the callback */
4198 return statusCode;
4199 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201
4202returnAfterError:
4203 cds_packet_free((void *)pPacket);
4204
4205 return statusCode;
4206} /* End lim_send_neighbor_report_request_frame. */
4207
4208/**
4209 * \brief Send a Link Report Action frame
4210 *
4211 *
4212 * \param pMac Pointer to the global MAC structure
4213 *
4214 * \param pLinkReport Address of a tSirMacLinkReport
4215 *
4216 * \param peer mac address of peer station.
4217 *
4218 * \param psessionEntry address of session entry.
4219 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004220 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 *
4222 *
4223 */
4224
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004225QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4227 tpSirMacLinkReport pLinkReport,
4228 tSirMacAddr peer, tpPESession psessionEntry)
4229{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004230 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 tDot11fLinkMeasurementReport frm;
4232 uint8_t *pFrame;
4233 tpSirMacMgmtHdr pMacHdr;
4234 uint32_t nBytes, nPayload, nStatus;
4235 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304236 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 uint8_t txFlag = 0;
4238 uint8_t smeSessionId = 0;
4239
4240 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004241 pe_err("(psession == NULL) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004242 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 }
4244
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304245 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004246
4247 frm.Category.category = SIR_MAC_ACTION_RRM;
4248 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4249 frm.DialogToken.token = pLinkReport->dialogToken;
4250
4251 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4252 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4253 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4254 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4255 /* such case this way than changing the frame parser. */
4256 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4257 frm.TPCEleLen.TPCLen = 2;
4258 frm.TxPower.txPower = pLinkReport->txPower;
4259 frm.LinkMargin.linkMargin = 0;
4260
4261 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4262 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4263 frm.RCPI.rcpi = pLinkReport->rcpi;
4264 frm.RSNI.rsni = pLinkReport->rsni;
4265
4266 nStatus =
4267 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4268 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004269 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004270 /* We'll fall back on the worst case scenario: */
4271 nPayload = sizeof(tDot11fLinkMeasurementReport);
4272 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004273 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4274 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 }
4276
4277 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4278
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304279 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4281 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304282 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004283 pe_err("Failed to allocate %d bytes for a Link "
4284 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004285 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004286 }
4287 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289
4290 /* Copy necessary info to BD */
4291 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4292 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4293
4294 /* Update A3 with the BSSID */
4295 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4296
4297 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4298
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300
4301 /* Now, we're ready to "pack" the frames */
4302 nStatus = dot11f_pack_link_measurement_report(pMac,
4303 &frm,
4304 pFrame +
4305 sizeof(tSirMacMgmtHdr),
4306 nPayload, &nPayload);
4307
4308 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004309 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004311 /* FIXME - Need to convert to QDF_STATUS */
4312 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 goto returnAfterError;
4314 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004315 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 nStatus);
4317 }
4318
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004319 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 lim_print_mac_addr(pMac, peer, LOGW);
4321
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004322 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304323 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4324 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4326 }
4327
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304328 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304330 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 pPacket,
4332 (uint16_t) nBytes,
4333 TXRX_FRM_802_11_MGMT,
4334 ANI_TXDIR_TODS,
4335 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004336 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304337 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304338 psessionEntry->peSessionId, qdf_status));
4339 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004340 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004341 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 /* Pkt will be freed up by the callback */
4343 return statusCode;
4344 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004345 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346
4347returnAfterError:
4348 cds_packet_free((void *)pPacket);
4349
4350 return statusCode;
4351} /* End lim_send_link_report_action_frame. */
4352
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004353QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304355 uint8_t dialog_token,
4356 uint8_t num_report,
4357 struct rrm_beacon_report_last_beacon_params
4358 *last_beacon_report_params,
4359 tpSirMacRadioMeasureReport pRRMReport,
4360 tSirMacAddr peer,
4361 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004363 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 uint8_t *pFrame;
4365 tpSirMacMgmtHdr pMacHdr;
4366 uint32_t nBytes, nPayload, nStatus;
4367 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304368 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 uint8_t i;
4370 uint8_t txFlag = 0;
4371 uint8_t smeSessionId = 0;
4372
4373 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304374 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 if (!frm) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004376 pe_err("Not enough memory to allocate tDot11fRadioMeasurementReport");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004377 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 }
4379
4380 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004381 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304382 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004383 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004385
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004386 smeSessionId = psessionEntry->smeSessionId;
4387
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004388 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304389 dialog_token, num_report);
4390
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 frm->Category.category = SIR_MAC_ACTION_RRM;
4392 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4393 frm->DialogToken.token = dialog_token;
4394
4395 frm->num_MeasurementReport =
4396 (num_report >
4397 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4398 num_report;
4399
4400 for (i = 0; i < frm->num_MeasurementReport; i++) {
4401 frm->MeasurementReport[i].type = pRRMReport[i].type;
4402 frm->MeasurementReport[i].token = pRRMReport[i].token;
4403 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4404 switch (pRRMReport[i].type) {
4405 case SIR_MAC_RRM_BEACON_TYPE:
4406 populate_dot11f_beacon_report(pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304407 &frm->MeasurementReport[i],
4408 &pRRMReport[i].report.
4409 beaconReport,
4410 last_beacon_report_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 frm->MeasurementReport[i].incapable =
4412 pRRMReport[i].incapable;
4413 frm->MeasurementReport[i].refused =
4414 pRRMReport[i].refused;
4415 frm->MeasurementReport[i].present = 1;
4416 break;
4417 default:
4418 frm->MeasurementReport[i].incapable =
4419 pRRMReport[i].incapable;
4420 frm->MeasurementReport[i].refused =
4421 pRRMReport[i].refused;
4422 frm->MeasurementReport[i].present = 1;
4423 break;
4424 }
4425 }
4426
4427 nStatus =
4428 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4429 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004430 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 nStatus);
4432 /* We'll fall back on the worst case scenario: */
4433 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304434 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004435 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004437 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4438 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439 }
4440
4441 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4442
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304443 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4445 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004447 pe_err("Failed to allocate %d bytes for a Radio Measure "
4448 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304449 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004450 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 }
4452 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304453 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 /* Copy necessary info to BD */
4456 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4457 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4458
4459 /* Update A3 with the BSSID */
4460 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4461
4462 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 /* Now, we're ready to "pack" the frames */
4467 nStatus = dot11f_pack_radio_measurement_report(pMac,
4468 frm,
4469 pFrame +
4470 sizeof(tSirMacMgmtHdr),
4471 nPayload, &nPayload);
4472
4473 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004474 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 nStatus);
4476
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004477 /* FIXME - Need to convert to QDF_STATUS */
4478 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 goto returnAfterError;
4480 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004481 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4482 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 }
4484
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004485 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 lim_print_mac_addr(pMac, peer, LOGW);
4487
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004488 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304489 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4490 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 ) {
4492 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4493 }
4494
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304495 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304497 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 pPacket,
4499 (uint16_t) nBytes,
4500 TXRX_FRM_802_11_MGMT,
4501 ANI_TXDIR_TODS,
4502 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004503 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304504 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304505 psessionEntry->peSessionId, qdf_status));
4506 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004507 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004508 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304510 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 return statusCode;
4512 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304513 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004514 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 }
4516
4517returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304518 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 cds_packet_free((void *)pPacket);
4520 return statusCode;
4521}
4522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523#ifdef WLAN_FEATURE_11W
4524/**
4525 * \brief Send SA query request action frame to peer
4526 *
4527 * \sa lim_send_sa_query_request_frame
4528 *
4529 *
4530 * \param pMac The global tpAniSirGlobal object
4531 *
4532 * \param transId Transaction identifier
4533 *
4534 * \param peer The Mac address of the station to which this action frame is addressed
4535 *
4536 * \param psessionEntry The PE session entry
4537 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004538 * \return QDF_STATUS_SUCCESS if setup completes successfully
4539 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 */
4541
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004542QDF_STATUS lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 tSirMacAddr peer,
4544 tpPESession psessionEntry)
4545{
4546
4547 tDot11fSaQueryReq frm; /* SA query request action frame */
4548 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004549 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 tpSirMacMgmtHdr pMacHdr;
4551 uint32_t nBytes, nPayload, nStatus;
4552 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304553 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 uint8_t txFlag = 0;
4555 uint8_t smeSessionId = 0;
4556
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304557 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4559 /* 11w action field is :
4560 action: 0 --> SA Query Request action frame
4561 action: 1 --> SA Query Response action frame */
4562 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4563 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304564 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004565
4566 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4567 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004568 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 nStatus);
4570 /* We'll fall back on the worst case scenario: */
4571 nPayload = sizeof(tDot11fSaQueryReq);
4572 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004573 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4574 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 }
4576
4577 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304578 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304580 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004581 pe_err("Failed to allocate %d bytes for a SA Query Request "
4582 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004583 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 }
4585 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304586 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587
4588 /* Copy necessary info to BD */
4589 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4590 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4591
4592 /* Update A3 with the BSSID */
4593 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4594
4595 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4596
4597 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4598 /* in the FC */
4599 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4600
4601 /* Pack 11w SA Query Request frame */
4602 nStatus = dot11f_pack_sa_query_req(pMac,
4603 &frm,
4604 pFrame + sizeof(tSirMacMgmtHdr),
4605 nPayload, &nPayload);
4606
4607 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004608 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004610 /* FIXME - Need to convert to QDF_STATUS */
4611 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 goto returnAfterError;
4613 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004614 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 nStatus);
4616 }
4617
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004618 pe_debug("Sending an SA Query Request to");
4619 lim_print_mac_addr(pMac, peer, LOGD);
4620 pe_debug("Sending an SA Query Request from ");
4621 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004623 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304625 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4626 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627#endif
4628 ) {
4629 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4630 }
4631 smeSessionId = psessionEntry->smeSessionId;
4632
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304633 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 pPacket,
4635 (uint16_t) nBytes,
4636 TXRX_FRM_802_11_MGMT,
4637 ANI_TXDIR_TODS,
4638 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004639 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304640 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004641 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004642 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 /* Pkt will be freed up by the callback */
4644 return nSirStatus;
4645 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004646 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 }
4648
4649returnAfterError:
4650 cds_packet_free((void *)pPacket);
4651 return nSirStatus;
4652} /* End lim_send_sa_query_request_frame */
4653
4654/**
4655 * \brief Send SA query response action frame to peer
4656 *
4657 * \sa lim_send_sa_query_response_frame
4658 *
4659 *
4660 * \param pMac The global tpAniSirGlobal object
4661 *
4662 * \param transId Transaction identifier received in SA query request action frame
4663 *
4664 * \param peer The Mac address of the AP to which this action frame is addressed
4665 *
4666 * \param psessionEntry The PE session entry
4667 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004668 * \return QDF_STATUS_SUCCESS if setup completes successfully
4669 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 */
4671
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004672QDF_STATUS lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673 uint8_t *transId, tSirMacAddr peer,
4674 tpPESession psessionEntry)
4675{
4676
Jeff Johnson47d75242018-05-12 15:58:53 -07004677 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004679 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 tpSirMacMgmtHdr pMacHdr;
4681 uint32_t nBytes, nPayload, nStatus;
4682 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304683 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 uint8_t txFlag = 0;
4685 uint8_t smeSessionId = 0;
4686
4687 smeSessionId = psessionEntry->smeSessionId;
4688
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304689 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4691 /*11w action field is :
4692 action: 0 --> SA query request action frame
4693 action: 1 --> SA query response action frame */
4694 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4695 /*11w SA query response transId is same as
4696 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304697 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698
4699 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4700 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004701 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 nStatus);
4703 /* We'll fall back on the worst case scenario: */
4704 nPayload = sizeof(tDot11fSaQueryRsp);
4705 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004706 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4707 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 }
4709
4710 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304711 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304713 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004714 pe_err("Failed to allocate %d bytes for a SA query response"
4715 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004716 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 }
4718 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304719 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720
4721 /* Copy necessary info to BD */
4722 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4723 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4724
4725 /* Update A3 with the BSSID */
4726 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4727
4728 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4729
4730 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4731 /* in the FC */
4732 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4733
4734 /* Pack 11w SA query response frame */
4735 nStatus = dot11f_pack_sa_query_rsp(pMac,
4736 &frm,
4737 pFrame + sizeof(tSirMacMgmtHdr),
4738 nPayload, &nPayload);
4739
4740 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004741 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004743 /* FIXME - Need to convert to QDF_STATUS */
4744 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745 goto returnAfterError;
4746 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004747 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 nStatus);
4749 }
4750
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004751 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004752 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004754 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304756 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4757 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004758#endif
4759 ) {
4760 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4761 }
4762
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304763 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304765 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 pPacket,
4767 (uint16_t) nBytes,
4768 TXRX_FRM_802_11_MGMT,
4769 ANI_TXDIR_TODS,
4770 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004771 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304772 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304773 psessionEntry->peSessionId, qdf_status));
4774 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004775 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004776 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 /* Pkt will be freed up by the callback */
4778 return nSirStatus;
4779 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004780 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 }
4782
4783returnAfterError:
4784 cds_packet_free((void *)pPacket);
4785 return nSirStatus;
4786} /* End lim_send_sa_query_response_frame */
4787#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004788
4789/**
4790 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4791 * @mac_ctx: mac context
4792 * @peer_mac: Peer MAC address
4793 * @tid: TID for which addba response is being sent
4794 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004795 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004796 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004797 *
4798 * This function is called when ADDBA request is successful. ADDBA response is
4799 * setup by calling addba_response_setup API and frame is then sent out OTA.
4800 *
4801 * Return: QDF_STATUS
4802 */
4803QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004804 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004805 tpPESession session, uint8_t addba_extn_present,
4806 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004807{
4808
4809 tDot11faddba_rsp frm;
4810 uint8_t *frame_ptr;
4811 tpSirMacMgmtHdr mgmt_hdr;
4812 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004813 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004814 QDF_STATUS qdf_status;
4815 uint8_t tx_flag = 0;
4816 uint8_t sme_sessionid = 0;
4817 uint16_t buff_size, status_code, batimeout;
4818 uint8_t peer_id, dialog_token;
4819 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4820 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004821 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004822
4823 sme_sessionid = session->smeSessionId;
4824
4825 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4826 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004827 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004828 return QDF_STATUS_E_FAILURE;
4829 }
4830
Mohit Khannac4c22252017-11-20 11:06:33 -08004831 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4832 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004833 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004834 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004835 return QDF_STATUS_E_FAILURE;
4836 }
4837
4838 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4839 &status_code, &buff_size, &batimeout);
4840
Mohit Khannac4c22252017-11-20 11:06:33 -08004841 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004842 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4843 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4844 frm.Action.action = SIR_MAC_ADDBA_RSP;
4845
4846 frm.DialogToken.token = dialog_token;
4847 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004848 if (mac_ctx->reject_addba_req) {
4849 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4850 pe_err("refused addba req");
4851 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004852 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004853 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004854 if (mac_ctx->usr_cfg_ba_buff_size)
4855 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004856
4857 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4858 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4859
4860 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4861 if (session->active_ba_64_session) {
4862 frm.addba_param_set.buff_size =
4863 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4864 }
4865 } else if (!session->active_ba_64_session) {
4866 session->active_ba_64_session = true;
4867 }
Arif Hussain0e246802018-05-01 18:13:44 -07004868 if (mac_ctx->is_usr_cfg_amsdu_enabled)
4869 frm.addba_param_set.amsdu_supp = amsdu_support;
4870 else
4871 frm.addba_param_set.amsdu_supp = 0;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004872 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004873 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004874 if (addba_extn_present) {
4875 frm.addba_extn_element.present = 1;
4876 frm.addba_extn_element.no_fragmentation = 1;
4877 if (lim_is_session_he_capable(session)) {
4878 he_frag = lim_get_session_he_frag_cap(session);
4879 if (he_frag != 0) {
4880 frm.addba_extn_element.no_fragmentation = 0;
4881 frm.addba_extn_element.he_frag_operation =
4882 he_frag;
4883 }
4884 }
4885 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004886
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004887 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004888 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004889 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004890 tid, frm.DialogToken.token, frm.Status.status,
4891 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004892 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4893 addba_extn_present,
4894 lim_is_session_he_capable(session),
4895 frm.addba_extn_element.no_fragmentation,
4896 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004897
4898 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4899 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004900 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004901 status);
4902 /* We'll fall back on the worst case scenario: */
4903 payload_size = sizeof(tDot11faddba_rsp);
4904 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004905 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 -08004906 }
4907
4908 num_bytes = payload_size + sizeof(*mgmt_hdr);
4909 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4910 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004911 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004912 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4913 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004914 return QDF_STATUS_E_FAILURE;
4915 }
4916 qdf_mem_set(frame_ptr, num_bytes, 0);
4917
4918 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4919 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4920
4921 /* Update A3 with the BSSID */
4922 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4923 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4924
4925 /* ADDBA Response is a robust mgmt action frame,
4926 * set the "protect" (aka WEP) bit in the FC
4927 */
4928 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4929
4930 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4931 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4932 &payload_size);
4933
4934 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004935 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004936 status);
4937 qdf_status = QDF_STATUS_E_FAILURE;
4938 goto error_addba_rsp;
4939 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004940 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004941 status);
4942 }
4943
4944
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004945 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004946#ifdef WLAN_FEATURE_P2P
4947 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4948 (session->pePersona == QDF_P2P_GO_MODE)
4949#endif
4950 ) {
4951 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4952 }
4953
4954 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4955 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004956 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4957 (uint16_t)num_bytes,
4958 TXRX_FRM_802_11_MGMT,
4959 ANI_TXDIR_TODS, 7,
4960 NULL, frame_ptr,
4961 lim_addba_rsp_tx_complete_cnf,
4962 tx_flag, sme_sessionid,
4963 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004964 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4965 session->peSessionId, qdf_status));
4966 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004967 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004968 qdf_status);
4969 qdf_status = QDF_STATUS_E_FAILURE;
4970 /*
4971 * wma_tx_frame free memory in certain cases, free pkt_ptr
4972 * only if not freed already.
4973 */
4974 if (pkt_ptr)
4975 cds_packet_free((void *)pkt_ptr);
4976 return qdf_status;
4977 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004978 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004979 }
4980
4981error_addba_rsp:
4982 cds_packet_free((void *)pkt_ptr);
4983 return qdf_status;
4984}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304985
4986/**
4987 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4988 * @mac_ctx Pointer to Global MAC structure
4989 * @mb_msg: Received message info
4990 * @msg_len: Received message length
4991 * @packet: Packet to be transmitted
4992 * @frame: Received frame
4993 *
4994 * Return: None
4995 */
4996static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4997 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4998 void *packet, uint8_t *frame)
4999{
5000 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5001 QDF_STATUS qdf_status;
5002 uint8_t sme_session_id = 0;
5003 tpPESession session;
5004 uint16_t auth_ack_status;
5005 enum rateid min_rid = RATEID_DEFAULT;
5006
5007 sme_session_id = mb_msg->session_id;
5008 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
5009 if (session == NULL) {
5010 pe_err("session not found for given sme session");
5011 return;
5012 }
5013
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305014 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5015 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305016
5017 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5018 min_rid = lim_get_min_session_txrate(session);
5019
5020 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5021 (uint16_t)msg_len,
5022 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5023 7, lim_tx_complete, frame,
5024 lim_auth_tx_complete_cnf,
5025 0, sme_session_id, false, 0, min_rid);
5026 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5027 session->peSessionId, qdf_status));
5028 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305029 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5030 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305031 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5032 auth_ack_status = SENT_FAIL;
5033 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005034 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305035 /* Pkt will be freed up by the callback */
5036 }
5037}
5038
5039void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
5040 struct scheduler_msg *msg)
5041{
5042 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5043 uint32_t msg_len;
5044 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5045 uint8_t sme_session_id;
5046 QDF_STATUS qdf_status;
5047 uint8_t *frame;
5048 void *packet;
5049
5050 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5051 pe_debug("sending fc->type: %d fc->subType: %d",
5052 fc->type, fc->subType);
5053
5054 sme_session_id = mb_msg->session_id;
5055
5056 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5057 (void **)&packet);
5058 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5059 pe_err("call to bufAlloc failed for AUTH frame");
5060 return;
5061 }
5062
5063 qdf_mem_copy(frame, mb_msg->data, msg_len);
5064
5065 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5066}