blob: 5e8ce36779c27b3975f67deb7b430608fa1f7fb7 [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);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700483 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700484 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485
486 while (left >= 2) {
487 elem_id = ptr[0];
488 elem_len = ptr[1];
489 left -= 2;
490 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700491 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700494 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 }
496 if (!((SIR_MAC_EID_VENDOR == elem_id) &&
497 (memcmp
498 (&ptr[2], SIR_MAC_P2P_OUI,
499 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530500 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 elem_len + 2);
502 tempLen += (elem_len + 2);
503 }
504 left -= elem_len;
505 ptr += (elem_len + 2);
506 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530507 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700511 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512}
513
514/**
515 * lim_send_probe_rsp_mgmt_frame() - Send probe response
516 *
517 * @mac_ctx: Handle for mac context
518 * @peer_macaddr: Mac address of requesting peer
519 * @ssid: SSID for response
520 * @n_staid: Station ID, currently unused.
521 * @pe_session: PE session id
522 * @keepalive: Keep alive flag. Currently unused.
523 * @preq_p2pie: P2P IE in incoming probe request
524 *
525 * Builds and sends probe response frame to the requesting peer
526 *
527 * Return: void
528 */
529
530void
531lim_send_probe_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
532 tSirMacAddr peer_macaddr,
533 tpAniSSID ssid,
534 short n_staid,
535 uint8_t keepalive,
536 tpPESession pe_session, uint8_t preq_p2pie)
537{
538 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700539 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800540 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 tpSirMacMgmtHdr mac_hdr;
542 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700543 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530544 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 uint32_t addn_ie_present = false;
546
547 uint16_t addn_ie_len = 0;
548 uint32_t wps_ap = 0, tmp;
549 uint8_t tx_flag = 0;
550 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700551 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 uint8_t noalen = 0;
553 uint8_t total_noalen = 0;
554 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
555 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
556 uint8_t sme_sessionid = 0;
557 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530558 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530559 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560
561 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700562 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 return;
564
565 if (NULL == pe_session)
566 return;
567
568 /*
569 * In case when cac timer is running for this SAP session then
570 * avoid sending probe rsp out. It is violation of dfs specification.
571 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530572 if (((pe_session->pePersona == QDF_SAP_MODE) ||
573 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530575 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 FL("CAC timer is running, probe response dropped"));
577 return;
578 }
579 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700581 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 /*
585 * Fill out 'frm', after which we'll just hand the struct off to
586 * 'dot11f_pack_probe_response'.
587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fProbeResponse), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589
590 /*
591 * Timestamp to be updated by TFP, below.
592 *
593 * Beacon Interval:
594 */
595 if (LIM_IS_AP_ROLE(pe_session)) {
596 frm->BeaconInterval.interval =
597 mac_ctx->sch.schObject.gSchBeaconInterval;
598 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530599 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 frm->BeaconInterval.interval = (uint16_t) cfg;
601 }
602
603 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
604 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
605 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
606 &frm->SuppRates, pe_session);
607
608 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
609 pe_session->currentOperChannel);
610 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
611
612 if (LIM_IS_AP_ROLE(pe_session)) {
613 if (pe_session->wps_state != SAP_WPS_DISABLED)
614 populate_dot11f_probe_res_wpsi_es(mac_ctx,
615 &frm->WscProbeRes,
616 pe_session);
617 } else {
618 if (wlan_cfg_get_int(mac_ctx, (uint16_t) WNI_CFG_WPS_ENABLE,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700619 &tmp) != QDF_STATUS_SUCCESS)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700620 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621
622 wps_ap = tmp & WNI_CFG_WPS_ENABLE_AP;
623
624 if (wps_ap)
625 populate_dot11f_wsc_in_probe_res(mac_ctx,
626 &frm->WscProbeRes);
627
628 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
629 eLIM_WSC_ENROLL_BEGIN) {
630 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
631 &frm->WscProbeRes);
632 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
633 eLIM_WSC_ENROLL_IN_PROGRESS;
634 }
635
636 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
637 eLIM_WSC_ENROLL_END) {
638 de_populate_dot11f_wsc_registrar_info_in_probe_res(
639 mac_ctx, &frm->WscProbeRes);
640 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
641 eLIM_WSC_ENROLL_NOOP;
642 }
643 }
644
645 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
646 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
647
648 if (pe_session->dot11mode != WNI_CFG_DOT11_MODE_11B)
649 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
650
651 populate_dot11f_ext_supp_rates(mac_ctx,
652 POPULATE_DOT11F_RATES_OPERATIONAL,
653 &frm->ExtSuppRates, pe_session);
654
655 /* Populate HT IEs, when operating in 11n */
656 if (pe_session->htCapability) {
657 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
658 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700661 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
663 populate_dot11f_vht_operation(mac_ctx, pe_session,
664 &frm->VHTOperation);
665 /*
666 * we do not support multi users yet.
667 * populate_dot11f_vht_ext_bss_load( mac_ctx,
668 * &frm.VHTExtBssLoad );
669 */
670 is_vht_enabled = true;
671 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800673 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700674 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800675 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700676 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800677 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700678 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800679 }
680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
682 pe_session);
683
684 if (pe_session->pLimStartBssReq) {
685 populate_dot11f_wpa(mac_ctx,
686 &(pe_session->pLimStartBssReq->rsnIE),
687 &frm->WPA);
688 populate_dot11f_rsn_opaque(mac_ctx,
689 &(pe_session->pLimStartBssReq->rsnIE),
690 &frm->RSNOpaque);
691 }
692
693 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
694 &frm->WMMCaps, pe_session);
695
696#if defined(FEATURE_WLAN_WAPI)
697 if (pe_session->pLimStartBssReq)
698 populate_dot11f_wapi(mac_ctx,
699 &(pe_session->pLimStartBssReq->rsnIE),
700 &frm->WAPI);
701#endif /* defined(FEATURE_WLAN_WAPI) */
702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703 if (mac_ctx->lim.gpLimRemainOnChanReq)
704 bytes += (mac_ctx->lim.gpLimRemainOnChanReq->length -
705 sizeof(tSirRemainOnChnReq));
706 else
707 /*
708 * Only use CFG for non-listen mode. This CFG is not working for
709 * concurrency. In listening mode, probe rsp IEs is passed in
710 * the message from SME to PE.
711 */
712 addn_ie_present =
713 (pe_session->addIeParams.probeRespDataLen != 0);
714
715 if (addn_ie_present) {
716
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530717 add_ie = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 pe_session->addIeParams.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700719 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530722 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 pe_session->addIeParams.probeRespData_buff,
724 pe_session->addIeParams.probeRespDataLen);
725 addn_ie_len = pe_session->addIeParams.probeRespDataLen;
726
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700727 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700729 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 goto err_ret;
731 }
732
733 sir_status = lim_strip_extcap_update_struct(mac_ctx,
734 add_ie, &addn_ie_len,
735 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700736 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700737 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530738 } else {
739 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 }
741
742 bytes = bytes + addn_ie_len;
743
744 if (preq_p2pie)
745 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
746 addn_ie_len);
747
748 if (p2p_ie != NULL) {
749 /* get NoA attribute stream P2P IE */
750 noalen = lim_get_noa_attr_stream(mac_ctx,
751 noa_stream, pe_session);
752 if (noalen != 0) {
753 total_noalen =
754 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
755 &noa_stream[0], noalen);
756 bytes = bytes + total_noalen;
757 }
758 }
759 }
760
Hu Wang411e0cc2016-10-28 14:56:01 +0800761 /*
762 * Extcap IE now support variable length, merge Extcap IE from addn_ie
763 * may change the frame size. Therefore, MUST merge ExtCap IE before
764 * dot11f get packed payload size.
765 */
766 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800767 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
768 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800769
770 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
771 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700772 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800773 status);
774 /* We'll fall back on the worst case scenario: */
775 payload = sizeof(tDot11fProbeResponse);
776 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700777 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800778 status);
779 }
780
781 bytes += payload + sizeof(tSirMacMgmtHdr);
782
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530783 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530785 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700786 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 goto err_ret;
788 }
789 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530790 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
792 /* Next, we fill out the buffer descriptor: */
793 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
794 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
795 pe_session->selfMacAddr);
796
797 mac_hdr = (tpSirMacMgmtHdr) frame;
798
799 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 /* That done, pack the Probe Response: */
802 status =
803 dot11f_pack_probe_response(mac_ctx, frm,
804 frame + sizeof(tSirMacMgmtHdr),
805 payload, &payload);
806 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700807 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 status);
809 goto err_ret;
810 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700811 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 }
813
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700814 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530815 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 if (mac_ctx->lim.gpLimRemainOnChanReq)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530818 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 mac_ctx->lim.gpLimRemainOnChanReq->probeRspIe,
820 (mac_ctx->lim.gpLimRemainOnChanReq->length -
821 sizeof(tSirRemainOnChnReq)));
822
823 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 &add_ie[0], addn_ie_len);
826
827 if (noalen != 0) {
828 if (total_noalen >
829 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700830 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 total_noalen);
832 goto err_ret;
833 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530834 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 &noa_ie[0], total_noalen);
836 }
837 }
838
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800839 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530840 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
841 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 )
843 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
844
845 /* Queue Probe Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530846 qdf_status = wma_tx_frame((tHalHandle) mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 (uint16_t) bytes,
848 TXRX_FRM_802_11_MGMT,
849 ANI_TXDIR_TODS,
850 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -0700851 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852
853 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530854 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700855 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856
857 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530858 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530860 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 return;
862
863err_ret:
864 if (add_ie != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530865 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 if (frm != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530867 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 if (packet != NULL)
869 cds_packet_free((void *)packet);
870 return;
871
872} /* End lim_send_probe_rsp_mgmt_frame. */
873
874void
875lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
876 tSirMacAddr peerMacAddr,
877 tSirAddtsReqInfo *pAddTS, tpPESession psessionEntry)
878{
879 uint16_t i;
880 uint8_t *pFrame;
881 tDot11fAddTSRequest AddTSReq;
882 tDot11fWMMAddTSRequest WMMAddTSReq;
883 uint32_t nPayload, nBytes, nStatus;
884 tpSirMacMgmtHdr pMacHdr;
885 void *pPacket;
886#ifdef FEATURE_WLAN_ESE
887 uint32_t phyMode;
888#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530889 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 uint8_t txFlag = 0;
891 uint8_t smeSessionId = 0;
892
893 if (NULL == psessionEntry) {
894 return;
895 }
896
897 smeSessionId = psessionEntry->smeSessionId;
898
899 if (!pAddTS->wmeTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530900 qdf_mem_set((uint8_t *) &AddTSReq, sizeof(AddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901
902 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
903 AddTSReq.DialogToken.token = pAddTS->dialogToken;
904 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
905 if (pAddTS->lleTspecPresent) {
906 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
907 } else {
908 populate_dot11f_wmmtspec(&pAddTS->tspec,
909 &AddTSReq.WMMTSPEC);
910 }
911
912 if (pAddTS->lleTspecPresent) {
913 AddTSReq.num_WMMTCLAS = 0;
914 AddTSReq.num_TCLAS = pAddTS->numTclas;
915 for (i = 0; i < pAddTS->numTclas; ++i) {
916 populate_dot11f_tclas(pMac, &pAddTS->tclasInfo[i],
917 &AddTSReq.TCLAS[i]);
918 }
919 } else {
920 AddTSReq.num_TCLAS = 0;
921 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
922 for (i = 0; i < pAddTS->numTclas; ++i) {
923 populate_dot11f_wmmtclas(pMac,
924 &pAddTS->tclasInfo[i],
925 &AddTSReq.WMMTCLAS[i]);
926 }
927 }
928
929 if (pAddTS->tclasProcPresent) {
930 if (pAddTS->lleTspecPresent) {
931 AddTSReq.TCLASSPROC.processing =
932 pAddTS->tclasProc;
933 AddTSReq.TCLASSPROC.present = 1;
934 } else {
935 AddTSReq.WMMTCLASPROC.version = 1;
936 AddTSReq.WMMTCLASPROC.processing =
937 pAddTS->tclasProc;
938 AddTSReq.WMMTCLASPROC.present = 1;
939 }
940 }
941
942 nStatus =
943 dot11f_get_packed_add_ts_request_size(pMac, &AddTSReq, &nPayload);
944 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700945 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
946 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 /* We'll fall back on the worst case scenario: */
948 nPayload = sizeof(tDot11fAddTSRequest);
949 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700950 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
951 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 }
953 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530954 qdf_mem_set((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
956 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
957 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
958 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
959
960 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
961 WMMAddTSReq.StatusCode.statusCode = 0;
962
963 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
964#ifdef FEATURE_WLAN_ESE
965 lim_get_phy_mode(pMac, &phyMode, psessionEntry);
966
967 if (phyMode == WNI_CFG_PHY_MODE_11G
968 || phyMode == WNI_CFG_PHY_MODE_11A) {
969 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
970 } else {
971 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
972 }
973 populate_dot11_tsrsie(pMac, &pAddTS->tsrsIE,
974 &WMMAddTSReq.ESETrafStrmRateSet,
975 sizeof(uint8_t));
976#endif
977 /* fillWmeTspecIE */
978
979 nStatus =
980 dot11f_get_packed_wmm_add_ts_request_size(pMac, &WMMAddTSReq,
981 &nPayload);
982 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700983 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 nStatus);
985 /* We'll fall back on the worst case scenario: */
986 nPayload = sizeof(tDot11fAddTSRequest);
987 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700988 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
989 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 }
991 }
992
993 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
994
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530995 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530997 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700998 pe_err("Failed to allocate %d bytes for an Add TS Request",
999 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 return;
1001 }
1002 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004
1005 /* Next, we fill out the buffer descriptor: */
1006 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1007 SIR_MAC_MGMT_ACTION, peerMacAddr, psessionEntry->selfMacAddr);
1008 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1009
1010 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1011
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 lim_set_protected_bit(pMac, psessionEntry, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
1014 /* That done, pack the struct: */
1015 if (!pAddTS->wmeTspecPresent) {
1016 nStatus = dot11f_pack_add_ts_request(pMac, &AddTSReq,
1017 pFrame +
1018 sizeof(tSirMacMgmtHdr),
1019 nPayload, &nPayload);
1020 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001021 pe_err("Failed to pack an Add TS Request "
1022 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 cds_packet_free((void *)pPacket);
1024 return; /* allocated! */
1025 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001026 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
1027 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 }
1029 } else {
1030 nStatus = dot11f_pack_wmm_add_ts_request(pMac, &WMMAddTSReq,
1031 pFrame +
1032 sizeof(tSirMacMgmtHdr),
1033 nPayload, &nPayload);
1034 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001035 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
1036 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 cds_packet_free((void *)pPacket);
1038 return; /* allocated! */
1039 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001040 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
1041 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 }
1043 }
1044
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001045 pe_debug("Sending an Add TS Request frame to");
1046 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001048 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301050 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1051 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 ) {
1053 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1054 }
1055
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301056 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001058 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001059 psessionEntry, QDF_STATUS_SUCCESS,
1060 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061
1062 /* Queue Addts Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301063 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 TXRX_FRM_802_11_MGMT,
1065 ANI_TXDIR_TODS,
1066 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001067 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301068 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301069 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001071 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1072 pe_err("Could not send an Add TS Request (%X",
1073 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074} /* End lim_send_addts_req_action_frame. */
1075
1076/**
1077 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1078 * @mac_ctx: Handle for mac context
1079 * @status_code: Status code for assoc response frame
1080 * @aid: Association ID
1081 * @peer_addr: Mac address of requesting peer
1082 * @subtype: Assoc/Reassoc
1083 * @sta: Pointer to station node
1084 * @pe_session: PE session id.
1085 *
1086 * Builds and sends association response frame to the requesting peer.
1087 *
1088 * Return: void
1089 */
1090
1091void
1092lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
1093 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
1094 uint8_t subtype, tpDphHashNode sta, tpPESession pe_session)
1095{
1096 static tDot11fAssocResponse frm;
1097 uint8_t *frame;
1098 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001099 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100 uint8_t lle_mode = 0, addts;
1101 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001102 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301104 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 tUpdateBeaconParams beacon_params;
1106 uint8_t tx_flag = 0;
1107 uint32_t addn_ie_len = 0;
1108 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1109 tpSirAssocReq assoc_req = NULL;
1110 uint8_t sme_session = 0;
1111 bool is_vht = false;
1112 uint16_t stripoff_len = 0;
1113 tDot11fIEExtCap extracted_ext_cap;
1114 bool extracted_flag = false;
1115#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301116 uint8_t retry_int;
1117 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118#endif
1119
1120 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001121 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 return;
1123 }
1124
1125 sme_session = pe_session->smeSessionId;
1126
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301127 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128
1129 limGetQosMode(pe_session, &qos_mode);
1130 limGetWmeMode(pe_session, &wme_mode);
1131
1132 /*
1133 * An Add TS IE is added only if the AP supports it and
1134 * the requesting STA sent a traffic spec.
1135 */
1136 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1137
1138 frm.Status.status = status_code;
1139
1140 frm.AID.associd = aid | LIM_AID_MASK;
1141
1142 if (NULL == sta) {
1143 populate_dot11f_supp_rates(mac_ctx,
1144 POPULATE_DOT11F_RATES_OPERATIONAL,
1145 &frm.SuppRates, pe_session);
1146 populate_dot11f_ext_supp_rates(mac_ctx,
1147 POPULATE_DOT11F_RATES_OPERATIONAL,
1148 &frm.ExtSuppRates, pe_session);
1149 } else {
1150 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1151 &frm.ExtSuppRates,
1152 sta->supportedRates.llbRates,
1153 sta->supportedRates.llaRates);
1154 }
1155
1156 if (LIM_IS_AP_ROLE(pe_session) && sta != NULL &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001157 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 assoc_req = (tpSirAssocReq)
1159 pe_session->parsedAssocReq[sta->assocId];
1160 /*
1161 * populate P2P IE in AssocRsp when assocReq from the peer
1162 * includes P2P IE
1163 */
1164 if (assoc_req != NULL && assoc_req->addIEPresent)
1165 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1166 &frm.P2PAssocRes,
1167 assoc_req);
1168 }
1169
1170 if (NULL != sta) {
1171 if (eHAL_SET == qos_mode) {
1172 if (sta->lleEnabled) {
1173 lle_mode = 1;
1174 populate_dot11f_edca_param_set(mac_ctx,
1175 &frm.EDCAParamSet, pe_session);
1176 }
1177 }
1178
1179 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1180 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1181 pe_session);
1182
1183 if (sta->wsmEnabled)
1184 populate_dot11f_wmm_caps(&frm.WMMCaps);
1185 }
1186
1187 if (sta->mlmStaContext.htCapability &&
1188 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001189 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 populate_dot11f_ht_caps(mac_ctx, pe_session,
1191 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001192 /*
1193 * Check the STA capability and
1194 * update the HTCaps accordingly
1195 */
1196 frm.HTCaps.supportedChannelWidthSet = (
1197 sta->htSupportedChannelWidthSet <
1198 pe_session->htSupportedChannelWidthSet) ?
1199 sta->htSupportedChannelWidthSet :
1200 pe_session->htSupportedChannelWidthSet;
1201 if (!frm.HTCaps.supportedChannelWidthSet)
1202 frm.HTCaps.shortGI40MHz = 0;
1203
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1205 pe_session);
1206 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001207 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 +05301208 frm.HTCaps.supportedChannelWidthSet,
1209 frm.HTCaps.mimoPowerSave,
1210 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1211 frm.HTCaps.shortGI40MHz,
1212 frm.HTCaps.dsssCckMode40MHz,
1213 frm.HTCaps.maxRxAMPDUFactor);
1214
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 if (sta->mlmStaContext.vhtCapability &&
1216 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001217 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 populate_dot11f_vht_caps(mac_ctx, pe_session,
1219 &frm.VHTCaps);
1220 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301221 &frm.VHTOperation);
1222 is_vht = true;
1223 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001224
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301225 if (pe_session->vhtCapability &&
1226 pe_session->vendor_vht_sap &&
1227 (assoc_req != NULL) &&
1228 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001229 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301230 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001231 frm.vendor_vht_ie.sub_type =
1232 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301233 frm.vendor_vht_ie.VHTCaps.present = 1;
1234 populate_dot11f_vht_caps(mac_ctx, pe_session,
1235 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001236 populate_dot11f_vht_operation(mac_ctx, pe_session,
1237 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 is_vht = true;
1239 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1241 pe_session);
1242
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001243 if (lim_is_sta_he_capable(sta) &&
1244 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001245 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001246 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001247 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001248 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001249 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001250 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251#ifdef WLAN_FEATURE_11W
1252 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301253 max_retries =
1254 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1255 retry_int =
1256 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1257 populate_dot11f_timeout_interval(mac_ctx,
1258 &frm.TimeoutInterval,
1259 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1260 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 sta->pmfSaQueryRetryCount)
1262 * retry_int);
1263 }
1264#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001265
1266 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1267 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 }
1269
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301270 qdf_mem_set((uint8_t *) &beacon_params, sizeof(beacon_params), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271
1272 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301273 (pe_session->gLimProtectionControl !=
1274 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1275 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1276 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277
1278 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1279 pe_session);
1280 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1281 pe_session);
1282
1283 /*
1284 * Populate Do11capabilities after updating session with
1285 * Assos req details
1286 */
1287 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1288
1289 beacon_params.bssIdx = pe_session->bssIdx;
1290
1291 /* Send message to HAL about beacon parameter change. */
1292 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1293 && beacon_params.paramChangeBitmap) {
1294 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1295 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1296 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297
Arif Hussain1513cb22018-01-05 19:56:31 -08001298 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 if (assoc_req != NULL) {
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001301 addn_ie_len = pe_session->addIeParams.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302
1303 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001304 if (addn_ie_len > 0 &&
1305 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1306 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 qdf_mem_copy(add_ie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 pe_session->addIeParams.assocRespData_buff,
1309 pe_session->addIeParams.assocRespDataLen);
1310
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301311 qdf_mem_set((uint8_t *) &extracted_ext_cap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 sizeof(extracted_ext_cap), 0);
1313
1314 stripoff_len = addn_ie_len;
1315 sir_status =
1316 lim_strip_extcap_update_struct
1317 (mac_ctx, &add_ie[0], &stripoff_len,
1318 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001319 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001320 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 } else {
1322 addn_ie_len = stripoff_len;
1323 extracted_flag = true;
1324 }
1325 bytes = bytes + addn_ie_len;
1326 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001327 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 addn_ie_len, assoc_req->addIEPresent);
1329 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001330
1331 /*
1332 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1333 * may change the frame size. Therefore, MUST merge ExtCap IE before
1334 * dot11f get packed payload size.
1335 */
1336 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001337 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1338 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001339
1340 /* Allocate a buffer for this frame: */
1341 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1342 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001343 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001344 status);
1345 return;
1346 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001347 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001348 status);
1349 }
1350
1351 bytes += sizeof(tSirMacMgmtHdr) + payload;
1352
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301353 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301355 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001356 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 return;
1358 }
1359 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301360 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361
1362 /* Next, we fill out the buffer descriptor: */
1363 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1364 (LIM_ASSOC == subtype) ?
1365 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1366 peer_addr,
1367 pe_session->selfMacAddr);
1368 mac_hdr = (tpSirMacMgmtHdr) frame;
1369
1370 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1371
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1373 frame + sizeof(tSirMacMgmtHdr),
1374 payload, &payload);
1375 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001376 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 status);
1378 cds_packet_free((void *)packet);
1379 return;
1380 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001381 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 status);
1383 }
1384
1385 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001386 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 status_code, aid);
1388 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001389 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 status_code, aid);
1391
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301392 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393
1394 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301395 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 &add_ie[0], addn_ie_len);
1397
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001398 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301400 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1401 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1403
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301404 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001406 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001407 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301409 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 TXRX_FRM_802_11_MGMT,
1411 ANI_TXDIR_TODS,
1412 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001413 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301414 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301415 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416
1417 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301418 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001419 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301420 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
1422 /*
1423 * update the ANI peer station count.
1424 * FIXME_PROTECTION : take care of different type of station
1425 * counter inside this function.
1426 */
1427 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1428
1429}
1430
1431void
1432lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
1433 tSirMacAddr peer,
1434 uint8_t wmmTspecPresent,
1435 tSirMacTSInfo *pTsinfo,
1436 tSirMacTspecIE *pTspecIe, tpPESession psessionEntry)
1437{
1438 uint8_t *pFrame;
1439 tpSirMacMgmtHdr pMacHdr;
1440 tDot11fDelTS DelTS;
1441 tDot11fWMMDelTS WMMDelTS;
1442 uint32_t nBytes, nPayload, nStatus;
1443 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301444 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 uint8_t txFlag = 0;
1446 uint8_t smeSessionId = 0;
1447
1448 if (NULL == psessionEntry) {
1449 return;
1450 }
1451
1452 smeSessionId = psessionEntry->smeSessionId;
1453
1454 if (!wmmTspecPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301455 qdf_mem_set((uint8_t *) &DelTS, sizeof(DelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456
1457 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1458 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1459 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1460
1461 nStatus = dot11f_get_packed_del_ts_size(pMac, &DelTS, &nPayload);
1462 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 /* We'll fall back on the worst case scenario: */
1465 nPayload = sizeof(tDot11fDelTS);
1466 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001467 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1468 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 }
1470 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301471 qdf_mem_set((uint8_t *) &WMMDelTS, sizeof(WMMDelTS), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472
1473 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1474 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1475 WMMDelTS.DialogToken.token = 0;
1476 WMMDelTS.StatusCode.statusCode = 0;
1477 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1478 nStatus =
1479 dot11f_get_packed_wmm_del_ts_size(pMac, &WMMDelTS, &nPayload);
1480 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001481 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 /* We'll fall back on the worst case scenario: */
1483 nPayload = sizeof(tDot11fDelTS);
1484 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001485 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1486 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 }
1488 }
1489
1490 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301492 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1494 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301495 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001496 pe_err("Failed to allocate %d bytes for an Add TS Response",
1497 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 return;
1499 }
1500 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301501 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502
1503 /* Next, we fill out the buffer descriptor: */
1504 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
1505 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
1506 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1507
1508 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
1509
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511
1512 /* That done, pack the struct: */
1513 if (!wmmTspecPresent) {
1514 nStatus = dot11f_pack_del_ts(pMac, &DelTS,
1515 pFrame + sizeof(tSirMacMgmtHdr),
1516 nPayload, &nPayload);
1517 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001518 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 nStatus);
1520 cds_packet_free((void *)pPacket);
1521 return; /* allocated! */
1522 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001523 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1524 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 }
1526 } else {
1527 nStatus = dot11f_pack_wmm_del_ts(pMac, &WMMDelTS,
1528 pFrame + sizeof(tSirMacMgmtHdr),
1529 nPayload, &nPayload);
1530 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001531 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 nStatus);
1533 cds_packet_free((void *)pPacket);
1534 return; /* allocated! */
1535 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001536 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1537 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 }
1539 }
1540
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001541 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
1542 lim_print_mac_addr(pMac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001544 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05301546 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE)
1547 || (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 ) {
1549 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1550 }
1551
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301552 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 psessionEntry->peSessionId, pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001554 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001555 psessionEntry, QDF_STATUS_SUCCESS,
1556 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301557 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 TXRX_FRM_802_11_MGMT,
1559 ANI_TXDIR_TODS,
1560 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001561 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301562 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301563 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301565 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001566 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567
1568} /* End lim_send_delts_req_action_frame. */
1569
1570/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301571 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1572 * @context: pointer to global mac
1573 * @buf: buffer
1574 * @tx_complete : Sent status
1575 * @params; tx completion params
1576 *
1577 * Return: This returns QDF_STATUS
1578 */
1579
1580static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1581 qdf_nbuf_t buf,
1582 uint32_t tx_complete,
1583 void *params)
1584{
1585 uint16_t assoc_ack_status;
1586 uint16_t reason_code;
1587 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
1588
1589 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001590 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301591 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001592 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301593 } else {
1594 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001595 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301596 }
1597 if (buf)
1598 qdf_nbuf_free(buf);
1599
1600 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1601 NULL, assoc_ack_status, reason_code);
1602 return QDF_STATUS_SUCCESS;
1603}
1604
1605/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 * lim_send_assoc_req_mgmt_frame() - Send association request
1607 * @mac_ctx: Handle to MAC context
1608 * @mlm_assoc_req: Association request information
1609 * @pe_session: PE session information
1610 *
1611 * Builds and transmits association request frame to AP.
1612 *
1613 * Return: Void
1614 */
1615
1616void
1617lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
1618 tLimMlmAssocReq *mlm_assoc_req,
1619 tpPESession pe_session)
1620{
Naveen Rawat72475db2017-12-13 18:07:35 -08001621 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 tDot11fAssocRequest *frm;
1623 uint16_t caps;
1624 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001625 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001627 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1629 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301630 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 uint16_t add_ie_len;
1632 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001633 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 uint8_t tx_flag = 0;
1636 uint8_t sme_sessionid = 0;
1637 bool vht_enabled = false;
1638 tDot11fIEExtCap extr_ext_cap;
1639 bool extr_ext_flag = true;
1640 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001641 uint32_t ie_offset = 0;
1642 uint8_t *p_ext_cap = NULL;
1643 tDot11fIEExtCap bcn_ext_cap;
1644 uint8_t *bcn_ie = NULL;
1645 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301646 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001647 enum rateid min_rid = RATEID_DEFAULT;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301648 uint8_t *mbo_ie = NULL;
1649 uint8_t mbo_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650
1651 if (NULL == pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001652 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301653 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 return;
1655 }
1656
1657 sme_sessionid = pe_session->smeSessionId;
1658
1659 /* check this early to avoid unncessary operation */
1660 if (NULL == pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001661 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301662 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 return;
1664 }
1665 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1666 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1667
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301668 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001669 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301670 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 return;
1672 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001673 qdf_mem_set((uint8_t *) frm, sizeof(tDot11fAssocRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301675 if (add_ie_len && pe_session->is_ext_caps_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301676 qdf_mem_set((uint8_t *) &extr_ext_cap, sizeof(tDot11fIEExtCap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 0);
1678 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1679 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001680 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001682 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 } else {
1684 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1685 extr_ext_cap.bytes;
1686
1687 if (p_ext_cap->interworking_service)
1688 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001689 extr_ext_cap.num_bytes =
1690 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1691 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 }
1693 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001694 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 extr_ext_flag = false;
1696 }
1697
1698 caps = mlm_assoc_req->capabilityInfo;
1699#if defined(FEATURE_WLAN_WAPI)
1700 /*
1701 * According to WAPI standard:
1702 * 7.3.1.4 Capability Information field
1703 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1704 * in transmitted Association or Reassociation management frames.
1705 * APs ignore the Privacy subfield within received Association and
1706 * Reassociation management frames.
1707 */
1708 if (pe_session->encryptType == eSIR_ED_WPI)
1709 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1710#endif
1711 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1712
1713 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1714 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1715 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1716 &frm->SuppRates, pe_session);
1717
1718 qos_enabled = (pe_session->limQosEnabled) &&
1719 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1720
1721 wme_enabled = (pe_session->limWmeEnabled) &&
1722 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1723
1724 /* We prefer .11e asociations: */
1725 if (qos_enabled)
1726 wme_enabled = false;
1727
1728 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1729 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1730
1731 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001732 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 power_caps = true;
1734
1735 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1736 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1738 LIM_ASSOC, pe_session);
1739
1740 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1742 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1743 if (power_caps == false) {
1744 power_caps = true;
1745 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1746 LIM_ASSOC, pe_session);
1747 }
1748 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001750 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1751 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752
1753 populate_dot11f_ext_supp_rates(mac_ctx,
1754 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1755 pe_session);
1756
Gupta, Kapil54a16992016-01-13 19:34:02 +05301757 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1758 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1760 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 /*
1763 * The join request *should* contain zero or one of the WPA and RSN
1764 * IEs. The payload send along with the request is a
1765 * 'tSirSmeJoinReq'; the IE portion is held inside a 'tSirRSNie':
1766 * typedef struct sSirRSNie
1767 * {
1768 * uint16_t length;
1769 * uint8_t rsnIEdata[SIR_MAC_MAX_IE_LENGTH+2];
1770 * } tSirRSNie, *tpSirRSNie;
1771 * So, we should be able to make the following two calls harmlessly,
1772 * since they do nothing if they don't find the given IE in the
1773 * bytestream with which they're provided.
1774 * The net effect of this will be to faithfully transmit whatever
1775 * security IE is in the join request.
1776 * However, if we're associating for the purpose of WPS
1777 * enrollment, and we've been configured to indicate that by
1778 * eliding the WPA or RSN IE, we just skip this:
1779 */
1780 if (add_ie_len && add_ie)
1781 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1782
1783 if (NULL == wps_ie) {
1784 populate_dot11f_rsn_opaque(mac_ctx,
1785 &(pe_session->pLimJoinReq->rsnIE),
1786 &frm->RSNOpaque);
1787 populate_dot11f_wpa_opaque(mac_ctx,
1788 &(pe_session->pLimJoinReq->rsnIE),
1789 &frm->WPAOpaque);
1790#if defined(FEATURE_WLAN_WAPI)
1791 populate_dot11f_wapi_opaque(mac_ctx,
1792 &(pe_session->pLimJoinReq->rsnIE),
1793 &frm->WAPIOpaque);
1794#endif /* defined(FEATURE_WLAN_WAPI) */
1795 }
1796 /* include WME EDCA IE as well */
1797 if (wme_enabled) {
1798 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1799 pe_session, &frm->WMMInfoStation);
1800
1801 if (wsm_enabled)
1802 populate_dot11f_wmm_caps(&frm->WMMCaps);
1803 }
1804
1805 /*
1806 * Populate HT IEs, when operating in 11n and
1807 * when AP is also operating in 11n mode
1808 */
1809 if (pe_session->htCapability &&
1810 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001811 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001813 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1814 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001815 } else if (pe_session->he_with_wep_tkip) {
1816 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1817 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001819 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 +05301820 frm->HTCaps.supportedChannelWidthSet,
1821 frm->HTCaps.mimoPowerSave,
1822 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1823 frm->HTCaps.shortGI40MHz,
1824 frm->HTCaps.dsssCckMode40MHz,
1825 frm->HTCaps.maxRxAMPDUFactor);
1826
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 if (pe_session->vhtCapability &&
1828 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001829 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001831 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1832 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001834 if (pe_session->enableHtSmps &&
1835 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001836 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001837 populate_dot11f_operating_mode(mac_ctx,
1838 &frm->OperatingMode, pe_session);
1839 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001840 } else if (pe_session->he_with_wep_tkip) {
1841 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1842 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 if (!vht_enabled &&
1846 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001847 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301848 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001849 frm->vendor_vht_ie.sub_type =
1850 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301851 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301852 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301853 pe_session->vht_config.su_beam_formee) {
1854 pe_debug("Disable SU beamformee for vendor IE");
1855 pe_session->vht_config.su_beam_formee = 0;
1856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301858 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 vht_enabled = true;
1860 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301861 if (pe_session->is_ext_caps_present)
1862 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1863 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Wu Gao93816212018-08-31 16:49:54 +08001865 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301866 populate_dot11f_qcn_ie(&frm->QCN_IE);
1867
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001868 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001869 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001870 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001871 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001872 } else if (pe_session->he_with_wep_tkip) {
1873 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1874 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001875 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 tSirBssDescription *bssdescr;
1879
1880 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001881 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 (unsigned int) bssdescr->mdie[0],
1883 (unsigned int) bssdescr->mdie[1],
1884 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 populate_mdie(mac_ctx, &frm->MobilityDomain,
1886 pe_session->pLimJoinReq->bssDescription.mdie);
1887 } else {
1888 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001889 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891
1892#ifdef FEATURE_WLAN_ESE
1893 /*
1894 * ESE Version IE will be included in association request
1895 * when ESE is enabled on DUT through ini and it is also
1896 * advertised by the peer AP to which we are trying to
1897 * associate to.
1898 */
1899 if (pe_session->is_ese_version_ie_present &&
1900 mac_ctx->roam.configParam.isEseIniFeatureEnabled)
1901 populate_dot11f_ese_version(&frm->ESEVersion);
1902 /* For ESE Associations fill the ESE IEs */
1903 if (pe_session->isESEconnection &&
1904 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1905#ifndef FEATURE_DISABLE_RM
1906 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1907#endif
1908 }
1909#endif
1910
Hu Wang411e0cc2016-10-28 14:56:01 +08001911 /*
1912 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1913 * may change the frame size. Therefore, MUST merge ExtCap IE before
1914 * dot11f get packed payload size.
1915 */
1916 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001917 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1918
1919 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1920 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1921 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1922 DOT11F_FF_BEACONINTERVAL_LEN +
1923 DOT11F_FF_CAPABILITIES_LEN;
1924
1925 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1926 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1927 bcn_ie = pe_session->beacon + ie_offset;
1928 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001929 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001930 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001931 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001932 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1933 &bcn_ext_cap);
1934 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1935 false);
1936 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001937 /*
1938 * TWT extended capabilities should be populated after the
1939 * intersection of beacon caps and self caps is done because
1940 * the bits for TWT are unique to STA and AP and cannot be
1941 * intersected.
1942 */
1943 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1944 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001945 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001946
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001947 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001948 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001949 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001950
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301951 if (lim_is_fils_connection(pe_session)) {
1952 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1953 aes_block_size_len = AES_BLOCK_SIZE;
1954 }
1955
1956 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301957 * MBO IE needs to be appendded at the end of the assoc request
1958 * frame and is not parsed and unpacked by the frame parser
1959 * as the supplicant can send multiple TLVs with same Attribute
1960 * in the MBO IE and the frame parser does not support multiple
1961 * TLVs with same attribute in a single IE.
1962 * Strip off the MBO IE from add_ie and append it at the end.
1963 */
1964 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
1965 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
1966 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001967 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301968 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301969
1970 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
1971 SIR_MAC_EID_VENDOR, ONE_BYTE,
1972 SIR_MAC_MBO_OUI,
1973 SIR_MAC_MBO_OUI_SIZE,
1974 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
1975 if (QDF_IS_STATUS_ERROR(qdf_status)) {
1976 pe_err("Failed to strip MBO IE");
1977 goto free_mbo_ie;
1978 }
1979
1980 /* Include the EID and length fields */
1981 mbo_ie_len = mbo_ie[1] + 2;
1982 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
1983 }
1984
1985 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301986 * Do unpack to populate the add_ie buffer to frm structure
1987 * before packing the frm structure. In this way, the IE ordering
1988 * which the latest 802.11 spec mandates is maintained.
1989 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001990 if (add_ie_len) {
1991 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301992 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001993 if (DOT11F_FAILED(ret)) {
1994 pe_err("unpack failed, ret: 0x%x", ret);
1995 goto end;
1996 }
1997 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301998
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2000 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002001 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 status);
2003 /* We'll fall back on the worst case scenario: */
2004 payload = sizeof(tDot11fAssocRequest);
2005 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002006 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 status);
2008 }
2009
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302010 bytes = payload + sizeof(tSirMacMgmtHdr) +
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302011 aes_block_size_len + mbo_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302013 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002016 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017
2018 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302019 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 pe_session->peSessionId,
2021 pe_session->limMlmState));
2022
2023 /* Update PE session id */
2024 assoc_cnf.sessionId = pe_session->peSessionId;
2025
2026 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2029 (uint32_t *) &assoc_cnf);
2030
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302031 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 }
2033 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302034 qdf_mem_set(frame, bytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035
2036 /* Next, we fill out the buffer descriptor: */
2037 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2038 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
2039 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 /* That done, pack the Assoc Request: */
2041 status = dot11f_pack_assoc_request(mac_ctx, frm,
2042 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2043 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002044 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302046 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002048 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302051 /* Copy the MBO IE to the end of the frame */
2052 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2053 mbo_ie, mbo_ie_len);
2054 payload = payload + mbo_ie_len;
2055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 if (pe_session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302057 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002059 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 }
2061
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302062 if (lim_is_fils_connection(pe_session)) {
2063 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2064 frame, &payload);
2065 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2066 cds_packet_free((void *)packet);
2067 qdf_mem_free(frm);
2068 return;
2069 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 }
2071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302072 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002073 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 /*
2075 * Store the Assoc request. This is sent to csr/hdd in
2076 * join cnf response.
2077 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302078 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002079 frame + sizeof(tSirMacMgmtHdr), payload);
2080 pe_session->assocReqLen = payload;
2081 }
2082
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002083 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302084 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2085 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 )
2087 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2088
Anurag Chouhan6d760662016-02-20 16:05:43 +05302089 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2090 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302094 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302096
2097 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002098 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002099 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002100 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002101 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002102 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302103 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302104 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2106 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302107 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002108 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302109 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302110 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302111 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002112
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302113 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002114 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302115 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302116 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002117 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302120free_mbo_ie:
2121 if (mbo_ie)
2122 qdf_mem_free(mbo_ie);
2123
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302124end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302126 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302128 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 return;
2130}
2131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002133 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2134 * @context: pointer to global mac
2135 * @buf: buffer which is nothing but entire ADD BA frame
2136 * @tx_complete : Sent status
2137 * @params; tx completion params
2138 *
2139 * Return: This returns QDF_STATUS
2140 */
2141static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2142 qdf_nbuf_t buf,
2143 uint32_t tx_complete,
2144 void *params)
2145{
2146 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2147 tSirMacMgmtHdr *mac_hdr;
2148 tDot11faddba_rsp rsp;
2149 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2150 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2151 uint8_t peer_id;
2152 void *peer;
2153 uint32_t frame_len;
2154 QDF_STATUS status;
2155 uint8_t *data;
2156
2157 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2158 pe_debug("Add ba response successfully sent");
2159 else
2160 pe_debug("Fail to send add ba response");
2161
2162 if (!buf) {
2163 pe_err("Addba response frame buffer is NULL");
2164 return QDF_STATUS_E_FAILURE;
2165 }
2166
2167 data = qdf_nbuf_data(buf);
2168
2169 if (!data) {
2170 pe_err("Addba response frame is NULL");
2171 return QDF_STATUS_E_FAILURE;
2172 }
2173
2174 mac_hdr = (tSirMacMgmtHdr *)data;
2175 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2176 frame_len = sizeof(rsp);
2177 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2178 sizeof(*mac_hdr), frame_len,
2179 &rsp, false);
2180
2181 if (DOT11F_FAILED(status)) {
2182 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2183 status, frame_len);
2184 goto error;
2185 }
2186
2187 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2188 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2189 if (!peer) {
2190 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2191 goto error;
2192 }
2193 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2194 tx_complete);
2195 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2196error:
2197 if (buf)
2198 qdf_nbuf_free(buf);
2199
2200 return QDF_STATUS_SUCCESS;
2201}
2202
2203/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302204 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302205 * @context: pointer to global mac
2206 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302207 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302208 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302209 *
2210 * Return: This returns QDF_STATUS
2211 */
2212
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302213static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2214 qdf_nbuf_t buf,
2215 uint32_t tx_complete,
2216 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302217{
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302218 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302219 uint16_t auth_ack_status;
2220 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302221
Naveen Rawat684e8b12017-09-20 15:54:44 -07002222 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002223 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2224 "success" : "fail");
2225 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302226 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302227 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002228 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302229 /* 'Change' timer for future activations */
2230 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2231 } else {
2232 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302233 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002234 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302235 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302236
2237 if (buf)
2238 qdf_nbuf_free(buf);
2239
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302240 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2241 NULL, auth_ack_status, reason_code);
2242
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302243 return QDF_STATUS_SUCCESS;
2244}
2245
2246/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2248 *
2249 * @mac_ctx: Pointer to Global MAC structure
2250 * @auth_frame: Pointer to Authentication frame structure
2251 * @peer_addr: MAC address of destination peer
2252 * @wep_bit: wep bit in frame control for Authentication frame3
2253 * @session: PE session information
2254 *
2255 * This function is called by lim_process_mlm_messages(). Authentication frame
2256 * is formatted and sent when this function is called.
2257 *
2258 * Return: void
2259 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260void
2261lim_send_auth_mgmt_frame(tpAniSirGlobal mac_ctx,
2262 tpSirMacAuthFrameBody auth_frame,
2263 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302264 uint8_t wep_challenge_len,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302265 tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266{
2267 uint8_t *frame, *body;
2268 uint32_t frame_len = 0, body_len = 0;
2269 tpSirMacMgmtHdr mac_hdr;
2270 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302271 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 uint8_t tx_flag = 0;
2273 uint8_t sme_sessionid = 0;
2274 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002275 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002276 enum rateid min_rid = RATEID_DEFAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277
2278 if (NULL == session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002279 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 return;
2281 }
2282
2283 sme_sessionid = session->smeSessionId;
2284
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302285 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002286 /*
2287 * Auth frame3 to be sent with encrypted framebody
2288 *
2289 * Allocate buffer for Authenticaton frame of size
2290 * equal to management frame header length plus 2 bytes
2291 * each for auth algorithm number, transaction number,
2292 * status code, 128 bytes for challenge text and
2293 * 4 bytes each for IV & ICV.
2294 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002295 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
2296 MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002297
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302298 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002299 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002300
2301 goto alloc_packet;
2302 }
2303
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002304 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002305 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 auth_frame->authTransactionSeqNumber,
2307 auth_frame->authStatusCode,
2308 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
2309 MAC_ADDR_ARRAY(peer_addr));
2310
2311 switch (auth_frame->authTransactionSeqNumber) {
2312 case SIR_MAC_AUTH_FRAME_1:
2313 /*
2314 * Allocate buffer for Authenticaton frame of size
2315 * equal to management frame header length plus 2 bytes
2316 * each for auth algorithm number, transaction number
2317 * and status code.
2318 */
2319
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002320 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2321 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302323 frame_len += lim_create_fils_auth_data(mac_ctx,
2324 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
2326 if (NULL != session->ftPEContext.pFTPreAuthReq &&
2327 0 != session->ftPEContext.pFTPreAuthReq->
2328 ft_ies_length) {
2329 ft_ies_length = session->ftPEContext.
2330 pFTPreAuthReq->ft_ies_length;
2331 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002332 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 ft_ies_length);
2334 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002335 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 frame_len += (2 + SIR_MDIE_SIZE);
2337 }
2338 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 break;
2340
2341 case SIR_MAC_AUTH_FRAME_2:
2342 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2343 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2344 (auth_frame->authStatusCode !=
2345 eSIR_MAC_SUCCESS_STATUS))) {
2346 /*
2347 * Allocate buffer for Authenticaton frame of size
2348 * equal to management frame header length plus
2349 * 2 bytes each for auth algorithm number,
2350 * transaction number and status code.
2351 */
2352
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002353 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2354 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 } else {
2356 /*
2357 * Shared Key algorithm with challenge text
2358 * to be sent.
2359 *
2360 * Allocate buffer for Authenticaton frame of size
2361 * equal to management frame header length plus
2362 * 2 bytes each for auth algorithm number,
2363 * transaction number, status code and 128 bytes
2364 * for challenge text.
2365 */
2366
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002367 challenge_req = true;
2368 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302369 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2370 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002371 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 }
2373 break;
2374
2375 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002376 /*
2377 * Auth frame3 to be sent without encrypted framebody
2378 *
2379 * Allocate buffer for Authenticaton frame of size equal
2380 * to management frame header length plus 2 bytes each
2381 * for auth algorithm number, transaction number and
2382 * status code.
2383 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002385 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2386 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 break;
2388
2389 case SIR_MAC_AUTH_FRAME_4:
2390 /*
2391 * Allocate buffer for Authenticaton frame of size equal
2392 * to management frame header length plus 2 bytes each
2393 * for auth algorithm number, transaction number and
2394 * status code.
2395 */
2396
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002397 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2398 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399
2400 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002401 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002402 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002403 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 } /* switch (auth_frame->authTransactionSeqNumber) */
2405
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002406alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302407 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 (void **)&packet);
2409
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302410 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002411 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 return;
2413 }
2414
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302415 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416
2417 /* Prepare BD */
2418 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2419 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2420 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302421 if (wep_challenge_len)
2422 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2423 else
2424 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425
2426 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002427 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302428 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 (uint8_t *) session->bssId,
2430 sizeof(tSirMacAddr));
2431
2432 /* Prepare Authentication frame body */
2433 body = frame + sizeof(tSirMacMgmtHdr);
2434
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302435 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002438 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 MAC_ADDR_ARRAY(mac_hdr->da));
2440
2441 } else {
2442 *((uint16_t *) (body)) =
2443 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2444 body += sizeof(uint16_t);
2445 body_len -= sizeof(uint16_t);
2446
2447 *((uint16_t *) (body)) =
2448 sir_swap_u16if_needed(
2449 auth_frame->authTransactionSeqNumber);
2450 body += sizeof(uint16_t);
2451 body_len -= sizeof(uint16_t);
2452
2453 *((uint16_t *) (body)) =
2454 sir_swap_u16if_needed(auth_frame->authStatusCode);
2455 body += sizeof(uint16_t);
2456 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002457
2458 if (challenge_req) {
2459 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302460 /* copy challenge IE id, len, challenge text */
2461 *body = auth_frame->type;
2462 body++;
2463 body_len -= sizeof(uint8_t);
2464 *body = auth_frame->length;
2465 body++;
2466 body_len -= sizeof(uint8_t);
2467 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002468 body_len);
2469 pe_err("Incomplete challenge info: length: %d, expected: %d",
2470 body_len,
2471 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2472 body += body_len;
2473 body_len = 0;
2474 } else {
2475 /* copy challenge IE id, len, challenge text */
2476 *body = auth_frame->type;
2477 body++;
2478 *body = auth_frame->length;
2479 body++;
2480 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302481 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2482 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002483
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302484 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2485 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002486 }
2487 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2490 (auth_frame->authTransactionSeqNumber ==
2491 SIR_MAC_AUTH_FRAME_1) &&
2492 (session->ftPEContext.pFTPreAuthReq != NULL)) {
2493
2494 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302495 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 session->ftPEContext.
2497 pFTPreAuthReq->ft_ies,
2498 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002499 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002500 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2501 QDF_TRACE_LEVEL_DEBUG,
2502 (uint8_t *) body,
2503 ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 } else if (NULL != session->ftPEContext.
2505 pFTPreAuthReq->pbssDescription) {
2506 /* MDID attr is 54 */
2507 *body = SIR_MDIE_ELEMENT_ID;
2508 body++;
2509 *body = SIR_MDIE_SIZE;
2510 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302511 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 &session->ftPEContext.pFTPreAuthReq->
2513 pbssDescription->mdie[0],
2514 SIR_MDIE_SIZE);
2515 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302516 } else if (auth_frame->authAlgoNumber ==
Varun Reddy Yeturu5faa1772017-10-23 11:22:01 -07002517 SIR_FILS_SK_WITHOUT_PFS) {
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302518 /* TODO MDIE */
2519 pe_debug("appending fils Auth data");
2520 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002523 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2524 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 auth_frame->authTransactionSeqNumber,
2526 auth_frame->authStatusCode,
2527 (auth_frame->authStatusCode ==
2528 eSIR_MAC_SUCCESS_STATUS),
2529 MAC_ADDR_ARRAY(mac_hdr->da));
2530 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002531 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2532 QDF_TRACE_LEVEL_DEBUG,
2533 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302535 if ((NULL != session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002536 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302537 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002539 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302540 lim_get_rf_band(session->currentOperChannel))
2541 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2542 || (session->pePersona == QDF_P2P_GO_MODE))
2543 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544
Anurag Chouhan6d760662016-02-20 16:05:43 +05302545 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2546 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2548
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302549 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302552 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002553 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002554 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002555 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302556 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2557 (uint16_t)frame_len,
2558 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2559 7, lim_tx_complete, frame,
2560 lim_auth_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002561 tx_flag, sme_sessionid, false, 0, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302562 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2563 session->peSessionId, qdf_status));
2564 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2565 pe_err("*** Could not send Auth frame, retCode=%X ***",
2566 qdf_status);
2567 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2568 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002569 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302570 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302571 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 return;
2573}
2574
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002575QDF_STATUS lim_send_deauth_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576{
2577 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002578 tpDphHashNode sta_ds;
2579 tLimMlmDeauthReq *deauth_req;
2580 tLimMlmDeauthCnf deauth_cnf;
2581 tpPESession session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002583 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2584 if (deauth_req) {
2585 if (tx_timer_running(
2586 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2587 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002590 session_entry = pe_find_session_by_session_id(mac_ctx,
2591 deauth_req->sessionId);
2592 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002593 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002594 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 eSIR_SME_INVALID_PARAMETERS;
2596 goto end;
2597 }
2598
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002599 sta_ds =
2600 dph_lookup_hash_entry(mac_ctx,
2601 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002602 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002603 &session_entry->dph.dphHashTable);
2604 if (sta_ds == NULL) {
2605 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 goto end;
2607 }
2608
2609 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002610 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2611 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2612 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2613 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302614#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002615 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302616#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002617 (session_entry->isFastRoamIniFeatureEnabled) ||
2618 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002619 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002620 session_entry,
2621 session_entry->peSessionId,
2622 deauth_req->reasonCode,
2623 deauth_req->deauthTrigger);
2624 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002625 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002626 pe_debug("No FT Preauth Session Cleanup in role %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002627#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002628 " isESE %d"
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002629#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002630 " isLFR %d"
2631 " is11r %d, Deauth reason %d Trigger = %d",
2632 session_entry->limSystemRole,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002633#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002634 session_entry->isESEconnection,
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002635#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002636 session_entry->isFastRoamIniFeatureEnabled,
2637 session_entry->is11Rconnection,
2638 deauth_req->reasonCode,
2639 deauth_req->deauthTrigger);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002640 }
2641 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002642 qdf_mem_free(deauth_req);
2643 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302645 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002647 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2648 &deauth_req->peer_macaddr);
2649 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2650 deauth_cnf.aid = deauth_req->aid;
2651 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652
2653 /* Free up buffer allocated */
2654 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002655 qdf_mem_free(deauth_req);
2656 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002658 lim_post_sme_message(mac_ctx,
2659 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661}
2662
2663/**
2664 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2665 *
2666 * @mac_ctx: Handle to MAC context
2667 *
2668 * Sends disassoc confirmation to SME. Removes disassoc request stored
2669 * in lim.
2670 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 */
2673
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302674QDF_STATUS lim_send_disassoc_cnf(tpAniSirGlobal mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675{
2676 uint16_t aid;
2677 tpDphHashNode sta_ds;
2678 tLimMlmDisassocCnf disassoc_cnf;
2679 tpPESession pe_session;
2680 tLimMlmDisassocReq *disassoc_req;
2681
2682 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2683 if (disassoc_req) {
2684 if (tx_timer_running(
2685 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2686 lim_deactivate_and_change_timer(mac_ctx,
2687 eLIM_DISASSOC_ACK_TIMER);
2688
2689 pe_session = pe_find_session_by_session_id(
2690 mac_ctx, disassoc_req->sessionId);
2691 if (pe_session == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002692 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693 disassoc_cnf.resultCode =
2694 eSIR_SME_INVALID_PARAMETERS;
2695 goto end;
2696 }
2697
2698 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002699 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 &pe_session->dph.dphHashTable);
2701 if (sta_ds == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002702 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2704 goto end;
2705 }
2706 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002707 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2709 disassoc_cnf.resultCode =
2710 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002711 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712 goto end;
2713 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002714 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002715 (disassoc_req->reasonCode !=
2716 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002717 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002718 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 /* Delete FT session if there exists one */
2721 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302724 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302726 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302728 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 }
2730end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302731 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002732 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302733 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 disassoc_cnf.aid = disassoc_req->aid;
2735 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2736
2737 /* Update PE session ID */
2738 disassoc_cnf.sessionId = disassoc_req->sessionId;
2739
2740 if (disassoc_req != NULL) {
2741 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302742 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2744 }
2745
2746 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2747 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302748 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749}
2750
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302751QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002752 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302753 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002755 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302756
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002757 pe_debug("tx_success: %d", tx_success);
2758
2759 return lim_send_disassoc_cnf(max_ctx);
2760}
2761
2762static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2763 qdf_nbuf_t buf,
2764 uint32_t tx_success,
2765 void *params)
2766{
2767 tpAniSirGlobal max_ctx = (tpAniSirGlobal)context;
2768 QDF_STATUS status_code;
2769 struct scheduler_msg msg = {0};
2770
2771 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302772
2773 if (buf)
2774 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002775 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2776 msg.bodyptr = params;
2777 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302778
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002779 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2780 if (status_code != QDF_STATUS_SUCCESS)
2781 pe_err("posting message: %X to LIM failed, reason: %d",
2782 msg.type, status_code);
2783 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784}
2785
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302786QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002787 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302788 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002789{
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002790 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302791
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002792 pe_debug("tx_success: %d", tx_success);
2793
2794 return lim_send_deauth_cnf(mac_ctx);
2795}
2796
2797static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2798 qdf_nbuf_t buf,
2799 uint32_t tx_success,
2800 void *params)
2801{
2802 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)context;
2803 QDF_STATUS status_code;
2804 struct scheduler_msg msg = {0};
2805
2806 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302807
2808 if (buf)
2809 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002810 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2811 msg.bodyptr = params;
2812 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302813
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002814 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2815 if (status_code != QDF_STATUS_SUCCESS)
2816 pe_err("posting message: %X to LIM failed, reason: %d",
2817 msg.type, status_code);
2818 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819}
2820
2821/**
2822 * \brief This function is called to send Disassociate frame.
2823 *
2824 *
2825 * \param pMac Pointer to Global MAC structure
2826 *
2827 * \param nReason Indicates the reason that need to be sent in
2828 * Disassociation frame
2829 *
2830 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2831 * sent
2832 *
2833 *
2834 */
2835
2836void
2837lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
2838 uint16_t nReason,
2839 tSirMacAddr peer,
2840 tpPESession psessionEntry, bool waitForAck)
2841{
2842 tDot11fDisassociation frm;
2843 uint8_t *pFrame;
2844 tpSirMacMgmtHdr pMacHdr;
2845 uint32_t nBytes, nPayload, nStatus;
2846 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302847 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 uint8_t txFlag = 0;
2849 uint32_t val = 0;
2850 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 if (NULL == psessionEntry) {
2853 return;
2854 }
2855
2856 /*
2857 * In case when cac timer is running for this SAP session then
2858 * avoid sending disassoc out. It is violation of dfs specification.
2859 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05302860 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
2861 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302863 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 FL
2865 ("CAC timer is running, drop disassoc from going out"));
2866 return;
2867 }
2868 smeSessionId = psessionEntry->smeSessionId;
2869
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302870 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002871
2872 frm.Reason.code = nReason;
2873
2874 nStatus = dot11f_get_packed_disassociation_size(pMac, &frm, &nPayload);
2875 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002876 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 nStatus);
2878 /* We'll fall back on the worst case scenario: */
2879 nPayload = sizeof(tDot11fDisassociation);
2880 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002881 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2882 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 }
2884
2885 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2886
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302887 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302889 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002890 pe_err("Failed to allocate %d bytes for a Disassociation",
2891 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 return;
2893 }
2894 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302895 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896
2897 /* Next, we fill out the buffer descriptor: */
2898 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
2899 SIR_MAC_MGMT_DISASSOC, peer, psessionEntry->selfMacAddr);
2900 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2901
2902 /* Prepare the BSSID */
2903 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
2904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906
2907 nStatus = dot11f_pack_disassociation(pMac, &frm, pFrame +
2908 sizeof(tSirMacMgmtHdr),
2909 nPayload, &nPayload);
2910 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002911 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 nStatus);
2913 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002914 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002916 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2917 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 }
2919
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002920 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002922 MAC_ADDRESS_STR, psessionEntry->peSessionId, nReason,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 waitForAck, MAC_ADDR_ARRAY(pMacHdr->da),
2924 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
2925
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002926 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302927 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
2928 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 ) {
2930 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2931 }
2932
Sushant Kaushik46556062015-12-02 16:57:47 +05302933 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934
2935 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302936 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 psessionEntry->peSessionId,
2938 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002939 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002940 psessionEntry, QDF_STATUS_SUCCESS,
2941 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 /* Queue Disassociation frame in high priority WQ */
2943 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302944 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
2946 TXRX_FRM_802_11_MGMT,
2947 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002948 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002949 txFlag, smeSessionId, false, 0,
2950 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302951 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302952 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302953 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954
2955 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2956
2957 if (tx_timer_change
2958 (&pMac->lim.limTimers.gLimDisassocAckTimer, val, 0)
2959 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002960 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 return;
2962 } else if (TX_SUCCESS !=
2963 tx_timer_activate(&pMac->lim.limTimers.
2964 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002965 pe_err("Unable to activate Disassoc ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 lim_deactivate_and_change_timer(pMac,
2967 eLIM_DISASSOC_ACK_TIMER);
2968 return;
2969 }
2970 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302971 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 psessionEntry->peSessionId,
2973 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08002974 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
2975 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002976 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302978 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 TXRX_FRM_802_11_MGMT,
2980 ANI_TXDIR_TODS,
2981 7,
2982 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002983 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302984 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302985 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302986 psessionEntry->peSessionId, qdf_status));
2987 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002988 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 /* Pkt will be freed up by the callback */
2991 }
2992 }
2993} /* End lim_send_disassoc_mgmt_frame. */
2994
2995/**
2996 * \brief This function is called to send a Deauthenticate frame
2997 *
2998 *
2999 * \param pMac Pointer to global MAC structure
3000 *
3001 * \param nReason Indicates the reason that need to be sent in the
3002 * Deauthenticate frame
3003 *
3004 * \param peeer address of the STA to which the frame is to be sent
3005 *
3006 *
3007 */
3008
3009void
3010lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
3011 uint16_t nReason,
3012 tSirMacAddr peer,
3013 tpPESession psessionEntry, bool waitForAck)
3014{
3015 tDot11fDeAuth frm;
3016 uint8_t *pFrame;
3017 tpSirMacMgmtHdr pMacHdr;
3018 uint32_t nBytes, nPayload, nStatus;
3019 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303020 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 uint8_t txFlag = 0;
3022 uint32_t val = 0;
3023#ifdef FEATURE_WLAN_TDLS
3024 uint16_t aid;
3025 tpDphHashNode pStaDs;
3026#endif
3027 uint8_t smeSessionId = 0;
3028
3029 if (NULL == psessionEntry) {
3030 return;
3031 }
3032
3033 /*
3034 * In case when cac timer is running for this SAP session then
3035 * avoid deauth frame out. It is violation of dfs specification.
3036 */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303037 if (((psessionEntry->pePersona == QDF_SAP_MODE) ||
3038 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (true == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303040 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 FL
3042 ("CAC timer is running, drop the deauth from going out"));
3043 return;
3044 }
3045 smeSessionId = psessionEntry->smeSessionId;
3046
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303047 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048
3049 frm.Reason.code = nReason;
3050
3051 nStatus = dot11f_get_packed_de_auth_size(pMac, &frm, &nPayload);
3052 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003053 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054 nStatus);
3055 /* We'll fall back on the worst case scenario: */
3056 nPayload = sizeof(tDot11fDeAuth);
3057 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003058 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3059 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 }
3061
3062 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303064 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303066 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003067 pe_err("Failed to allocate %d bytes for a De-Authentication",
3068 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 return;
3070 }
3071 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303072 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073
3074 /* Next, we fill out the buffer descriptor: */
3075 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3076 SIR_MAC_MGMT_DEAUTH, peer, psessionEntry->selfMacAddr);
3077 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3078
3079 /* Prepare the BSSID */
3080 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
3081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083
3084 nStatus = dot11f_pack_de_auth(pMac, &frm, pFrame +
3085 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3086 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003087 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088 nStatus);
3089 cds_packet_free((void *)pPacket);
3090 return;
3091 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003092 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3093 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003095 pe_debug("***Sessionid %d Sending Deauth frame with "
3096 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3097 " ,From " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 psessionEntry->peSessionId, nReason, waitForAck,
3099 MAC_ADDR_ARRAY(pMacHdr->da),
3100 MAC_ADDR_ARRAY(psessionEntry->selfMacAddr));
3101
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003102 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303103 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3104 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 ) {
3106 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3107 }
3108
Sushant Kaushik46556062015-12-02 16:57:47 +05303109 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110#ifdef FEATURE_WLAN_TDLS
3111 pStaDs =
3112 dph_lookup_hash_entry(pMac, peer, &aid,
3113 &psessionEntry->dph.dphHashTable);
3114#endif
3115
3116 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303117 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 psessionEntry->peSessionId,
3119 pMacHdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08003120 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3121 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003122 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303124 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
3126 TXRX_FRM_802_11_MGMT,
3127 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003128 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003129 txFlag, smeSessionId, false, 0,
3130 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303131 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303132 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303133 psessionEntry->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303135 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003136 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303137 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138
3139 /* Call lim_process_deauth_ack_timeout which will send
3140 * DeauthCnf for this frame
3141 */
3142 lim_process_deauth_ack_timeout(pMac);
3143 return;
3144 }
3145
3146 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3147
3148 if (tx_timer_change
3149 (&pMac->lim.limTimers.gLimDeauthAckTimer, val, 0)
3150 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003151 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152 return;
3153 } else if (TX_SUCCESS !=
3154 tx_timer_activate(&pMac->lim.limTimers.
3155 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003156 pe_err("Unable to activate Deauth ack Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 lim_deactivate_and_change_timer(pMac,
3158 eLIM_DEAUTH_ACK_TIMER);
3159 return;
3160 }
3161 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303162 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 psessionEntry->peSessionId,
3164 pMacHdr->fc.subType));
3165#ifdef FEATURE_WLAN_TDLS
3166 if ((NULL != pStaDs)
3167 && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
3168 /* Queue Disassociation frame in high priority WQ */
Krunal Sonic65fc492018-03-09 15:53:28 -08003169 lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
3170 psessionEntry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003171 QDF_STATUS_SUCCESS,
3172 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303173 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3175 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3176 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003177 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 } else {
3179#endif
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);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303185 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3187 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3188 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003189 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190#ifdef FEATURE_WLAN_TDLS
3191 }
3192#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303193 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303194 psessionEntry->peSessionId, qdf_status));
3195 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003196 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303197 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 /* Pkt will be freed up by the callback */
3199 }
3200 }
3201
3202} /* End lim_send_deauth_mgmt_frame. */
3203
3204#ifdef ANI_SUPPORT_11H
3205/**
3206 * \brief Send a Measurement Report Action frame
3207 *
3208 *
3209 * \param pMac Pointer to the global MAC structure
3210 *
3211 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3212 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003213 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 *
3215 *
3216 */
3217
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003218QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219lim_send_meas_report_frame(tpAniSirGlobal pMac,
3220 tpSirMacMeasReqActionFrame pMeasReqFrame,
3221 tSirMacAddr peer, tpPESession psessionEntry)
3222{
3223 tDot11fMeasurementReport frm;
3224 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003225 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 tpSirMacMgmtHdr pMacHdr;
3227 uint32_t nBytes, nPayload, nStatus;
3228 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303229 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303231 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232
3233 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3234 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3235 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3236
3237 switch (pMeasReqFrame->measReqIE.measType) {
3238 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3239 nSirStatus =
3240 populate_dot11f_measurement_report0(pMac, pMeasReqFrame,
3241 &frm.MeasurementReport);
3242 break;
3243 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3244 nSirStatus =
3245 populate_dot11f_measurement_report1(pMac, pMeasReqFrame,
3246 &frm.MeasurementReport);
3247 break;
3248 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3249 nSirStatus =
3250 populate_dot11f_measurement_report2(pMac, pMeasReqFrame,
3251 &frm.MeasurementReport);
3252 break;
3253 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003254 pe_err("Unknown measurement type %d in limSen"
3255 "dMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 }
3259
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003260 if (QDF_STATUS_SUCCESS != nSirStatus)
3261 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262
3263 nStatus = dot11f_get_packed_measurement_report_size(pMac, &frm, &nPayload);
3264 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003265 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 nStatus);
3267 /* We'll fall back on the worst case scenario: */
3268 nPayload = sizeof(tDot11fMeasurementReport);
3269 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003270 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3271 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 }
3273
3274 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3275
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303276 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003277 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 (uint16_t) nBytes, (void **)&pFrame,
3279 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003281 pe_err("Failed to allocate %d bytes for a "
3282 "De-Authentication", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003283 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 }
3285 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303286 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287
3288 /* Next, we fill out the buffer descriptor: */
3289 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3290 SIR_MAC_MGMT_ACTION, peer);
3291 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3292
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303293 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296
3297 nStatus = dot11f_pack_measurement_report(pMac, &frm, pFrame +
3298 sizeof(tSirMacMgmtHdr),
3299 nPayload, &nPayload);
3300 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003301 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003303 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003305 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003307 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3308 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 }
3310
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303311 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 ((psessionEntry) ? psessionEntry->
3313 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303314 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3316 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003317 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303318 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303319 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303321 qdf_status));
3322 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003323 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303324 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003326 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 }
3328
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003329 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330
3331} /* End lim_send_meas_report_frame. */
3332
3333/**
3334 * \brief Send a TPC Request Action frame
3335 *
3336 *
3337 * \param pMac Pointer to the global MAC datastructure
3338 *
3339 * \param peer MAC address to which the frame should be sent
3340 *
3341 *
3342 */
3343
3344void
3345lim_send_tpc_request_frame(tpAniSirGlobal pMac,
3346 tSirMacAddr peer, tpPESession psessionEntry)
3347{
3348 tDot11fTPCRequest frm;
3349 uint8_t *pFrame;
3350 tpSirMacMgmtHdr pMacHdr;
3351 uint32_t nBytes, nPayload, nStatus;
3352 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303353 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003354
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303355 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356
3357 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3358 frm.Action.action = SIR_MAC_ACTION_TPC_REQUEST_ID;
3359 frm.DialogToken.token = 1;
3360 frm.TPCRequest.present = 1;
3361
3362 nStatus = dot11f_get_packed_tpc_request_size(pMac, &frm, &nPayload);
3363 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003364 pe_err("Failed to calculate the packed size for a TPC Request (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 /* We'll fall back on the worst case scenario: */
3366 nPayload = sizeof(tDot11fTPCRequest);
3367 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003368 pe_warn("There were warnings while calculating the packed size for a TPC Request (0x%08x)",
3369 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 }
3371
3372 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3373
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303374 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003375 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 (uint16_t) nBytes, (void **)&pFrame,
3377 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303378 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003379 pe_err("Failed to allocate %d bytes for a TPC"
3380 " Request", nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 return;
3382 }
3383 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303384 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385
3386 /* Next, we fill out the buffer descriptor: */
3387 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3388 SIR_MAC_MGMT_ACTION, peer);
3389 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3390
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303391 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394
3395 nStatus = dot11f_pack_tpc_request(pMac, &frm, pFrame +
3396 sizeof(tSirMacMgmtHdr),
3397 nPayload, &nPayload);
3398 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003399 pe_err("Failed to pack a TPC Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003401 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 (void *)pFrame, (void *)pPacket);
3403 return; /* allocated! */
3404 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003405 pe_warn("There were warnings while packing a TPC Request (0x%08x)",
3406 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 }
3408
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303409 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 ((psessionEntry) ? psessionEntry->
3411 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303412 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3414 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003415 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303416 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303417 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303419 qdf_status));
3420 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003421 pe_err("Failed to send a TPC Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303422 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 /* Pkt will be freed up by the callback */
3424 }
3425
3426} /* End lim_send_tpc_request_frame. */
3427
3428/**
3429 * \brief Send a TPC Report Action frame
3430 *
3431 *
3432 * \param pMac Pointer to the global MAC datastructure
3433 *
3434 * \param pTpcReqFrame Pointer to the received TPC Request
3435 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003436 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437 *
3438 *
3439 */
3440
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003441QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442lim_send_tpc_report_frame(tpAniSirGlobal pMac,
3443 tpSirMacTpcReqActionFrame pTpcReqFrame,
3444 tSirMacAddr peer, tpPESession psessionEntry)
3445{
3446 tDot11fTPCReport frm;
3447 uint8_t *pFrame;
3448 tpSirMacMgmtHdr pMacHdr;
3449 uint32_t nBytes, nPayload, nStatus;
3450 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303453 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003454
3455 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3456 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3457 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3458
3459 frm.TPCReport.tx_power = 0;
3460 frm.TPCReport.link_margin = 0;
3461 frm.TPCReport.present = 1;
3462
3463 nStatus = dot11f_get_packed_tpc_report_size(pMac, &frm, &nPayload);
3464 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003465 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 /* We'll fall back on the worst case scenario: */
3467 nPayload = sizeof(tDot11fTPCReport);
3468 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003469 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3470 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 }
3472
3473 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3474
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 qdf_status =
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003476 cds_packet_alloc(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 (uint16_t) nBytes, (void **)&pFrame,
3478 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303479 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003480 pe_err("Failed to allocate %d bytes for a TPC"
3481 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003482 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 }
3484 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303485 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486
3487 /* Next, we fill out the buffer descriptor: */
3488 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3489 SIR_MAC_MGMT_ACTION, peer);
3490
3491 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3492
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303493 qdf_mem_copy(pMacHdr->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496
3497 nStatus = dot11f_pack_tpc_report(pMac, &frm, pFrame +
3498 sizeof(tSirMacMgmtHdr),
3499 nPayload, &nPayload);
3500 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003501 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 nStatus);
Jeff Johnson6aaaa992018-06-30 10:43:04 -07003503 cds_packet_free(pMac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003505 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003507 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3508 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303510 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 ((psessionEntry) ? psessionEntry->
3512 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003514 wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
3515 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003516 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303517 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003518 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3519 ((psessionEntry) ? psessionEntry->peSessionId : NO_SESSION),
3520 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003522 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303523 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003525 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 }
3527
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003528 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529
3530} /* End lim_send_tpc_report_frame. */
3531#endif /* ANI_SUPPORT_11H */
3532
3533/**
3534 * \brief Send a Channel Switch Announcement
3535 *
3536 *
3537 * \param pMac Pointer to the global MAC datastructure
3538 *
3539 * \param peer MAC address to which this frame will be sent
3540 *
3541 * \param nMode
3542 *
3543 * \param nNewChannel
3544 *
3545 * \param nCount
3546 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003547 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003548 *
3549 *
3550 */
3551
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003552QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553lim_send_channel_switch_mgmt_frame(tpAniSirGlobal pMac,
3554 tSirMacAddr peer,
3555 uint8_t nMode,
3556 uint8_t nNewChannel,
3557 uint8_t nCount, tpPESession psessionEntry)
3558{
3559 tDot11fChannelSwitch frm;
3560 uint8_t *pFrame;
3561 tpSirMacMgmtHdr pMacHdr;
3562 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3563 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303564 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 uint8_t txFlag = 0;
3566
3567 uint8_t smeSessionId = 0;
3568
3569 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003570 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003571 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 }
3573 smeSessionId = psessionEntry->smeSessionId;
3574
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303575 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576
3577 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3578 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3579 frm.ChanSwitchAnn.switchMode = nMode;
3580 frm.ChanSwitchAnn.newChannel = nNewChannel;
3581 frm.ChanSwitchAnn.switchCount = nCount;
3582 frm.ChanSwitchAnn.present = 1;
3583
3584 nStatus = dot11f_get_packed_channel_switch_size(pMac, &frm, &nPayload);
3585 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003586 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 nStatus);
3588 /* We'll fall back on the worst case scenario: */
3589 nPayload = sizeof(tDot11fChannelSwitch);
3590 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003591 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3592 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 }
3594
3595 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3596
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303597 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3599 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003601 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003602 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 }
3604 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303605 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606
3607 /* Next, we fill out the buffer descriptor: */
3608 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
3609 SIR_MAC_MGMT_ACTION, peer,
3610 psessionEntry->selfMacAddr);
3611 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303612 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
3614
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616
3617 nStatus = dot11f_pack_channel_switch(pMac, &frm, pFrame +
3618 sizeof(tSirMacMgmtHdr),
3619 nPayload, &nPayload);
3620 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003621 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 nStatus);
3623 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003624 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003626 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3627 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003630 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05303631 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
3632 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 ) {
3634 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3635 }
3636
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303637 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303639 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 TXRX_FRM_802_11_MGMT,
3641 ANI_TXDIR_TODS,
3642 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003643 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303644 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303645 psessionEntry->peSessionId, qdf_status));
3646 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003647 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003650 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003653 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654
3655} /* End lim_send_channel_switch_mgmt_frame. */
3656
Abhishek Singh518323d2015-10-19 17:42:01 +05303657/**
3658 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3659 * action frame over the air .
3660 * @mac_ctx: pointer to global mac structure
3661 * @peer: Destination mac.
3662 * @mode: channel switch mode
3663 * @new_op_class: new op class
3664 * @new_channel: new channel to switch
3665 * @count: channel switch count
3666 *
3667 * This function is called to send ECSA frame.
3668 *
3669 * Return: success if frame is sent else return failure
3670 */
3671
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003672QDF_STATUS
Abhishek Singh518323d2015-10-19 17:42:01 +05303673lim_send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
3674 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
3675 uint8_t new_channel, uint8_t count, tpPESession session_entry)
3676{
3677 tDot11fext_channel_switch_action_frame frm;
3678 uint8_t *frame;
3679 tpSirMacMgmtHdr mac_hdr;
3680 uint32_t num_bytes, n_payload, status;
3681 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303682 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303683 uint8_t txFlag = 0;
3684 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303685 uint8_t ch_spacing;
3686 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303687
3688 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003689 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003690 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303691 }
3692
3693 sme_session_id = session_entry->smeSessionId;
3694
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303695 qdf_mem_set(&frm, sizeof(frm), 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303696
3697 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3698 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3699
3700 frm.ext_chan_switch_ann_action.switch_mode = mode;
3701 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3702 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3703 frm.ext_chan_switch_ann_action.switch_count = count;
3704
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303705 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3706 mac_ctx->scan.countryCodeCurrent, new_channel,
3707 new_op_class);
3708 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3709
3710 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3711 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3712 frm.WiderBWChanSwitchAnn.newChanWidth =
3713 wide_bw_ie->newChanWidth;
3714 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3715 wide_bw_ie->newCenterChanFreq0;
3716 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3717 wide_bw_ie->newCenterChanFreq1;
3718 frm.WiderBWChanSwitchAnn.present = 1;
3719 pe_debug("wrapper: width:%d f0:%d f1:%d",
3720 frm.WiderBWChanSwitchAnn.newChanWidth,
3721 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3722 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3723 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303724
3725 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3726 &frm, &n_payload);
3727 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003728 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303729 status);
3730 /* We'll fall back on the worst case scenario*/
3731 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3732 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003733 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303734 status);
3735 }
3736
3737 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3738
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303739 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303740 (void **) &frame, (void **) &packet);
3741
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303742 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003743 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303744 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003745 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303746 }
3747
3748 /* Paranoia*/
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303749 qdf_mem_set(frame, num_bytes, 0);
Abhishek Singh518323d2015-10-19 17:42:01 +05303750
3751 /* Next, we fill out the buffer descriptor */
3752 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3753 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3754 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303755 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303756 (uint8_t *) session_entry->bssId,
3757 sizeof(tSirMacAddr));
3758
gaolez4b62a9e2018-08-16 15:57:50 +08003759 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3760
Abhishek Singh518323d2015-10-19 17:42:01 +05303761 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3762 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3763 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003764 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303765 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003766 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303767 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003768 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303769 status);
3770 }
3771
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003772 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303773 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303774 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3775 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303776 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3777 }
3778
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003779 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 +05303780 MAC_ADDR_ARRAY(mac_hdr->da),
3781 frm.ext_chan_switch_ann_action.switch_count,
3782 frm.ext_chan_switch_ann_action.switch_mode,
3783 frm.ext_chan_switch_ann_action.new_channel,
3784 frm.ext_chan_switch_ann_action.op_class);
3785
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303786 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303787 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303788 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303789 TXRX_FRM_802_11_MGMT,
3790 ANI_TXDIR_TODS,
3791 7,
3792 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003793 txFlag, sme_session_id, 0,
3794 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303795 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303796 session_entry->peSessionId, qdf_status));
3797 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003798 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303800 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003801 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303802 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003803 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303804} /* End lim_send_extended_chan_switch_action_frame */
3805
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303806
3807/**
3808 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3809 * sent over the air
3810 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303811 * @context: pointer to global mac
3812 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303813 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303814 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303815 *
3816 * Return: This returns QDF_STATUS
3817 */
3818
3819static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303820 void *context,
3821 qdf_nbuf_t buf,
3822 uint32_t tx_complete,
3823 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303824{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003825 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003826 if (buf)
3827 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303828 return QDF_STATUS_SUCCESS;
3829}
3830
3831/**
3832 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3833 * p2p oper chan change confirm action frame
3834 * @mac_ctx: pointer to global mac structure
3835 * @peer: Destination mac.
3836 * @session_entry: session entry
3837 *
3838 * This function is called to send p2p oper chan change confirm action frame.
3839 *
3840 * Return: success if frame is sent else return failure
3841 */
3842
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003843QDF_STATUS
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303844lim_p2p_oper_chan_change_confirm_action_frame(tpAniSirGlobal mac_ctx,
3845 tSirMacAddr peer, tpPESession session_entry)
3846{
3847 tDot11fp2p_oper_chan_change_confirm frm;
3848 uint8_t *frame;
3849 tpSirMacMgmtHdr mac_hdr;
3850 uint32_t num_bytes, n_payload, status;
3851 void *packet;
3852 QDF_STATUS qdf_status;
3853 uint8_t tx_flag = 0;
3854 uint8_t sme_session_id = 0;
3855
3856 if (session_entry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003857 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003858 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303859 }
3860
3861 sme_session_id = session_entry->smeSessionId;
3862
3863 qdf_mem_set(&frm, sizeof(frm), 0);
3864
3865 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3866
3867 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3868 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3869 frm.p2p_action_subtype.subtype = 0x04;
3870 frm.DialogToken.token = 0x0;
3871
3872 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003873 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303874 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3875 }
3876
3877 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003878 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303879 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3880 populate_dot11f_operating_mode(mac_ctx,
3881 &frm.OperatingMode, session_entry);
3882 }
3883
3884 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3885 &frm, &n_payload);
3886 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003887 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303888 /* We'll fall back on the worst case scenario*/
3889 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3890 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003891 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3892 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303893 }
3894
3895 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3896
3897 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3898 (void **) &frame, (void **) &packet);
3899
3900 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003901 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003902 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303903 }
3904
3905 qdf_mem_set(frame, num_bytes, 0);
3906
3907 /* Next, fill out the buffer descriptor */
3908 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3909 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3910 mac_hdr = (tpSirMacMgmtHdr) frame;
3911 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3912 (uint8_t *) session_entry->bssId,
3913 sizeof(tSirMacAddr));
3914
3915 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3916 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3917 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003918 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303919 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003920 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303921 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003922 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303923 status);
3924 }
3925
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003926 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303927 lim_get_rf_band(session_entry->currentOperChannel)) ||
3928 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3929 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3930 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3931 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003932 pe_debug("Send frame on channel %d to mac "
3933 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303934 MAC_ADDR_ARRAY(peer));
3935
3936 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3937 session_entry->peSessionId, mac_hdr->fc.subType));
3938
3939 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3940 (uint16_t)num_bytes,
3941 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3942 7, lim_tx_complete, frame,
3943 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003944 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303945
3946 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3947 session_entry->peSessionId, qdf_status));
3948 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003949 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303950 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003951 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303952 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003953 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303954}
3955
3956
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003957QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958lim_send_vht_opmode_notification_frame(tpAniSirGlobal pMac,
3959 tSirMacAddr peer,
3960 uint8_t nMode, tpPESession psessionEntry)
3961{
3962 tDot11fOperatingMode frm;
3963 uint8_t *pFrame;
3964 tpSirMacMgmtHdr pMacHdr;
3965 uint32_t nBytes, nPayload = 0, nStatus; /* , nCfg; */
3966 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303967 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 uint8_t txFlag = 0;
3969
3970 uint8_t smeSessionId = 0;
3971
3972 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003973 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003974 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 }
3976 smeSessionId = psessionEntry->smeSessionId;
3977
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303978 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979
3980 frm.Category.category = SIR_MAC_ACTION_VHT;
3981 frm.Action.action = SIR_MAC_VHT_OPMODE_NOTIFICATION;
3982 frm.OperatingMode.chanWidth = nMode;
3983 frm.OperatingMode.rxNSS = 0;
3984 frm.OperatingMode.rxNSSType = 0;
3985
3986 nStatus = dot11f_get_packed_operating_mode_size(pMac, &frm, &nPayload);
3987 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003988 pe_err("Failed to calculate the packed size for a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 nStatus);
3990 /* We'll fall back on the worst case scenario: */
3991 nPayload = sizeof(tDot11fOperatingMode);
3992 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003993 pe_warn("There were warnings while calculating the packed size for a Operating Mode (0x%08x)",
3994 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 }
3996
3997 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303999 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4001 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004003 pe_err("Failed to allocate %d bytes for a Operating Mode Report",
4004 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004005 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 }
4007 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304008 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009
4010 /* Next, we fill out the buffer descriptor: */
Anurag Chouhan6d760662016-02-20 16:05:43 +05304011 if (psessionEntry->pePersona == QDF_SAP_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4013 SIR_MAC_MGMT_ACTION, peer,
4014 psessionEntry->selfMacAddr);
4015 else
4016 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4017 SIR_MAC_MGMT_ACTION, psessionEntry->bssId,
4018 psessionEntry->selfMacAddr);
4019 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304020 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 (uint8_t *) psessionEntry->bssId, sizeof(tSirMacAddr));
4022 nStatus = dot11f_pack_operating_mode(pMac, &frm, pFrame +
4023 sizeof(tSirMacMgmtHdr),
4024 nPayload, &nPayload);
4025 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004026 pe_err("Failed to pack a Operating Mode (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027 nStatus);
4028 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004029 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004031 pe_warn("There were warnings while packing a Operating Mode (0x%08x)",
4032 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004034 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304035 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4036 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 ) {
4038 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4039 }
4040
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304041 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304043 qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 TXRX_FRM_802_11_MGMT,
4045 ANI_TXDIR_TODS,
4046 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004047 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304048 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304049 psessionEntry->peSessionId, qdf_status));
4050 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004051 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304052 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004054 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 }
4056
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004057 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058}
4059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060/**
4061 * \brief Send a Neighbor Report Request Action frame
4062 *
4063 *
4064 * \param pMac Pointer to the global MAC structure
4065 *
4066 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4067 *
4068 * \param peer mac address of peer station.
4069 *
4070 * \param psessionEntry address of session entry.
4071 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004072 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 *
4074 *
4075 */
4076
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004077QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078lim_send_neighbor_report_request_frame(tpAniSirGlobal pMac,
4079 tpSirMacNeighborReportReq pNeighborReq,
4080 tSirMacAddr peer, tpPESession psessionEntry)
4081{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004082 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083 tDot11fNeighborReportRequest frm;
4084 uint8_t *pFrame;
4085 tpSirMacMgmtHdr pMacHdr;
4086 uint32_t nBytes, nPayload, nStatus;
4087 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304088 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 uint8_t txFlag = 0;
4090 uint8_t smeSessionId = 0;
4091
4092 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004093 pe_err("(psession == NULL) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004094 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 }
4096 smeSessionId = psessionEntry->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304097 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098
4099 frm.Category.category = SIR_MAC_ACTION_RRM;
4100 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
4101 frm.DialogToken.token = pNeighborReq->dialogToken;
4102
4103 if (pNeighborReq->ssid_present) {
4104 populate_dot11f_ssid(pMac, &pNeighborReq->ssid, &frm.SSID);
4105 }
4106
4107 nStatus =
4108 dot11f_get_packed_neighbor_report_request_size(pMac, &frm, &nPayload);
4109 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004110 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 nStatus);
4112 /* We'll fall back on the worst case scenario: */
4113 nPayload = sizeof(tDot11fNeighborReportRequest);
4114 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004115 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4116 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 }
4118
4119 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4120
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304121 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4123 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304124 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004125 pe_err("Failed to allocate %d bytes for a Neighbor "
4126 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004127 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 }
4129 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304130 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131
4132 /* Copy necessary info to BD */
4133 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4134 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4135
4136 /* Update A3 with the BSSID */
4137 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4138
4139 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142
4143 /* Now, we're ready to "pack" the frames */
4144 nStatus = dot11f_pack_neighbor_report_request(pMac,
4145 &frm,
4146 pFrame +
4147 sizeof(tSirMacMgmtHdr),
4148 nPayload, &nPayload);
4149
4150 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004151 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 nStatus);
4153
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004154 /* FIXME - Need to convert to QDF_STATUS */
4155 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 goto returnAfterError;
4157 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004158 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4159 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 }
4161
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004162 pe_debug("Sending a Neighbor Report Request to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +05304163 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004165 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304166 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4167 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 ) {
4169 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4170 }
4171
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304172 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304174 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 pPacket,
4176 (uint16_t) nBytes,
4177 TXRX_FRM_802_11_MGMT,
4178 ANI_TXDIR_TODS,
4179 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004180 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304181 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304182 psessionEntry->peSessionId, qdf_status));
4183 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004184 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004185 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 /* Pkt will be freed up by the callback */
4187 return statusCode;
4188 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004189 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190
4191returnAfterError:
4192 cds_packet_free((void *)pPacket);
4193
4194 return statusCode;
4195} /* End lim_send_neighbor_report_request_frame. */
4196
4197/**
4198 * \brief Send a Link Report Action frame
4199 *
4200 *
4201 * \param pMac Pointer to the global MAC structure
4202 *
4203 * \param pLinkReport Address of a tSirMacLinkReport
4204 *
4205 * \param peer mac address of peer station.
4206 *
4207 * \param psessionEntry address of session entry.
4208 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004209 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 *
4211 *
4212 */
4213
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004214QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215lim_send_link_report_action_frame(tpAniSirGlobal pMac,
4216 tpSirMacLinkReport pLinkReport,
4217 tSirMacAddr peer, tpPESession psessionEntry)
4218{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004219 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 tDot11fLinkMeasurementReport frm;
4221 uint8_t *pFrame;
4222 tpSirMacMgmtHdr pMacHdr;
4223 uint32_t nBytes, nPayload, nStatus;
4224 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304225 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 uint8_t txFlag = 0;
4227 uint8_t smeSessionId = 0;
4228
4229 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004230 pe_err("(psession == NULL) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004231 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 }
4233
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304234 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235
4236 frm.Category.category = SIR_MAC_ACTION_RRM;
4237 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4238 frm.DialogToken.token = pLinkReport->dialogToken;
4239
4240 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4241 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4242 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4243 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4244 /* such case this way than changing the frame parser. */
4245 frm.TPCEleID.TPCId = SIR_MAC_TPC_RPT_EID;
4246 frm.TPCEleLen.TPCLen = 2;
4247 frm.TxPower.txPower = pLinkReport->txPower;
4248 frm.LinkMargin.linkMargin = 0;
4249
4250 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4251 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4252 frm.RCPI.rcpi = pLinkReport->rcpi;
4253 frm.RSNI.rsni = pLinkReport->rsni;
4254
4255 nStatus =
4256 dot11f_get_packed_link_measurement_report_size(pMac, &frm, &nPayload);
4257 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004258 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 /* We'll fall back on the worst case scenario: */
4260 nPayload = sizeof(tDot11fLinkMeasurementReport);
4261 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004262 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4263 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 }
4265
4266 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4267
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304268 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4270 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304271 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004272 pe_err("Failed to allocate %d bytes for a Link "
4273 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004274 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 }
4276 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304277 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278
4279 /* Copy necessary info to BD */
4280 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4281 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4282
4283 /* Update A3 with the BSSID */
4284 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4285
4286 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289
4290 /* Now, we're ready to "pack" the frames */
4291 nStatus = dot11f_pack_link_measurement_report(pMac,
4292 &frm,
4293 pFrame +
4294 sizeof(tSirMacMgmtHdr),
4295 nPayload, &nPayload);
4296
4297 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004298 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004300 /* FIXME - Need to convert to QDF_STATUS */
4301 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 goto returnAfterError;
4303 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004304 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 nStatus);
4306 }
4307
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004308 pe_warn("Sending a Link Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 lim_print_mac_addr(pMac, peer, LOGW);
4310
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004311 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304312 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4313 (psessionEntry->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4315 }
4316
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304317 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304319 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 pPacket,
4321 (uint16_t) nBytes,
4322 TXRX_FRM_802_11_MGMT,
4323 ANI_TXDIR_TODS,
4324 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004325 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304326 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304327 psessionEntry->peSessionId, qdf_status));
4328 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004329 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004330 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331 /* Pkt will be freed up by the callback */
4332 return statusCode;
4333 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004334 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335
4336returnAfterError:
4337 cds_packet_free((void *)pPacket);
4338
4339 return statusCode;
4340} /* End lim_send_link_report_action_frame. */
4341
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004342QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343lim_send_radio_measure_report_action_frame(tpAniSirGlobal pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304344 uint8_t dialog_token,
4345 uint8_t num_report,
4346 struct rrm_beacon_report_last_beacon_params
4347 *last_beacon_report_params,
4348 tpSirMacRadioMeasureReport pRRMReport,
4349 tSirMacAddr peer,
4350 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004352 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 uint8_t *pFrame;
4354 tpSirMacMgmtHdr pMacHdr;
4355 uint32_t nBytes, nPayload, nStatus;
4356 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304357 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 uint8_t i;
4359 uint8_t txFlag = 0;
4360 uint8_t smeSessionId = 0;
4361
4362 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304363 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004364 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004365 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366
4367 if (psessionEntry == NULL) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004368 pe_err("(psession == NULL) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304369 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004370 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004373 smeSessionId = psessionEntry->smeSessionId;
4374
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004375 pe_debug("dialog_token %d num_report %d",
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304376 dialog_token, num_report);
4377
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 frm->Category.category = SIR_MAC_ACTION_RRM;
4379 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4380 frm->DialogToken.token = dialog_token;
4381
4382 frm->num_MeasurementReport =
4383 (num_report >
4384 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4385 num_report;
4386
4387 for (i = 0; i < frm->num_MeasurementReport; i++) {
4388 frm->MeasurementReport[i].type = pRRMReport[i].type;
4389 frm->MeasurementReport[i].token = pRRMReport[i].token;
4390 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4391 switch (pRRMReport[i].type) {
4392 case SIR_MAC_RRM_BEACON_TYPE:
4393 populate_dot11f_beacon_report(pMac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304394 &frm->MeasurementReport[i],
4395 &pRRMReport[i].report.
4396 beaconReport,
4397 last_beacon_report_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 frm->MeasurementReport[i].incapable =
4399 pRRMReport[i].incapable;
4400 frm->MeasurementReport[i].refused =
4401 pRRMReport[i].refused;
4402 frm->MeasurementReport[i].present = 1;
4403 break;
4404 default:
4405 frm->MeasurementReport[i].incapable =
4406 pRRMReport[i].incapable;
4407 frm->MeasurementReport[i].refused =
4408 pRRMReport[i].refused;
4409 frm->MeasurementReport[i].present = 1;
4410 break;
4411 }
4412 }
4413
4414 nStatus =
4415 dot11f_get_packed_radio_measurement_report_size(pMac, frm, &nPayload);
4416 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004417 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 nStatus);
4419 /* We'll fall back on the worst case scenario: */
4420 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304421 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004422 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004424 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4425 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 }
4427
4428 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4429
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304430 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4432 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304433 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004434 pe_err("Failed to allocate %d bytes for a Radio Measure "
4435 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304436 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004437 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 }
4439 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304440 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441
4442 /* Copy necessary info to BD */
4443 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4444 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4445
4446 /* Update A3 with the BSSID */
4447 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4448
4449 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452
4453 /* Now, we're ready to "pack" the frames */
4454 nStatus = dot11f_pack_radio_measurement_report(pMac,
4455 frm,
4456 pFrame +
4457 sizeof(tSirMacMgmtHdr),
4458 nPayload, &nPayload);
4459
4460 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004461 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 nStatus);
4463
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004464 /* FIXME - Need to convert to QDF_STATUS */
4465 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 goto returnAfterError;
4467 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004468 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4469 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 }
4471
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004472 pe_warn("Sending a Radio Measure Report to");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 lim_print_mac_addr(pMac, peer, LOGW);
4474
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004475 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05304476 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4477 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 ) {
4479 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4480 }
4481
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304482 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304484 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 pPacket,
4486 (uint16_t) nBytes,
4487 TXRX_FRM_802_11_MGMT,
4488 ANI_TXDIR_TODS,
4489 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004490 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304491 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304492 psessionEntry->peSessionId, qdf_status));
4493 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004494 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004495 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304497 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 return statusCode;
4499 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304500 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004501 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 }
4503
4504returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304505 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 cds_packet_free((void *)pPacket);
4507 return statusCode;
4508}
4509
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510#ifdef WLAN_FEATURE_11W
4511/**
4512 * \brief Send SA query request action frame to peer
4513 *
4514 * \sa lim_send_sa_query_request_frame
4515 *
4516 *
4517 * \param pMac The global tpAniSirGlobal object
4518 *
4519 * \param transId Transaction identifier
4520 *
4521 * \param peer The Mac address of the station to which this action frame is addressed
4522 *
4523 * \param psessionEntry The PE session entry
4524 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004525 * \return QDF_STATUS_SUCCESS if setup completes successfully
4526 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 */
4528
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004529QDF_STATUS lim_send_sa_query_request_frame(tpAniSirGlobal pMac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 tSirMacAddr peer,
4531 tpPESession psessionEntry)
4532{
4533
4534 tDot11fSaQueryReq frm; /* SA query request action frame */
4535 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004536 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 tpSirMacMgmtHdr pMacHdr;
4538 uint32_t nBytes, nPayload, nStatus;
4539 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304540 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541 uint8_t txFlag = 0;
4542 uint8_t smeSessionId = 0;
4543
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304544 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4546 /* 11w action field is :
4547 action: 0 --> SA Query Request action frame
4548 action: 1 --> SA Query Response action frame */
4549 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4550 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304551 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552
4553 nStatus = dot11f_get_packed_sa_query_req_size(pMac, &frm, &nPayload);
4554 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004555 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 nStatus);
4557 /* We'll fall back on the worst case scenario: */
4558 nPayload = sizeof(tDot11fSaQueryReq);
4559 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004560 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4561 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 }
4563
4564 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304565 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004568 pe_err("Failed to allocate %d bytes for a SA Query Request "
4569 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004570 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004571 }
4572 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304573 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574
4575 /* Copy necessary info to BD */
4576 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4577 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4578
4579 /* Update A3 with the BSSID */
4580 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4581
4582 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4583
4584 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4585 /* in the FC */
4586 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4587
4588 /* Pack 11w SA Query Request frame */
4589 nStatus = dot11f_pack_sa_query_req(pMac,
4590 &frm,
4591 pFrame + sizeof(tSirMacMgmtHdr),
4592 nPayload, &nPayload);
4593
4594 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004595 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004597 /* FIXME - Need to convert to QDF_STATUS */
4598 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 goto returnAfterError;
4600 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004601 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 nStatus);
4603 }
4604
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004605 pe_debug("Sending an SA Query Request to");
4606 lim_print_mac_addr(pMac, peer, LOGD);
4607 pe_debug("Sending an SA Query Request from ");
4608 lim_print_mac_addr(pMac, psessionEntry->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004610 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304612 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4613 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614#endif
4615 ) {
4616 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4617 }
4618 smeSessionId = psessionEntry->smeSessionId;
4619
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304620 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 pPacket,
4622 (uint16_t) nBytes,
4623 TXRX_FRM_802_11_MGMT,
4624 ANI_TXDIR_TODS,
4625 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004626 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304627 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004628 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004629 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 /* Pkt will be freed up by the callback */
4631 return nSirStatus;
4632 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004633 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 }
4635
4636returnAfterError:
4637 cds_packet_free((void *)pPacket);
4638 return nSirStatus;
4639} /* End lim_send_sa_query_request_frame */
4640
4641/**
4642 * \brief Send SA query response action frame to peer
4643 *
4644 * \sa lim_send_sa_query_response_frame
4645 *
4646 *
4647 * \param pMac The global tpAniSirGlobal object
4648 *
4649 * \param transId Transaction identifier received in SA query request action frame
4650 *
4651 * \param peer The Mac address of the AP to which this action frame is addressed
4652 *
4653 * \param psessionEntry The PE session entry
4654 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004655 * \return QDF_STATUS_SUCCESS if setup completes successfully
4656 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 */
4658
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004659QDF_STATUS lim_send_sa_query_response_frame(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 uint8_t *transId, tSirMacAddr peer,
4661 tpPESession psessionEntry)
4662{
4663
Jeff Johnson47d75242018-05-12 15:58:53 -07004664 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004666 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004667 tpSirMacMgmtHdr pMacHdr;
4668 uint32_t nBytes, nPayload, nStatus;
4669 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304670 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 uint8_t txFlag = 0;
4672 uint8_t smeSessionId = 0;
4673
4674 smeSessionId = psessionEntry->smeSessionId;
4675
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304676 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4678 /*11w action field is :
4679 action: 0 --> SA query request action frame
4680 action: 1 --> SA query response action frame */
4681 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4682 /*11w SA query response transId is same as
4683 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304684 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685
4686 nStatus = dot11f_get_packed_sa_query_rsp_size(pMac, &frm, &nPayload);
4687 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004688 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004689 nStatus);
4690 /* We'll fall back on the worst case scenario: */
4691 nPayload = sizeof(tDot11fSaQueryRsp);
4692 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004693 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4694 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 }
4696
4697 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304698 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304700 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004701 pe_err("Failed to allocate %d bytes for a SA query response"
4702 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004703 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 }
4705 /* Paranoia: */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304706 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707
4708 /* Copy necessary info to BD */
4709 lim_populate_mac_header(pMac, pFrame, SIR_MAC_MGMT_FRAME,
4710 SIR_MAC_MGMT_ACTION, peer, psessionEntry->selfMacAddr);
4711
4712 /* Update A3 with the BSSID */
4713 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4714
4715 sir_copy_mac_addr(pMacHdr->bssId, psessionEntry->bssId);
4716
4717 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4718 /* in the FC */
4719 lim_set_protected_bit(pMac, psessionEntry, peer, pMacHdr);
4720
4721 /* Pack 11w SA query response frame */
4722 nStatus = dot11f_pack_sa_query_rsp(pMac,
4723 &frm,
4724 pFrame + sizeof(tSirMacMgmtHdr),
4725 nPayload, &nPayload);
4726
4727 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004728 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004730 /* FIXME - Need to convert to QDF_STATUS */
4731 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 goto returnAfterError;
4733 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004734 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 nStatus);
4736 }
4737
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004738 pe_debug("Sending a SA Query Response to");
Srinivas Girigowdaf936d822017-03-19 23:23:59 -07004739 lim_print_mac_addr(pMac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004741 if ((BAND_5G == lim_get_rf_band(psessionEntry->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742#ifdef WLAN_FEATURE_P2P
Anurag Chouhan6d760662016-02-20 16:05:43 +05304743 || (psessionEntry->pePersona == QDF_P2P_CLIENT_MODE) ||
4744 (psessionEntry->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004745#endif
4746 ) {
4747 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4748 }
4749
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304750 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 psessionEntry->peSessionId, pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304752 qdf_status = wma_tx_frame(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 pPacket,
4754 (uint16_t) nBytes,
4755 TXRX_FRM_802_11_MGMT,
4756 ANI_TXDIR_TODS,
4757 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004758 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304759 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304760 psessionEntry->peSessionId, qdf_status));
4761 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004762 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004763 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 /* Pkt will be freed up by the callback */
4765 return nSirStatus;
4766 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004767 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 }
4769
4770returnAfterError:
4771 cds_packet_free((void *)pPacket);
4772 return nSirStatus;
4773} /* End lim_send_sa_query_response_frame */
4774#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004775
4776/**
4777 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4778 * @mac_ctx: mac context
4779 * @peer_mac: Peer MAC address
4780 * @tid: TID for which addba response is being sent
4781 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004782 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004783 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004784 *
4785 * This function is called when ADDBA request is successful. ADDBA response is
4786 * setup by calling addba_response_setup API and frame is then sent out OTA.
4787 *
4788 * Return: QDF_STATUS
4789 */
4790QDF_STATUS lim_send_addba_response_frame(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004791 tSirMacAddr peer_mac, uint16_t tid,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004792 tpPESession session, uint8_t addba_extn_present,
4793 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004794{
4795
4796 tDot11faddba_rsp frm;
4797 uint8_t *frame_ptr;
4798 tpSirMacMgmtHdr mgmt_hdr;
4799 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004800 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004801 QDF_STATUS qdf_status;
4802 uint8_t tx_flag = 0;
4803 uint8_t sme_sessionid = 0;
4804 uint16_t buff_size, status_code, batimeout;
4805 uint8_t peer_id, dialog_token;
4806 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4807 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004808 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004809
4810 sme_sessionid = session->smeSessionId;
4811
4812 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4813 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004814 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004815 return QDF_STATUS_E_FAILURE;
4816 }
4817
Mohit Khannac4c22252017-11-20 11:06:33 -08004818 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4819 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004820 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004821 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004822 return QDF_STATUS_E_FAILURE;
4823 }
4824
4825 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4826 &status_code, &buff_size, &batimeout);
4827
Mohit Khannac4c22252017-11-20 11:06:33 -08004828 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004829 qdf_mem_set((uint8_t *) &frm, sizeof(frm), 0);
4830 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4831 frm.Action.action = SIR_MAC_ADDBA_RSP;
4832
4833 frm.DialogToken.token = dialog_token;
4834 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004835 if (mac_ctx->reject_addba_req) {
4836 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4837 pe_err("refused addba req");
4838 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004839 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004840 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004841 if (mac_ctx->usr_cfg_ba_buff_size)
4842 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004843
4844 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4845 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4846
4847 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4848 if (session->active_ba_64_session) {
4849 frm.addba_param_set.buff_size =
4850 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4851 }
4852 } else if (!session->active_ba_64_session) {
4853 session->active_ba_64_session = true;
4854 }
Arif Hussain0e246802018-05-01 18:13:44 -07004855 if (mac_ctx->is_usr_cfg_amsdu_enabled)
4856 frm.addba_param_set.amsdu_supp = amsdu_support;
4857 else
4858 frm.addba_param_set.amsdu_supp = 0;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004859 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004860 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004861 if (addba_extn_present) {
4862 frm.addba_extn_element.present = 1;
4863 frm.addba_extn_element.no_fragmentation = 1;
4864 if (lim_is_session_he_capable(session)) {
4865 he_frag = lim_get_session_he_frag_cap(session);
4866 if (he_frag != 0) {
4867 frm.addba_extn_element.no_fragmentation = 0;
4868 frm.addba_extn_element.he_frag_operation =
4869 he_frag;
4870 }
4871 }
4872 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004873
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004874 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004875 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004876 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004877 tid, frm.DialogToken.token, frm.Status.status,
4878 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004879 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4880 addba_extn_present,
4881 lim_is_session_he_capable(session),
4882 frm.addba_extn_element.no_fragmentation,
4883 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004884
4885 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4886 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004887 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004888 status);
4889 /* We'll fall back on the worst case scenario: */
4890 payload_size = sizeof(tDot11faddba_rsp);
4891 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004892 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 -08004893 }
4894
4895 num_bytes = payload_size + sizeof(*mgmt_hdr);
4896 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4897 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004898 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004899 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4900 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004901 return QDF_STATUS_E_FAILURE;
4902 }
4903 qdf_mem_set(frame_ptr, num_bytes, 0);
4904
4905 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4906 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4907
4908 /* Update A3 with the BSSID */
4909 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4910 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4911
4912 /* ADDBA Response is a robust mgmt action frame,
4913 * set the "protect" (aka WEP) bit in the FC
4914 */
4915 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4916
4917 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4918 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4919 &payload_size);
4920
4921 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004922 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004923 status);
4924 qdf_status = QDF_STATUS_E_FAILURE;
4925 goto error_addba_rsp;
4926 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004927 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004928 status);
4929 }
4930
4931
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004932 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004933#ifdef WLAN_FEATURE_P2P
4934 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4935 (session->pePersona == QDF_P2P_GO_MODE)
4936#endif
4937 ) {
4938 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4939 }
4940
4941 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4942 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004943 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4944 (uint16_t)num_bytes,
4945 TXRX_FRM_802_11_MGMT,
4946 ANI_TXDIR_TODS, 7,
4947 NULL, frame_ptr,
4948 lim_addba_rsp_tx_complete_cnf,
4949 tx_flag, sme_sessionid,
4950 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004951 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4952 session->peSessionId, qdf_status));
4953 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004954 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004955 qdf_status);
4956 qdf_status = QDF_STATUS_E_FAILURE;
4957 /*
4958 * wma_tx_frame free memory in certain cases, free pkt_ptr
4959 * only if not freed already.
4960 */
4961 if (pkt_ptr)
4962 cds_packet_free((void *)pkt_ptr);
4963 return qdf_status;
4964 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004965 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004966 }
4967
4968error_addba_rsp:
4969 cds_packet_free((void *)pkt_ptr);
4970 return qdf_status;
4971}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304972
4973/**
4974 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4975 * @mac_ctx Pointer to Global MAC structure
4976 * @mb_msg: Received message info
4977 * @msg_len: Received message length
4978 * @packet: Packet to be transmitted
4979 * @frame: Received frame
4980 *
4981 * Return: None
4982 */
4983static void lim_tx_mgmt_frame(tpAniSirGlobal mac_ctx,
4984 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4985 void *packet, uint8_t *frame)
4986{
4987 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4988 QDF_STATUS qdf_status;
4989 uint8_t sme_session_id = 0;
4990 tpPESession session;
4991 uint16_t auth_ack_status;
4992 enum rateid min_rid = RATEID_DEFAULT;
4993
4994 sme_session_id = mb_msg->session_id;
4995 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
4996 if (session == NULL) {
4997 pe_err("session not found for given sme session");
4998 return;
4999 }
5000
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05305001 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
5002 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305003
5004 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
5005 min_rid = lim_get_min_session_txrate(session);
5006
5007 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
5008 (uint16_t)msg_len,
5009 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
5010 7, lim_tx_complete, frame,
5011 lim_auth_tx_complete_cnf,
5012 0, sme_session_id, false, 0, min_rid);
5013 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
5014 session->peSessionId, qdf_status));
5015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05305016 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
5017 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305018 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
5019 auth_ack_status = SENT_FAIL;
5020 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005021 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305022 /* Pkt will be freed up by the callback */
5023 }
5024}
5025
5026void lim_send_mgmt_frame_tx(tpAniSirGlobal mac_ctx,
5027 struct scheduler_msg *msg)
5028{
5029 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5030 uint32_t msg_len;
5031 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5032 uint8_t sme_session_id;
5033 QDF_STATUS qdf_status;
5034 uint8_t *frame;
5035 void *packet;
5036
5037 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5038 pe_debug("sending fc->type: %d fc->subType: %d",
5039 fc->type, fc->subType);
5040
5041 sme_session_id = mb_msg->session_id;
5042
5043 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5044 (void **)&packet);
5045 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5046 pe_err("call to bufAlloc failed for AUTH frame");
5047 return;
5048 }
5049
5050 qdf_mem_copy(frame, mb_msg->data, msg_len);
5051
5052 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5053}