blob: 45123243c1f5980e92d1f7ec63d47b00306adbbd [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302 * Copyright (c) 2011-2019 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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080030#include "utils_api.h"
31#include "lim_types.h"
32#include "lim_utils.h"
33#include "lim_security_utils.h"
34#include "lim_prop_exts_utils.h"
35#include "dot11f.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "sch_api.h"
37#include "lim_send_messages.h"
38#include "lim_assoc_utils.h"
39#include "lim_ft.h"
40#ifdef WLAN_FEATURE_11W
41#include "wni_cfg.h"
42#endif
43
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053046#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053047#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053051#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052
53#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080054#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070055#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053056#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070057#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058
59/**
60 *
61 * \brief This function is called to add the sequence number to the
62 * management frames
63 *
Jeff Johnson99f25042018-11-21 22:49:06 -080064 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065 *
66 * \param pMacHdr Pointer to MAC management header
67 *
68 * The pMacHdr argument points to the MAC management header. The
Jeff Johnson99f25042018-11-21 22:49:06 -080069 * sequence number stored in the mac structure will be incremented
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 * and updated to the MAC management header. The start sequence
71 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
72 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
73 * number will roll over.
74 *
75 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080076static void lim_add_mgmt_seq_num(struct mac_context *mac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077{
Jeff Johnson99f25042018-11-21 22:49:06 -080078 if (mac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
79 mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 }
81
Jeff Johnson99f25042018-11-21 22:49:06 -080082 mac->mgmtSeqNum++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083
Jeff Johnson99f25042018-11-21 22:49:06 -080084 pMacHdr->seqControl.seqNumLo = (mac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 pMacHdr->seqControl.seqNumHi =
Jeff Johnson99f25042018-11-21 22:49:06 -080086 ((mac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087}
88
89/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090 * lim_populate_mac_header() - Fill in 802.11 header of frame
91 *
92 * @mac_ctx: Pointer to Global MAC structure
93 * @buf: Pointer to the frame buffer that needs to be populate
94 * @type: 802.11 Type of the frame
95 * @sub_type: 802.11 Subtype of the frame
96 * @peer_addr: dst address
97 * @self_mac_addr: local mac address
98 *
99 * This function is called by various LIM modules to prepare the
100 * 802.11 frame MAC header
101 *
102 * The buf argument points to the beginning of the frame buffer to
103 * which - a) The 802.11 MAC header is set b) Following this MAC header
104 * will be the MGMT frame payload The payload itself is populated by the
105 * caller API
106 *
107 * Return: None
108 */
109
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800110void lim_populate_mac_header(struct mac_context *mac_ctx, uint8_t *buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
112 tSirMacAddr self_mac_addr)
113{
114 tpSirMacMgmtHdr mac_hdr;
115
116 /* Prepare MAC management header */
117 mac_hdr = (tpSirMacMgmtHdr) (buf);
118
119 /* Prepare FC */
120 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
121 mac_hdr->fc.type = type;
122 mac_hdr->fc.subType = sub_type;
123
124 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530125 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
127
128 /* Prepare Address 2 */
129 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
130
131 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530132 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
134
135 /* Prepare sequence number */
136 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700137 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 mac_hdr->seqControl.seqNumLo,
139 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
140}
141
142/**
143 * lim_send_probe_req_mgmt_frame() - send probe request management frame
144 * @mac_ctx: Pointer to Global MAC structure
145 * @ssid: SSID to be sent in Probe Request frame
146 * @bssid: BSSID to be sent in Probe Request frame
147 * @channel: Channel # on which the Probe Request is going out
148 * @self_macaddr: self MAC address
149 * @dot11mode: self dotllmode
150 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
151 * frame
152 * @additional_ie: if additional_ielen is non zero, include this field in the
153 * Probe Request frame
154 *
155 * This function is called by various LIM modules to send Probe Request frame
156 * during active scan/learn phase.
157 * Probe request is sent out in the following scenarios:
158 * --heartbeat failure: session needed
159 * --join req: session needed
160 * --foreground scan: no session
161 * --background scan: no session
162 * --sch_beacon_processing: to get EDCA parameters: session needed
163 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700164 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700166QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800167lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 tSirMacSSid *ssid,
169 tSirMacAddr bssid,
170 uint8_t channel,
171 tSirMacAddr self_macaddr,
172 uint32_t dot11mode,
Jeff Johnson919f2c32019-01-16 11:22:24 -0800173 uint16_t *additional_ielen,
174 uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175{
176 tDot11fProbeRequest pr;
177 uint32_t status, bytes, payload;
178 uint8_t *frame;
179 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530180 QDF_STATUS qdf_status;
Jeff Johnsona7815652018-11-18 22:58:30 -0800181 struct pe_session *pesession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700183 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 uint8_t txflag = 0;
185 uint8_t sme_sessionid = 0;
186 bool is_vht_enabled = false;
187 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700188 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530189 bool extracted_ext_cap_flag = false;
190 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700191 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530192 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193
Arif Hussain4c265132018-04-23 18:55:26 -0700194 if (additional_ielen)
195 addn_ielen = *additional_ielen;
196
Jeff Johnson919f2c32019-01-16 11:22:24 -0800197 /*
198 * The probe req should not send 11ac capabilities if band is
199 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
200 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
201 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 */
203 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530204 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530205 (MLME_DOT11_MODE_11AC == dot11mode ||
206 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
207 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 /*
209 * session context may or may not be present, when probe request needs
210 * to be sent out. Following cases exist:
211 * --heartbeat failure: session needed
212 * --join req: session needed
213 * --foreground scan: no session
214 * --background scan: no session
215 * --sch_beacon_processing: to get EDCA parameters: session needed
216 * If session context does not exist, some IEs will be populated from
217 * CFGs, e.g. Supported and Extended rate set IEs
218 */
219 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
220
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700221 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 sme_sessionid = pesession->smeSessionId;
223
224 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
225 /* and then hand it off to 'dot11f_pack_probe_request' (for */
226 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800227 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228
229 /* & delegating to assorted helpers: */
230 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
231
232 if (addn_ielen && additional_ie)
233 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
234
235 /*
236 * Don't include 11b rate if it is a P2P serach or probe request is
237 * sent by P2P Client
238 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700239 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530240 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 /*
242 * In the below API pass channel number > 14, do that it fills
243 * only 11a rates in supported rates
244 */
245 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
246 pesession);
247 } else {
248 populate_dot11f_supp_rates(mac_ctx, channel,
249 &pr.SuppRates, pesession);
250
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530251 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
253 &pr.ExtSuppRates);
254 }
255 }
256
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 /*
258 * Table 7-14 in IEEE Std. 802.11k-2008 says
259 * DS params "can" be present in RRM is disabled and "is" present if
260 * RRM is enabled. It should be ok even if we add it into probe req when
261 * RRM is not enabled.
262 */
263 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
264 /* Call RRM module to get the tx power for management used. */
265 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
266 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
267
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700269 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
271 /* Include HT Capability IE */
272 if (pesession->htCapability)
273 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700274 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 if (IS_DOT11_MODE_HT(dot11mode))
276 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
277 }
278
279 /*
280 * Set channelbonding information as "disabled" when tunned to a
281 * 2.4 GHz channel
282 */
283 if (channel <= SIR_11B_CHANNEL_END) {
284 if (mac_ctx->roam.configParam.channelBondingMode24GHz
285 == PHY_SINGLE_CHANNEL_CENTERED) {
286 pr.HTCaps.supportedChannelWidthSet =
287 eHT_CHANNEL_WIDTH_20MHZ;
288 pr.HTCaps.shortGI40MHz = 0;
289 } else {
290 pr.HTCaps.supportedChannelWidthSet =
291 eHT_CHANNEL_WIDTH_40MHZ;
292 }
293 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700294 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
296 /* Include VHT Capability IE */
297 if (pesession->vhtCapability) {
298 populate_dot11f_vht_caps(mac_ctx, pesession,
299 &pr.VHTCaps);
300 is_vht_enabled = true;
301 }
302 } else {
303 if (IS_DOT11_MODE_VHT(dot11mode)) {
304 populate_dot11f_vht_caps(mac_ctx, pesession,
305 &pr.VHTCaps);
306 is_vht_enabled = true;
307 }
308 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700309 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
311 pesession);
312
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700313 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800314 lim_update_session_he_capable(mac_ctx, pesession);
315
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700316 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700317 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800318
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700319 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530320 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
321 sizeof(tDot11fIEExtCap));
322 sir_status = lim_strip_extcap_update_struct(mac_ctx,
323 additional_ie,
324 &addn_ielen,
325 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700326 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700327 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530328 } else {
329 struct s_ext_cap *p_ext_cap =
330 (struct s_ext_cap *)
331 extracted_ext_cap.bytes;
332 if (p_ext_cap->interworking_service)
333 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800334 extracted_ext_cap.num_bytes =
335 lim_compute_ext_cap_ie_length
336 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530337 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800338 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700339 if (additional_ielen)
340 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530341 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530342 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
343 SIR_MAC_QCN_OUI_TYPE_SIZE,
344 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530346 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -0700347 if (!qcn_ie)
348 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie, QCN_IE_ATTR_ID_ALL);
349 else
350 populate_dot11f_qcn_ie(mac_ctx, &pr.qcn_ie,
351 QCN_IE_ATTR_ID_VHT_MCS11);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
Hu Wang411e0cc2016-10-28 14:56:01 +0800353 /*
354 * Extcap IE now support variable length, merge Extcap IE from addn_ie
355 * may change the frame size. Therefore, MUST merge ExtCap IE before
356 * dot11f get packed payload size.
357 */
358 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800359 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800360
361 /* That's it-- now we pack it. First, how much space are we going to */
362 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
363 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700364 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800365 status);
366 /* We'll fall back on the worst case scenario: */
367 payload = sizeof(tDot11fProbeRequest);
368 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700369 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800370 status);
371 }
372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
374
375 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530376 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530378 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700379 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700380 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 }
382 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800383 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384
385 /* Next, we fill out the buffer descriptor: */
386 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
387 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
388
389 /* That done, pack the Probe Request: */
390 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
391 sizeof(tSirMacMgmtHdr),
392 payload, &payload);
393 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700394 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700396 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700398 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400 /* Append any AddIE if present. */
401 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530402 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 additional_ie, addn_ielen);
404 payload += addn_ielen;
405 }
406
407 /* If this probe request is sent during P2P Search State, then we need
408 * to send it at OFDM rate.
409 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530410 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 /*
412 * For unicast probe req mgmt from Join function we don't set
413 * above variables. So we need to add one more check whether it
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530414 * is opmode is P2P_CLIENT or not
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530416 ((pesession) && (QDF_P2P_CLIENT_MODE == pesession->opmode)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530419 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 wma_tx_frame(mac_ctx, packet,
421 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
422 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
423 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700424 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530425 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700426 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 }
430
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700431 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432} /* End lim_send_probe_req_mgmt_frame. */
433
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800434static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 uint8_t *addIE, uint16_t *addnIELen,
436 uint8_t probeReqP2pIe)
437{
438 /* If Probe request doesn't have P2P IE, then take out P2P IE
439 from additional IE */
440 if (!probeReqP2pIe) {
441 uint8_t *tempbuf = NULL;
442 uint16_t tempLen = 0;
443 int left = *addnIELen;
444 uint8_t *ptr = addIE;
445 uint8_t elem_id, elem_len;
446
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700447 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700448 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700449 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 }
451
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700453 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700454 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
456 while (left >= 2) {
457 elem_id = ptr[0];
458 elem_len = ptr[1];
459 left -= 2;
460 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700461 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530463 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700464 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700466 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 (memcmp
468 (&ptr[2], SIR_MAC_P2P_OUI,
469 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530470 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 elem_len + 2);
472 tempLen += (elem_len + 2);
473 }
474 left -= elem_len;
475 ptr += (elem_len + 2);
476 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530477 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530479 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700481 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482}
483
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800485lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 tSirMacAddr peer_macaddr,
487 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700488 struct pe_session *pe_session,
489 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490{
491 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700492 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800493 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 tpSirMacMgmtHdr mac_hdr;
495 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700496 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530497 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 uint32_t addn_ie_present = false;
499
500 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530501 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 uint8_t tx_flag = 0;
503 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700504 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 uint8_t noalen = 0;
506 uint8_t total_noalen = 0;
507 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
508 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
509 uint8_t sme_sessionid = 0;
510 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530511 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530512 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
514 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700515 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 return;
517
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700518 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 return;
520
521 /*
522 * In case when cac timer is running for this SAP session then
523 * avoid sending probe rsp out. It is violation of dfs specification.
524 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530525 if (((pe_session->opmode == QDF_SAP_MODE) ||
526 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530528 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 FL("CAC timer is running, probe response dropped"));
530 return;
531 }
532 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530533 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700534 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 /*
538 * Fill out 'frm', after which we'll just hand the struct off to
539 * 'dot11f_pack_probe_response'.
540 */
hangtian127c9532019-01-12 13:29:07 +0800541 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542
543 /*
544 * Timestamp to be updated by TFP, below.
545 *
546 * Beacon Interval:
547 */
548 if (LIM_IS_AP_ROLE(pe_session)) {
549 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800550 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530552 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800553 frm->BeaconInterval.interval = (uint16_t) cfg;
554 }
555
556 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
557 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
558 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
559 &frm->SuppRates, pe_session);
560
Liangwei Dong419d7302019-07-15 15:38:28 +0800561 populate_dot11f_ds_params(
562 mac_ctx, &frm->DSParams,
563 wlan_reg_freq_to_chan(mac_ctx->pdev,
564 pe_session->curr_op_freq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
566
567 if (LIM_IS_AP_ROLE(pe_session)) {
568 if (pe_session->wps_state != SAP_WPS_DISABLED)
569 populate_dot11f_probe_res_wpsi_es(mac_ctx,
570 &frm->WscProbeRes,
571 pe_session);
572 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530573 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
574 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 if (wps_ap)
576 populate_dot11f_wsc_in_probe_res(mac_ctx,
577 &frm->WscProbeRes);
578
579 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
580 eLIM_WSC_ENROLL_BEGIN) {
581 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
582 &frm->WscProbeRes);
583 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
584 eLIM_WSC_ENROLL_IN_PROGRESS;
585 }
586
587 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
588 eLIM_WSC_ENROLL_END) {
589 de_populate_dot11f_wsc_registrar_info_in_probe_res(
590 mac_ctx, &frm->WscProbeRes);
591 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
592 eLIM_WSC_ENROLL_NOOP;
593 }
594 }
595
596 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
597 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
598
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530599 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
601
602 populate_dot11f_ext_supp_rates(mac_ctx,
603 POPULATE_DOT11F_RATES_OPERATIONAL,
604 &frm->ExtSuppRates, pe_session);
605
606 /* Populate HT IEs, when operating in 11n */
607 if (pe_session->htCapability) {
608 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
609 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
610 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700612 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
614 populate_dot11f_vht_operation(mac_ctx, pe_session,
615 &frm->VHTOperation);
616 /*
617 * we do not support multi users yet.
618 * populate_dot11f_vht_ext_bss_load( mac_ctx,
619 * &frm.VHTExtBssLoad );
620 */
621 is_vht_enabled = true;
622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800624 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700625 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800626 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700627 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800628 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700629 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800630 }
631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
633 pe_session);
634
635 if (pe_session->pLimStartBssReq) {
636 populate_dot11f_wpa(mac_ctx,
637 &(pe_session->pLimStartBssReq->rsnIE),
638 &frm->WPA);
639 populate_dot11f_rsn_opaque(mac_ctx,
640 &(pe_session->pLimStartBssReq->rsnIE),
641 &frm->RSNOpaque);
642 }
643
644 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
645 &frm->WMMCaps, pe_session);
646
647#if defined(FEATURE_WLAN_WAPI)
648 if (pe_session->pLimStartBssReq)
649 populate_dot11f_wapi(mac_ctx,
650 &(pe_session->pLimStartBssReq->rsnIE),
651 &frm->WAPI);
652#endif /* defined(FEATURE_WLAN_WAPI) */
653
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500654 /*
655 * Only use CFG for non-listen mode. This CFG is not working for
656 * concurrency. In listening mode, probe rsp IEs is passed in
657 * the message from SME to PE.
658 */
659 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800660 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661
662 if (addn_ie_present) {
663
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530664 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800665 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700666 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800670 pe_session->add_ie_params.probeRespData_buff,
671 pe_session->add_ie_params.probeRespDataLen);
672 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700674 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700676 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 goto err_ret;
678 }
679
680 sir_status = lim_strip_extcap_update_struct(mac_ctx,
681 add_ie, &addn_ie_len,
682 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700683 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700684 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530685 } else {
686 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 }
688
689 bytes = bytes + addn_ie_len;
690
691 if (preq_p2pie)
692 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
693 addn_ie_len);
694
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700695 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 /* get NoA attribute stream P2P IE */
697 noalen = lim_get_noa_attr_stream(mac_ctx,
698 noa_stream, pe_session);
699 if (noalen != 0) {
700 total_noalen =
701 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
702 &noa_stream[0], noalen);
703 bytes = bytes + total_noalen;
704 }
705 }
706 }
707
Hu Wang411e0cc2016-10-28 14:56:01 +0800708 /*
709 * Extcap IE now support variable length, merge Extcap IE from addn_ie
710 * may change the frame size. Therefore, MUST merge ExtCap IE before
711 * dot11f get packed payload size.
712 */
713 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800714 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
715 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800716
717 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
718 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700719 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800720 status);
721 /* We'll fall back on the worst case scenario: */
722 payload = sizeof(tDot11fProbeResponse);
723 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700724 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800725 status);
726 }
727
728 bytes += payload + sizeof(tSirMacMgmtHdr);
729
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530730 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530732 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700733 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 goto err_ret;
735 }
736 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800737 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
739 /* Next, we fill out the buffer descriptor: */
740 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
741 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530742 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743
744 mac_hdr = (tpSirMacMgmtHdr) frame;
745
746 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 /* That done, pack the Probe Response: */
749 status =
750 dot11f_pack_probe_response(mac_ctx, frm,
751 frame + sizeof(tSirMacMgmtHdr),
752 payload, &payload);
753 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700754 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 status);
756 goto err_ret;
757 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700758 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 }
760
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700761 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530762 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530765 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 &add_ie[0], addn_ie_len);
767
768 if (noalen != 0) {
769 if (total_noalen >
770 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700771 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 total_noalen);
773 goto err_ret;
774 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530775 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 &noa_ie[0], total_noalen);
777 }
778 }
779
Liangwei Dong419d7302019-07-15 15:38:28 +0800780 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
781 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
782 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
784
785 /* Queue Probe Response frame in high priority WQ */
Jeff Johnson59429b02018-11-07 13:53:18 -0800786 qdf_status = wma_tx_frame(mac_ctx, packet,
787 (uint16_t)bytes,
788 TXRX_FRM_802_11_MGMT,
789 ANI_TXDIR_TODS,
790 7, lim_tx_complete, frame, tx_flag,
791 sme_sessionid, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
793 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700795 pe_err("Could not send Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700797 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530798 qdf_mem_free(add_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530800 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return;
802
803err_ret:
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700804 if (add_ie)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530805 qdf_mem_free(add_ie);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700806 if (frm)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_free(frm);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700808 if (packet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 cds_packet_free((void *)packet);
810 return;
811
812} /* End lim_send_probe_rsp_mgmt_frame. */
813
814void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800815lim_send_addts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 tSirMacAddr peerMacAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800817 tSirAddtsReqInfo *pAddTS, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818{
819 uint16_t i;
820 uint8_t *pFrame;
821 tDot11fAddTSRequest AddTSReq;
822 tDot11fWMMAddTSRequest WMMAddTSReq;
823 uint32_t nPayload, nBytes, nStatus;
824 tpSirMacMgmtHdr pMacHdr;
825 void *pPacket;
826#ifdef FEATURE_WLAN_ESE
827 uint32_t phyMode;
828#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 uint8_t txFlag = 0;
831 uint8_t smeSessionId = 0;
832
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700833 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 return;
835 }
836
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800837 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 if (!pAddTS->wmeTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +0800840 qdf_mem_zero((uint8_t *) &AddTSReq, sizeof(AddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700842 AddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 AddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700844 AddTSReq.Category.category = ACTION_CATEGORY_QOS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 if (pAddTS->lleTspecPresent) {
846 populate_dot11f_tspec(&pAddTS->tspec, &AddTSReq.TSPEC);
847 } else {
848 populate_dot11f_wmmtspec(&pAddTS->tspec,
849 &AddTSReq.WMMTSPEC);
850 }
851
852 if (pAddTS->lleTspecPresent) {
853 AddTSReq.num_WMMTCLAS = 0;
854 AddTSReq.num_TCLAS = pAddTS->numTclas;
855 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800856 populate_dot11f_tclas(mac, &pAddTS->tclasInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 &AddTSReq.TCLAS[i]);
858 }
859 } else {
860 AddTSReq.num_TCLAS = 0;
861 AddTSReq.num_WMMTCLAS = pAddTS->numTclas;
862 for (i = 0; i < pAddTS->numTclas; ++i) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800863 populate_dot11f_wmmtclas(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 &pAddTS->tclasInfo[i],
865 &AddTSReq.WMMTCLAS[i]);
866 }
867 }
868
869 if (pAddTS->tclasProcPresent) {
870 if (pAddTS->lleTspecPresent) {
871 AddTSReq.TCLASSPROC.processing =
872 pAddTS->tclasProc;
873 AddTSReq.TCLASSPROC.present = 1;
874 } else {
875 AddTSReq.WMMTCLASPROC.version = 1;
876 AddTSReq.WMMTCLASPROC.processing =
877 pAddTS->tclasProc;
878 AddTSReq.WMMTCLASPROC.present = 1;
879 }
880 }
881
882 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800883 dot11f_get_packed_add_ts_request_size(mac, &AddTSReq, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700885 pe_err("Failed to calculate the packed size for an Add TS Request (0x%08x)",
886 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 /* We'll fall back on the worst case scenario: */
888 nPayload = sizeof(tDot11fAddTSRequest);
889 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700890 pe_warn("There were warnings while calculating the packed size for an Add TS Request (0x%08x)",
891 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 }
893 } else {
hangtian127c9532019-01-12 13:29:07 +0800894 qdf_mem_zero((uint8_t *) &WMMAddTSReq, sizeof(WMMAddTSReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895
Srinivas Girigowda03cebc32019-05-17 16:50:31 -0700896 WMMAddTSReq.Action.action = QOS_ADD_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -0700898 WMMAddTSReq.Category.category = ACTION_CATEGORY_WMM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800899
900 /* WMM spec 2.2.10 - status code is only filled in for ADDTS response */
901 WMMAddTSReq.StatusCode.statusCode = 0;
902
903 populate_dot11f_wmmtspec(&pAddTS->tspec, &WMMAddTSReq.WMMTSPEC);
904#ifdef FEATURE_WLAN_ESE
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800905 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906
907 if (phyMode == WNI_CFG_PHY_MODE_11G
908 || phyMode == WNI_CFG_PHY_MODE_11A) {
909 pAddTS->tsrsIE.rates[0] = TSRS_11AG_RATE_6MBPS;
910 } else {
911 pAddTS->tsrsIE.rates[0] = TSRS_11B_RATE_5_5MBPS;
912 }
Jeff Johnson99f25042018-11-21 22:49:06 -0800913 populate_dot11_tsrsie(mac, &pAddTS->tsrsIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 &WMMAddTSReq.ESETrafStrmRateSet,
915 sizeof(uint8_t));
916#endif
917 /* fillWmeTspecIE */
918
919 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -0800920 dot11f_get_packed_wmm_add_ts_request_size(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 &nPayload);
922 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700923 pe_err("Failed to calculate the packed size for a WMM Add TS Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 nStatus);
925 /* We'll fall back on the worst case scenario: */
926 nPayload = sizeof(tDot11fAddTSRequest);
927 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700928 pe_warn("There were warnings while calculating the packed size for a WMM Add TS Request (0x%08x)",
929 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 }
931 }
932
933 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530935 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530937 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700938 pe_err("Failed to allocate %d bytes for an Add TS Request",
939 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 return;
941 }
942 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800943 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944
945 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -0800946 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530947 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 pMacHdr = (tpSirMacMgmtHdr) pFrame;
949
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800950 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800952 lim_set_protected_bit(mac, pe_session, peerMacAddr, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953
954 /* That done, pack the struct: */
955 if (!pAddTS->wmeTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -0800956 nStatus = dot11f_pack_add_ts_request(mac, &AddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 pFrame +
958 sizeof(tSirMacMgmtHdr),
959 nPayload, &nPayload);
960 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700961 pe_err("Failed to pack an Add TS Request "
962 "(0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 cds_packet_free((void *)pPacket);
964 return; /* allocated! */
965 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700966 pe_warn("There were warnings while packing an Add TS Request (0x%08x)",
967 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 }
969 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -0800970 nStatus = dot11f_pack_wmm_add_ts_request(mac, &WMMAddTSReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 pFrame +
972 sizeof(tSirMacMgmtHdr),
973 nPayload, &nPayload);
974 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700975 pe_err("Failed to pack a WMM Add TS Request (0x%08x)",
976 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 cds_packet_free((void *)pPacket);
978 return; /* allocated! */
979 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700980 pe_warn("There were warnings while packing a WMM Add TS Request (0x%08x)",
981 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 }
983 }
984
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700985 pe_debug("Sending an Add TS Request frame to");
Jeff Johnson99f25042018-11-21 22:49:06 -0800986 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987
Liangwei Dong419d7302019-07-15 15:38:28 +0800988 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
989 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
990 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530993 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800994 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -0800995 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800996 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700997 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001000 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 TXRX_FRM_802_11_MGMT,
1002 ANI_TXDIR_TODS,
1003 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001004 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301005 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001006 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001008 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1009 pe_err("Could not send an Add TS Request (%X",
1010 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011} /* End lim_send_addts_req_action_frame. */
1012
1013/**
1014 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1015 * @mac_ctx: Handle for mac context
1016 * @status_code: Status code for assoc response frame
1017 * @aid: Association ID
1018 * @peer_addr: Mac address of requesting peer
1019 * @subtype: Assoc/Reassoc
1020 * @sta: Pointer to station node
1021 * @pe_session: PE session id.
1022 *
1023 * Builds and sends association response frame to the requesting peer.
1024 *
1025 * Return: void
1026 */
1027
1028void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001029lim_send_assoc_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
Jeff Johnsona7815652018-11-18 22:58:30 -08001031 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032{
1033 static tDot11fAssocResponse frm;
1034 uint8_t *frame;
1035 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001036 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 uint8_t lle_mode = 0, addts;
1038 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001039 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301041 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 tUpdateBeaconParams beacon_params;
1043 uint8_t tx_flag = 0;
1044 uint32_t addn_ie_len = 0;
1045 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1046 tpSirAssocReq assoc_req = NULL;
1047 uint8_t sme_session = 0;
1048 bool is_vht = false;
1049 uint16_t stripoff_len = 0;
1050 tDot11fIEExtCap extracted_ext_cap;
1051 bool extracted_flag = false;
1052#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301053 uint8_t retry_int;
1054 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055#endif
1056
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001057 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001058 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 return;
1060 }
1061
1062 sme_session = pe_session->smeSessionId;
1063
hangtian127c9532019-01-12 13:29:07 +08001064 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
1066 limGetQosMode(pe_session, &qos_mode);
1067 limGetWmeMode(pe_session, &wme_mode);
1068
1069 /*
1070 * An Add TS IE is added only if the AP supports it and
1071 * the requesting STA sent a traffic spec.
1072 */
1073 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1074
1075 frm.Status.status = status_code;
1076
1077 frm.AID.associd = aid | LIM_AID_MASK;
1078
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001079 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 populate_dot11f_supp_rates(mac_ctx,
1081 POPULATE_DOT11F_RATES_OPERATIONAL,
1082 &frm.SuppRates, pe_session);
1083 populate_dot11f_ext_supp_rates(mac_ctx,
1084 POPULATE_DOT11F_RATES_OPERATIONAL,
1085 &frm.ExtSuppRates, pe_session);
1086 } else {
1087 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1088 &frm.ExtSuppRates,
1089 sta->supportedRates.llbRates,
1090 sta->supportedRates.llaRates);
1091 }
1092
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001093 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001094 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 assoc_req = (tpSirAssocReq)
1096 pe_session->parsedAssocReq[sta->assocId];
1097 /*
1098 * populate P2P IE in AssocRsp when assocReq from the peer
1099 * includes P2P IE
1100 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001101 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1103 &frm.P2PAssocRes,
1104 assoc_req);
1105 }
1106
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001107 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 if (eHAL_SET == qos_mode) {
1109 if (sta->lleEnabled) {
1110 lle_mode = 1;
1111 populate_dot11f_edca_param_set(mac_ctx,
1112 &frm.EDCAParamSet, pe_session);
1113 }
1114 }
1115
1116 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1117 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1118 pe_session);
1119
1120 if (sta->wsmEnabled)
1121 populate_dot11f_wmm_caps(&frm.WMMCaps);
1122 }
1123
1124 if (sta->mlmStaContext.htCapability &&
1125 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001126 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 populate_dot11f_ht_caps(mac_ctx, pe_session,
1128 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001129 /*
1130 * Check the STA capability and
1131 * update the HTCaps accordingly
1132 */
1133 frm.HTCaps.supportedChannelWidthSet = (
1134 sta->htSupportedChannelWidthSet <
1135 pe_session->htSupportedChannelWidthSet) ?
1136 sta->htSupportedChannelWidthSet :
1137 pe_session->htSupportedChannelWidthSet;
1138 if (!frm.HTCaps.supportedChannelWidthSet)
1139 frm.HTCaps.shortGI40MHz = 0;
1140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301142 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001144 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 +05301145 frm.HTCaps.supportedChannelWidthSet,
1146 frm.HTCaps.mimoPowerSave,
1147 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1148 frm.HTCaps.shortGI40MHz,
1149 frm.HTCaps.dsssCckMode40MHz,
1150 frm.HTCaps.maxRxAMPDUFactor);
1151
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 if (sta->mlmStaContext.vhtCapability &&
1153 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001154 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 populate_dot11f_vht_caps(mac_ctx, pe_session,
1156 &frm.VHTCaps);
1157 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301158 &frm.VHTOperation);
1159 is_vht = true;
Pragaspathi Thilagarajb3472f02019-06-04 14:10:44 +05301160 } else if (sta->mlmStaContext.force_1x1 &&
1161 frm.HTCaps.present) {
1162 /*
1163 * WAR: In P2P GO mode, if the P2P client device
1164 * is only HT capable and not VHT capable, but the P2P
1165 * GO device is VHT capable and advertises 2x2 NSS with
1166 * HT capablity client device, which results in IOT
1167 * issues.
1168 * When GO is operating in DBS mode, GO beacons
1169 * advertise 2x2 capability but include OMN IE to
1170 * indicate current operating mode of 1x1. But here
1171 * peer device is only HT capable and will not
1172 * understand OMN IE.
1173 */
1174 frm.HTInfo.basicMCSSet[1] = 0;
1175 frm.HTCaps.supportedMCSSet[1] = 0;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301176 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001177
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301178 if (pe_session->vhtCapability &&
1179 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001180 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301181 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001182 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301183 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001184 frm.vendor_vht_ie.sub_type =
1185 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301186 frm.vendor_vht_ie.VHTCaps.present = 1;
1187 populate_dot11f_vht_caps(mac_ctx, pe_session,
1188 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001189 populate_dot11f_vht_operation(mac_ctx, pe_session,
1190 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 is_vht = true;
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001192 populate_dot11f_qcn_ie(mac_ctx, &frm.qcn_ie,
1193 QCN_IE_ATTR_ID_ALL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1196 pe_session);
1197
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001198 if (lim_is_sta_he_capable(sta) &&
1199 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001200 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001201 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001202 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001203 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001204 &frm.he_op);
Kiran Kumar Lokereb2ea0272019-08-27 19:16:36 -07001205 populate_dot11f_he_6ghz_cap(mac_ctx, pe_session,
1206 &frm.he_6ghz_band_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001207 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208#ifdef WLAN_FEATURE_11W
1209 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301210 max_retries =
1211 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1212 retry_int =
1213 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1214 populate_dot11f_timeout_interval(mac_ctx,
1215 &frm.TimeoutInterval,
1216 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1217 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 sta->pmfSaQueryRetryCount)
1219 * retry_int);
1220 }
1221#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001222
1223 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1224 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 }
1226
hangtian127c9532019-01-12 13:29:07 +08001227 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
1229 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301230 (pe_session->gLimProtectionControl !=
1231 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1232 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1233 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234
1235 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1236 pe_session);
1237 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1238 pe_session);
1239
1240 /*
1241 * Populate Do11capabilities after updating session with
1242 * Assos req details
1243 */
1244 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1245
Abhishek Singhc70afa32019-09-19 15:17:21 +05301246 beacon_params.bss_idx = pe_session->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247
1248 /* Send message to HAL about beacon parameter change. */
1249 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1250 && beacon_params.paramChangeBitmap) {
1251 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1252 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1253 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254
Arif Hussain1513cb22018-01-05 19:56:31 -08001255 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1256
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001257 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001258 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001261 if (addn_ie_len > 0 &&
1262 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1263 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301264 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001265 pe_session->add_ie_params.assocRespData_buff,
1266 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267
hangtian127c9532019-01-12 13:29:07 +08001268 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1269 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270
1271 stripoff_len = addn_ie_len;
1272 sir_status =
1273 lim_strip_extcap_update_struct
1274 (mac_ctx, &add_ie[0], &stripoff_len,
1275 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001276 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001277 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 } else {
1279 addn_ie_len = stripoff_len;
1280 extracted_flag = true;
1281 }
1282 bytes = bytes + addn_ie_len;
1283 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001284 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 addn_ie_len, assoc_req->addIEPresent);
1286 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001287
1288 /*
1289 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1290 * may change the frame size. Therefore, MUST merge ExtCap IE before
1291 * dot11f get packed payload size.
1292 */
1293 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001294 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1295 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001296
1297 /* Allocate a buffer for this frame: */
1298 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1299 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001300 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001301 status);
1302 return;
1303 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001304 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001305 status);
1306 }
1307
1308 bytes += sizeof(tSirMacMgmtHdr) + payload;
1309
Min Liu0daa0982019-02-01 17:50:44 +08001310 if (sta)
1311 bytes += sta->mlmStaContext.owe_ie_len;
1312
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301313 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301315 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001316 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 return;
1318 }
1319 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001320 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321
1322 /* Next, we fill out the buffer descriptor: */
1323 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1324 (LIM_ASSOC == subtype) ?
1325 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1326 peer_addr,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301327 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 mac_hdr = (tpSirMacMgmtHdr) frame;
1329
1330 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1333 frame + sizeof(tSirMacMgmtHdr),
1334 payload, &payload);
1335 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001336 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 status);
1338 cds_packet_free((void *)packet);
1339 return;
1340 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001341 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 status);
1343 }
1344
1345 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001346 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 status_code, aid);
1348 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001349 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350 status_code, aid);
1351
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301352 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
1354 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 &add_ie[0], addn_ie_len);
1357
Min Liu0daa0982019-02-01 17:50:44 +08001358 if (sta && sta->mlmStaContext.owe_ie_len)
1359 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1360 + addn_ie_len,
1361 sta->mlmStaContext.owe_ie,
1362 sta->mlmStaContext.owe_ie_len);
1363
Liangwei Dong419d7302019-07-15 15:38:28 +08001364 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1365 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1366 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1368
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301369 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001371 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001372 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301374 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 TXRX_FRM_802_11_MGMT,
1376 ANI_TXDIR_TODS,
1377 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001378 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301379 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301380 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301383 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001384 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301385 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
1387 /*
1388 * update the ANI peer station count.
1389 * FIXME_PROTECTION : take care of different type of station
1390 * counter inside this function.
1391 */
1392 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1393
1394}
1395
1396void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001397lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 tSirMacAddr peer,
1399 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001400 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001401 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001402 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403{
1404 uint8_t *pFrame;
1405 tpSirMacMgmtHdr pMacHdr;
1406 tDot11fDelTS DelTS;
1407 tDot11fWMMDelTS WMMDelTS;
1408 uint32_t nBytes, nPayload, nStatus;
1409 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301410 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 uint8_t txFlag = 0;
1412 uint8_t smeSessionId = 0;
1413
Jeff Johnson312348f2018-12-22 13:33:54 -08001414 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001417 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418
1419 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001420 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001422 DelTS.Category.category = ACTION_CATEGORY_QOS;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001423 DelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1425
Jeff Johnson99f25042018-11-21 22:49:06 -08001426 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001428 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1429 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 /* We'll fall back on the worst case scenario: */
1431 nPayload = sizeof(tDot11fDelTS);
1432 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001433 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1434 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 }
1436 } else {
hangtian127c9532019-01-12 13:29:07 +08001437 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07001439 WMMDelTS.Category.category = ACTION_CATEGORY_WMM;
Srinivas Girigowda03cebc32019-05-17 16:50:31 -07001440 WMMDelTS.Action.action = QOS_DEL_TS_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 WMMDelTS.DialogToken.token = 0;
1442 WMMDelTS.StatusCode.statusCode = 0;
1443 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1444 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001445 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001447 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1448 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 /* We'll fall back on the worst case scenario: */
1450 nPayload = sizeof(tDot11fDelTS);
1451 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001452 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1453 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454 }
1455 }
1456
1457 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1458
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301459 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1461 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301462 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001463 pe_err("Failed to allocate %d bytes for an Add TS Response",
1464 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 return;
1466 }
1467 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001468 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469
1470 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001471 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05301472 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1474
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001475 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001477 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478
1479 /* That done, pack the struct: */
1480 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001481 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 pFrame + sizeof(tSirMacMgmtHdr),
1483 nPayload, &nPayload);
1484 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001485 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001486 nStatus);
1487 cds_packet_free((void *)pPacket);
1488 return; /* allocated! */
1489 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001490 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1491 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 }
1493 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001494 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495 pFrame + sizeof(tSirMacMgmtHdr),
1496 nPayload, &nPayload);
1497 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001498 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 nStatus);
1500 cds_packet_free((void *)pPacket);
1501 return; /* allocated! */
1502 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001503 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1504 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 }
1506 }
1507
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001508 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001509 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510
Liangwei Dong419d7302019-07-15 15:38:28 +08001511 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
1512 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
1513 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301516 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001517 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001518 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001519 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001520 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001521 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 TXRX_FRM_802_11_MGMT,
1523 ANI_TXDIR_TODS,
1524 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001525 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301526 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001527 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301529 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001530 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
1532} /* End lim_send_delts_req_action_frame. */
1533
1534/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301535 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1536 * @context: pointer to global mac
1537 * @buf: buffer
1538 * @tx_complete : Sent status
1539 * @params; tx completion params
1540 *
1541 * Return: This returns QDF_STATUS
1542 */
1543
1544static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1545 qdf_nbuf_t buf,
1546 uint32_t tx_complete,
1547 void *params)
1548{
1549 uint16_t assoc_ack_status;
1550 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001551 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301552
1553 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001554 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301555 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001556 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301557 } else {
1558 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001559 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301560 }
1561 if (buf)
1562 qdf_nbuf_free(buf);
1563
1564 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1565 NULL, assoc_ack_status, reason_code);
1566 return QDF_STATUS_SUCCESS;
1567}
1568
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301569#ifdef WLAN_ADAPTIVE_11R
1570/**
1571 * lim_fill_adaptive_11r_ie() - Populate the Vendor secific adaptive 11r
1572 * IE to association request frame
1573 * @pe_session: pointer to PE session
1574 * @ie_buf: buffer to which Adaptive 11r IE will be copied
1575 * @ie_len: length of the Adaptive 11r Vendor specific IE
1576 *
1577 * Return QDF_STATUS
1578 */
1579static QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1580 uint8_t **ie_buf, uint8_t *ie_len)
1581{
1582 uint8_t *buf = NULL, *adaptive_11r_ie = NULL;
1583
1584 if (!pe_session->is_adaptive_11r_connection)
1585 return QDF_STATUS_SUCCESS;
1586
1587 /*
1588 * Vendor specific Adaptive 11r IE to be advertised in Assoc
1589 * req:
1590 * Type 0xDD
1591 * Length 0x0B
1592 * OUI 0x00 0x00 0x0F
1593 * Type 0x22
1594 * subtype 0x00
1595 * Version 0x01
1596 * Length 0x04
1597 * Data 0x00 00 00 01(0th bit is 1 means adaptive 11r is
1598 * supported)
1599 */
1600 adaptive_11r_ie = qdf_mem_malloc(ADAPTIVE_11R_STA_IE_LEN + 2);
1601 if (!adaptive_11r_ie)
1602 return QDF_STATUS_E_FAILURE;
1603
1604 /* Fill the Vendor IE Type (0xDD) */
1605 buf = adaptive_11r_ie;
Srinivas Girigowda8e7ecab2019-05-16 11:31:19 -07001606 *buf = WLAN_ELEMID_VENDOR;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301607 buf++;
1608
1609 /* Fill the Vendor IE length (0x0B) */
1610 *buf = ADAPTIVE_11R_STA_IE_LEN;
1611 buf++;
1612
1613 /*
1614 * Fill the Adaptive 11r Vendor specific OUI(0x00 0x00 0x0F 0x22)
1615 */
1616 qdf_mem_copy(buf, ADAPTIVE_11R_STA_OUI, ADAPTIVE_11R_OUI_LEN);
1617 buf += ADAPTIVE_11R_OUI_LEN;
1618
1619 /* Fill Adaptive 11r Vendor specific Subtype (0x00) */
1620 *buf = ADAPTIVE_11R_OUI_SUBTYPE;
1621 buf++;
1622
1623 /* Fill Adaptive 11r Version (0x01) */
1624 *buf = ADAPTIVE_11R_OUI_VERSION;
1625 buf++;
1626
1627 /* Fill Adaptive 11r IE Data length (0x04) */
1628 *buf = ADAPTIVE_11R_DATA_LEN;
1629 buf++;
1630
1631 /* Fill Adaptive 11r IE Data (0x00 0x00 0x00 0x01) */
1632 qdf_mem_copy(buf, ADAPTIVE_11R_OUI_DATA, ADAPTIVE_11R_DATA_LEN);
1633
1634 *ie_len = ADAPTIVE_11R_STA_IE_LEN + 2;
1635 *ie_buf = adaptive_11r_ie;
1636
1637 return QDF_STATUS_SUCCESS;
1638}
1639
1640#else
1641static inline
1642QDF_STATUS lim_fill_adaptive_11r_ie(struct pe_session *pe_session,
1643 uint8_t **ie_buf, uint8_t *ie_len)
1644{
1645 return QDF_STATUS_SUCCESS;
1646}
1647#endif
1648
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301649/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 * lim_send_assoc_req_mgmt_frame() - Send association request
1651 * @mac_ctx: Handle to MAC context
1652 * @mlm_assoc_req: Association request information
1653 * @pe_session: PE session information
1654 *
1655 * Builds and transmits association request frame to AP.
1656 *
1657 * Return: Void
1658 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001660lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001662 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663{
Naveen Rawat72475db2017-12-13 18:07:35 -08001664 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 tDot11fAssocRequest *frm;
1666 uint16_t caps;
1667 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001668 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001670 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1672 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301673 QDF_STATUS qdf_status;
Srinivas Dasari22397902019-07-29 21:34:10 +05301674 uint16_t add_ie_len, current_len = 0, vendor_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001676 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 uint8_t tx_flag = 0;
1679 uint8_t sme_sessionid = 0;
1680 bool vht_enabled = false;
1681 tDot11fIEExtCap extr_ext_cap;
1682 bool extr_ext_flag = true;
1683 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001684 uint32_t ie_offset = 0;
1685 uint8_t *p_ext_cap = NULL;
1686 tDot11fIEExtCap bcn_ext_cap;
1687 uint8_t *bcn_ie = NULL;
1688 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301689 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001690 enum rateid min_rid = RATEID_DEFAULT;
Srinivas Dasari22397902019-07-29 21:34:10 +05301691 uint8_t *mbo_ie = NULL, *adaptive_11r_ie = NULL, *vendor_ies = NULL;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05301692 uint8_t mbo_ie_len = 0, adaptive_11r_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001694 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001695 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301696 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 return;
1698 }
1699
1700 sme_sessionid = pe_session->smeSessionId;
1701
1702 /* check this early to avoid unncessary operation */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301703 if (!pe_session->lim_join_req) {
1704 pe_err("pe_session->lim_join_req is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301705 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 return;
1707 }
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301708 add_ie_len = pe_session->lim_join_req->addIEAssoc.length;
1709 add_ie = pe_session->lim_join_req->addIEAssoc.addIEdata;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301711 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001712 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301713 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 return;
1715 }
hangtian127c9532019-01-12 13:29:07 +08001716 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301718 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001719 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1720 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1722 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001723 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001725 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726 } else {
1727 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1728 extr_ext_cap.bytes;
1729
1730 if (p_ext_cap->interworking_service)
1731 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001732 extr_ext_cap.num_bytes =
1733 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1734 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 }
1736 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001737 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 extr_ext_flag = false;
1739 }
1740
1741 caps = mlm_assoc_req->capabilityInfo;
1742#if defined(FEATURE_WLAN_WAPI)
1743 /*
1744 * According to WAPI standard:
1745 * 7.3.1.4 Capability Information field
1746 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1747 * in transmitted Association or Reassociation management frames.
1748 * APs ignore the Privacy subfield within received Association and
1749 * Reassociation management frames.
1750 */
1751 if (pe_session->encryptType == eSIR_ED_WPI)
1752 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1753#endif
1754 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1755
1756 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1757 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1758 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1759 &frm->SuppRates, pe_session);
1760
1761 qos_enabled = (pe_session->limQosEnabled) &&
1762 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1763
1764 wme_enabled = (pe_session->limWmeEnabled) &&
1765 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1766
1767 /* We prefer .11e asociations: */
1768 if (qos_enabled)
1769 wme_enabled = false;
1770
1771 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1772 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1773
1774 if (pe_session->lim11hEnable &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301775 pe_session->lim_join_req->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 power_caps = true;
1777
1778 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1779 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1781 LIM_ASSOC, pe_session);
1782
1783 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1785 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1786 if (power_caps == false) {
1787 power_caps = true;
1788 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1789 LIM_ASSOC, pe_session);
1790 }
1791 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001793 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1794 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
1796 populate_dot11f_ext_supp_rates(mac_ctx,
1797 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1798 pe_session);
1799
Gupta, Kapil54a16992016-01-13 19:34:02 +05301800 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1801 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1803 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001804
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 /*
1806 * The join request *should* contain zero or one of the WPA and RSN
1807 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001808 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 * typedef struct sSirRSNie
1810 * {
1811 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001812 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 * } tSirRSNie, *tpSirRSNie;
1814 * So, we should be able to make the following two calls harmlessly,
1815 * since they do nothing if they don't find the given IE in the
1816 * bytestream with which they're provided.
1817 * The net effect of this will be to faithfully transmit whatever
1818 * security IE is in the join request.
1819 * However, if we're associating for the purpose of WPS
1820 * enrollment, and we've been configured to indicate that by
1821 * eliding the WPA or RSN IE, we just skip this:
1822 */
1823 if (add_ie_len && add_ie)
1824 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1825
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001826 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 populate_dot11f_rsn_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301828 &pe_session->lim_join_req->rsnIE,
1829 &frm->RSNOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 populate_dot11f_wpa_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301831 &pe_session->lim_join_req->rsnIE,
1832 &frm->WPAOpaque);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833#if defined(FEATURE_WLAN_WAPI)
1834 populate_dot11f_wapi_opaque(mac_ctx,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301835 &(pe_session->lim_join_req->rsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 &frm->WAPIOpaque);
1837#endif /* defined(FEATURE_WLAN_WAPI) */
1838 }
1839 /* include WME EDCA IE as well */
1840 if (wme_enabled) {
1841 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1842 pe_session, &frm->WMMInfoStation);
1843
1844 if (wsm_enabled)
1845 populate_dot11f_wmm_caps(&frm->WMMCaps);
1846 }
1847
1848 /*
1849 * Populate HT IEs, when operating in 11n and
1850 * when AP is also operating in 11n mode
1851 */
1852 if (pe_session->htCapability &&
1853 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001854 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001856 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1857 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001858 } else if (pe_session->he_with_wep_tkip) {
1859 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1860 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001862 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 +05301863 frm->HTCaps.supportedChannelWidthSet,
1864 frm->HTCaps.mimoPowerSave,
1865 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1866 frm->HTCaps.shortGI40MHz,
1867 frm->HTCaps.dsssCckMode40MHz,
1868 frm->HTCaps.maxRxAMPDUFactor);
1869
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 if (pe_session->vhtCapability &&
1871 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001872 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001874 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1875 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001877 if (pe_session->enableHtSmps &&
1878 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001879 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001880 populate_dot11f_operating_mode(mac_ctx,
1881 &frm->OperatingMode, pe_session);
1882 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001883 } else if (pe_session->he_with_wep_tkip) {
1884 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1885 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001887
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 if (!vht_enabled &&
1889 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001890 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301891 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001892 frm->vendor_vht_ie.sub_type =
1893 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301894 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301895 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301896 pe_session->vht_config.su_beam_formee) {
1897 pe_debug("Disable SU beamformee for vendor IE");
1898 pe_session->vht_config.su_beam_formee = 0;
1899 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301901 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 vht_enabled = true;
1903 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301904 if (pe_session->is_ext_caps_present)
1905 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1906 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907
Kiran Kumar Lokere89f01f02019-08-06 18:22:39 -07001908 populate_dot11f_qcn_ie(mac_ctx, &frm->qcn_ie, QCN_IE_ATTR_ID_ALL);
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301909
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001910 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001911 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001912 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001913 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001914 } else if (pe_session->he_with_wep_tkip) {
1915 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1916 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001917 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301918
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301919 if (pe_session->lim_join_req->is11Rconnection) {
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +05301920 struct bss_description *bssdescr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301922 bssdescr = &pe_session->lim_join_req->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001923 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 (unsigned int) bssdescr->mdie[0],
1925 (unsigned int) bssdescr->mdie[1],
1926 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 populate_mdie(mac_ctx, &frm->MobilityDomain,
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301928 pe_session->lim_join_req->bssDescription.mdie);
Pragaspathi Thilagaraj03839b92019-03-12 17:45:21 +05301929
1930 /*
1931 * IEEE80211-ai [13.2.4 FT initial mobility domain association
1932 * over FILS in an RSN]
1933 * Populate FT IE in association request. This FT IE should be
1934 * same as the FT IE received in auth response frame during the
1935 * FT-FILS authentication.
1936 */
1937 if (lim_is_fils_connection(pe_session))
1938 populate_fils_ft_info(mac_ctx, &frm->FTInfo,
1939 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941
1942#ifdef FEATURE_WLAN_ESE
1943 /*
1944 * ESE Version IE will be included in association request
1945 * when ESE is enabled on DUT through ini and it is also
1946 * advertised by the peer AP to which we are trying to
1947 * associate to.
1948 */
1949 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08001950 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 populate_dot11f_ese_version(&frm->ESEVersion);
1952 /* For ESE Associations fill the ESE IEs */
1953 if (pe_session->isESEconnection &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05301954 pe_session->lim_join_req->isESEFeatureIniEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955#ifndef FEATURE_DISABLE_RM
1956 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1957#endif
1958 }
1959#endif
1960
Hu Wang411e0cc2016-10-28 14:56:01 +08001961 /*
1962 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1963 * may change the frame size. Therefore, MUST merge ExtCap IE before
1964 * dot11f get packed payload size.
1965 */
1966 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001967 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1968
1969 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1970 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1971 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1972 DOT11F_FF_BEACONINTERVAL_LEN +
1973 DOT11F_FF_CAPABILITIES_LEN;
1974
1975 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1976 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1977 bcn_ie = pe_session->beacon + ie_offset;
1978 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001979 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001980 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001981 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001982 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1983 &bcn_ext_cap);
1984 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1985 false);
1986 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001987 /*
1988 * TWT extended capabilities should be populated after the
1989 * intersection of beacon caps and self caps is done because
1990 * the bits for TWT are unique to STA and AP and cannot be
1991 * intersected.
1992 */
1993 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1994 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001995 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001996
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001997 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001998 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001999 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08002000
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302001 if (lim_is_fils_connection(pe_session)) {
2002 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
2003 aes_block_size_len = AES_BLOCK_SIZE;
2004 }
2005
2006 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302007 * MBO IE needs to be appendded at the end of the assoc request
2008 * frame and is not parsed and unpacked by the frame parser
2009 * as the supplicant can send multiple TLVs with same Attribute
2010 * in the MBO IE and the frame parser does not support multiple
2011 * TLVs with same attribute in a single IE.
2012 * Strip off the MBO IE from add_ie and append it at the end.
2013 */
2014 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
2015 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
2016 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002017 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302018 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302019
2020 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07002021 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302022 SIR_MAC_MBO_OUI,
2023 SIR_MAC_MBO_OUI_SIZE,
2024 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
2025 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2026 pe_err("Failed to strip MBO IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302027 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302028 }
2029
2030 /* Include the EID and length fields */
2031 mbo_ie_len = mbo_ie[1] + 2;
2032 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
2033 }
2034
Srinivas Dasari22397902019-07-29 21:34:10 +05302035 /*
2036 * Strip rest of the vendor IEs and append to the assoc request frame.
2037 * Append the IEs just before MBO IEs as MBO IEs have to be at the
2038 * end of the frame.
2039 */
2040 if (wlan_get_ie_ptr_from_eid(WLAN_ELEMID_VENDOR, add_ie, add_ie_len)) {
2041 vendor_ies = qdf_mem_malloc(MAX_VENDOR_IES_LEN + 2);
2042 if (vendor_ies) {
2043 current_len = add_ie_len;
2044 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
2045 WLAN_ELEMID_VENDOR, ONE_BYTE,
2046 NULL,
2047 0,
2048 vendor_ies,
2049 MAX_VENDOR_IES_LEN);
2050 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2051 pe_err("Failed to strip Vendor IEs");
2052 goto end;
2053 }
2054
2055 vendor_ie_len = current_len - add_ie_len;
2056 pe_debug("Stripped vendor IEs of size: %u",
2057 current_len);
2058 }
2059 }
2060
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302061 qdf_status = lim_fill_adaptive_11r_ie(pe_session, &adaptive_11r_ie,
2062 &adaptive_11r_ie_len);
2063 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2064 pe_err("Failed to fill adaptive 11r IE");
Srinivas Dasari22397902019-07-29 21:34:10 +05302065 goto end;
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302066 }
2067
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302068 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302069 * Do unpack to populate the add_ie buffer to frm structure
2070 * before packing the frm structure. In this way, the IE ordering
2071 * which the latest 802.11 spec mandates is maintained.
2072 */
Naveen Rawat72475db2017-12-13 18:07:35 -08002073 if (add_ie_len) {
2074 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302075 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08002076 if (DOT11F_FAILED(ret)) {
2077 pe_err("unpack failed, ret: 0x%x", ret);
2078 goto end;
2079 }
2080 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
2083 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002084 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085 status);
2086 /* We'll fall back on the worst case scenario: */
2087 payload = sizeof(tDot11fAssocRequest);
2088 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002089 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 status);
2091 }
2092
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302093 bytes = payload + sizeof(tSirMacMgmtHdr) +
Srinivas Dasari22397902019-07-29 21:34:10 +05302094 aes_block_size_len + mbo_ie_len + adaptive_11r_ie_len +
2095 vendor_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302097 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302099 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002100 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101
2102 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302103 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 pe_session->peSessionId,
2105 pe_session->limMlmState));
2106
2107 /* Update PE session id */
2108 assoc_cnf.sessionId = pe_session->peSessionId;
2109
2110 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
2111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
2113 (uint32_t *) &assoc_cnf);
2114
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302115 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116 }
2117 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002118 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119
2120 /* Next, we fill out the buffer descriptor: */
2121 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2122 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302123 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 /* That done, pack the Assoc Request: */
2125 status = dot11f_pack_assoc_request(mac_ctx, frm,
2126 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
2127 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002128 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302130 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002132 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 }
2134
Srinivas Dasari22397902019-07-29 21:34:10 +05302135 /* Copy the vendor IEs to the end of the frame */
2136 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2137 vendor_ies, vendor_ie_len);
2138 payload = payload + vendor_ie_len;
2139
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302140 /* Copy the MBO IE to the end of the frame */
2141 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2142 mbo_ie, mbo_ie_len);
2143 payload = payload + mbo_ie_len;
2144
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302145 /*
2146 * Copy the Vendor specific Adaptive 11r IE to end of the
2147 * assoc request frame
2148 */
2149 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2150 adaptive_11r_ie, adaptive_11r_ie_len);
2151 payload = payload + adaptive_11r_ie_len;
2152
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002153 if (pe_session->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302154 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002156 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 }
2158
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302159 if (lim_is_fils_connection(pe_session)) {
2160 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2161 frame, &payload);
2162 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2163 cds_packet_free((void *)packet);
Srinivas Dasari22397902019-07-29 21:34:10 +05302164 goto end;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302165 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 }
2167
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302168 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002169 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170 /*
2171 * Store the Assoc request. This is sent to csr/hdd in
2172 * join cnf response.
2173 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302174 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 frame + sizeof(tSirMacMgmtHdr), payload);
2176 pe_session->assocReqLen = payload;
2177 }
2178
Liangwei Dong419d7302019-07-15 15:38:28 +08002179 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
2180 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2181 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2183
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302184 if (pe_session->opmode == QDF_P2P_CLIENT_MODE ||
2185 pe_session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2187
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302189 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302191
2192 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002193 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002194 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002195 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002196 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002197 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302198 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302199 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2201 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302202 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002203 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302204 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302205 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302206 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002207
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302208 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002209 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302210 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302211 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002212 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302215
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302216end:
Srinivas Dasari22397902019-07-29 21:34:10 +05302217 qdf_mem_free(vendor_ies);
2218 qdf_mem_free(mbo_ie);
2219
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 /* Free up buffer allocated for mlm_assoc_req */
Pragaspathi Thilagaraj54018e02019-04-25 01:32:17 +05302221 qdf_mem_free(adaptive_11r_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302222 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302224 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 return;
2226}
2227
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002229 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2230 * @context: pointer to global mac
2231 * @buf: buffer which is nothing but entire ADD BA frame
2232 * @tx_complete : Sent status
2233 * @params; tx completion params
2234 *
2235 * Return: This returns QDF_STATUS
2236 */
2237static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2238 qdf_nbuf_t buf,
2239 uint32_t tx_complete,
2240 void *params)
2241{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002242 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002243 tSirMacMgmtHdr *mac_hdr;
2244 tDot11faddba_rsp rsp;
2245 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2246 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2247 uint8_t peer_id;
2248 void *peer;
2249 uint32_t frame_len;
2250 QDF_STATUS status;
2251 uint8_t *data;
2252
2253 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2254 pe_debug("Add ba response successfully sent");
2255 else
2256 pe_debug("Fail to send add ba response");
2257
2258 if (!buf) {
2259 pe_err("Addba response frame buffer is NULL");
2260 return QDF_STATUS_E_FAILURE;
2261 }
2262
2263 data = qdf_nbuf_data(buf);
2264
2265 if (!data) {
2266 pe_err("Addba response frame is NULL");
2267 return QDF_STATUS_E_FAILURE;
2268 }
2269
2270 mac_hdr = (tSirMacMgmtHdr *)data;
2271 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2272 frame_len = sizeof(rsp);
2273 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2274 sizeof(*mac_hdr), frame_len,
2275 &rsp, false);
2276
2277 if (DOT11F_FAILED(status)) {
2278 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2279 status, frame_len);
2280 goto error;
2281 }
2282
2283 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2284 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2285 if (!peer) {
2286 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2287 goto error;
2288 }
2289 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2290 tx_complete);
2291 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2292error:
2293 if (buf)
2294 qdf_nbuf_free(buf);
2295
2296 return QDF_STATUS_SUCCESS;
2297}
2298
2299/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302300 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302301 * @context: pointer to global mac
2302 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302303 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302304 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302305 *
2306 * Return: This returns QDF_STATUS
2307 */
2308
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302309static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2310 qdf_nbuf_t buf,
2311 uint32_t tx_complete,
2312 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302313{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002314 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302315 uint16_t auth_ack_status;
2316 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302317
Naveen Rawat684e8b12017-09-20 15:54:44 -07002318 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002319 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2320 "success" : "fail");
2321 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302322 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302323 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002324 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302325 /* 'Change' timer for future activations */
2326 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2327 } else {
2328 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302329 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002330 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302331 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302332
2333 if (buf)
2334 qdf_nbuf_free(buf);
2335
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302336 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2337 NULL, auth_ack_status, reason_code);
2338
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302339 return QDF_STATUS_SUCCESS;
2340}
2341
2342/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2344 *
2345 * @mac_ctx: Pointer to Global MAC structure
2346 * @auth_frame: Pointer to Authentication frame structure
2347 * @peer_addr: MAC address of destination peer
2348 * @wep_bit: wep bit in frame control for Authentication frame3
2349 * @session: PE session information
2350 *
2351 * This function is called by lim_process_mlm_messages(). Authentication frame
2352 * is formatted and sent when this function is called.
2353 *
2354 * Return: void
2355 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002357lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358 tpSirMacAuthFrameBody auth_frame,
2359 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302360 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002361 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362{
2363 uint8_t *frame, *body;
2364 uint32_t frame_len = 0, body_len = 0;
2365 tpSirMacMgmtHdr mac_hdr;
2366 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302367 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 uint8_t tx_flag = 0;
2369 uint8_t sme_sessionid = 0;
2370 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002371 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002372 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302373 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002375 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002376 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 return;
2378 }
2379
2380 sme_sessionid = session->smeSessionId;
2381
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302382 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002383 /*
2384 * Auth frame3 to be sent with encrypted framebody
2385 *
2386 * Allocate buffer for Authenticaton frame of size
2387 * equal to management frame header length plus 2 bytes
2388 * each for auth algorithm number, transaction number,
2389 * status code, 128 bytes for challenge text and
2390 * 4 bytes each for IV & ICV.
2391 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002392 pe_debug("Sending encrypted auth frame to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002393 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002394
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302395 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002396 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002397
2398 goto alloc_packet;
2399 }
2400
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002401 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002402 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403 auth_frame->authTransactionSeqNumber,
2404 auth_frame->authStatusCode,
2405 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002406 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407
2408 switch (auth_frame->authTransactionSeqNumber) {
2409 case SIR_MAC_AUTH_FRAME_1:
2410 /*
2411 * Allocate buffer for Authenticaton frame of size
2412 * equal to management frame header length plus 2 bytes
2413 * each for auth algorithm number, transaction number
2414 * and status code.
2415 */
2416
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002417 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2418 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302420 frame_len += lim_create_fils_auth_data(mac_ctx,
2421 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002423 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 0 != session->ftPEContext.pFTPreAuthReq->
2425 ft_ies_length) {
2426 ft_ies_length = session->ftPEContext.
2427 pFTPreAuthReq->ft_ies_length;
2428 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002429 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 ft_ies_length);
2431 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002432 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 frame_len += (2 + SIR_MDIE_SIZE);
2434 }
2435 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302436
2437 /* include MDIE in FILS authentication frame */
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302438 if (session->lim_join_req &&
2439 session->lim_join_req->is11Rconnection &&
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302440 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +05302441 session->lim_join_req->bssDescription.mdiePresent)
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302442 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 break;
2444
2445 case SIR_MAC_AUTH_FRAME_2:
2446 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2447 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2448 (auth_frame->authStatusCode !=
2449 eSIR_MAC_SUCCESS_STATUS))) {
2450 /*
2451 * Allocate buffer for Authenticaton frame of size
2452 * equal to management frame header length plus
2453 * 2 bytes each for auth algorithm number,
2454 * transaction number and status code.
2455 */
2456
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002457 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2458 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 } else {
2460 /*
2461 * Shared Key algorithm with challenge text
2462 * to be sent.
2463 *
2464 * Allocate buffer for Authenticaton frame of size
2465 * equal to management frame header length plus
2466 * 2 bytes each for auth algorithm number,
2467 * transaction number, status code and 128 bytes
2468 * for challenge text.
2469 */
2470
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002471 challenge_req = true;
2472 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302473 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2474 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002475 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 }
2477 break;
2478
2479 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002480 /*
2481 * Auth frame3 to be sent without encrypted framebody
2482 *
2483 * Allocate buffer for Authenticaton frame of size equal
2484 * to management frame header length plus 2 bytes each
2485 * for auth algorithm number, transaction number and
2486 * status code.
2487 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002489 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2490 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 break;
2492
2493 case SIR_MAC_AUTH_FRAME_4:
2494 /*
2495 * Allocate buffer for Authenticaton frame of size equal
2496 * to management frame header length plus 2 bytes each
2497 * for auth algorithm number, transaction number and
2498 * status code.
2499 */
2500
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002501 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2502 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503
2504 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002505 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002506 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002507 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508 } /* switch (auth_frame->authTransactionSeqNumber) */
2509
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002510alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302511 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 (void **)&packet);
2513
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302514 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002515 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 return;
2517 }
2518
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302519 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520
2521 /* Prepare BD */
2522 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05302523 SIR_MAC_MGMT_AUTH, peer_addr, session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302525 if (wep_challenge_len)
2526 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2527 else
2528 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002529
2530 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002531 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302532 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 (uint8_t *) session->bssId,
2534 sizeof(tSirMacAddr));
2535
2536 /* Prepare Authentication frame body */
2537 body = frame + sizeof(tSirMacMgmtHdr);
2538
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302539 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302540 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002542 pe_debug("Sending Auth seq# 3 to " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002543 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544
2545 } else {
2546 *((uint16_t *) (body)) =
2547 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2548 body += sizeof(uint16_t);
2549 body_len -= sizeof(uint16_t);
2550
2551 *((uint16_t *) (body)) =
2552 sir_swap_u16if_needed(
2553 auth_frame->authTransactionSeqNumber);
2554 body += sizeof(uint16_t);
2555 body_len -= sizeof(uint16_t);
2556
2557 *((uint16_t *) (body)) =
2558 sir_swap_u16if_needed(auth_frame->authStatusCode);
2559 body += sizeof(uint16_t);
2560 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002561
2562 if (challenge_req) {
2563 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302564 /* copy challenge IE id, len, challenge text */
2565 *body = auth_frame->type;
2566 body++;
2567 body_len -= sizeof(uint8_t);
2568 *body = auth_frame->length;
2569 body++;
2570 body_len -= sizeof(uint8_t);
2571 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002572 body_len);
2573 pe_err("Incomplete challenge info: length: %d, expected: %d",
2574 body_len,
2575 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2576 body += body_len;
2577 body_len = 0;
2578 } else {
2579 /* copy challenge IE id, len, challenge text */
2580 *body = auth_frame->type;
2581 body++;
2582 *body = auth_frame->length;
2583 body++;
2584 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302585 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2586 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002587
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302588 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2589 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002590 }
2591 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2594 (auth_frame->authTransactionSeqNumber ==
2595 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002596 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597
2598 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302599 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 session->ftPEContext.
2601 pFTPreAuthReq->ft_ies,
2602 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002603 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002604 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2605 QDF_TRACE_LEVEL_DEBUG,
2606 (uint8_t *) body,
2607 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002608 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 pFTPreAuthReq->pbssDescription) {
2610 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002611 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 body++;
2613 *body = SIR_MDIE_SIZE;
2614 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302615 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 &session->ftPEContext.pFTPreAuthReq->
2617 pbssDescription->mdie[0],
2618 SIR_MDIE_SIZE);
2619 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302620 } else if ((auth_frame->authAlgoNumber ==
2621 SIR_FILS_SK_WITHOUT_PFS) &&
2622 (auth_frame->authTransactionSeqNumber ==
2623 SIR_MAC_AUTH_FRAME_1)) {
2624 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302625 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002628 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002629 QDF_MAC_ADDR_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 auth_frame->authTransactionSeqNumber,
2631 auth_frame->authStatusCode,
2632 (auth_frame->authStatusCode ==
2633 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002634 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002636 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2637 QDF_TRACE_LEVEL_DEBUG,
2638 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002640 if ((session->ftPEContext.pFTPreAuthReq) &&
Liangwei Dong419d7302019-07-15 15:38:28 +08002641 (lim_get_rf_band(
2642 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)) ==
2643 BAND_5G)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Liangwei Dong419d7302019-07-15 15:38:28 +08002645 else if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
2646 session->opmode == QDF_P2P_CLIENT_MODE ||
2647 session->opmode == QDF_P2P_GO_MODE)
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302648 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05302650 if (session->opmode == QDF_P2P_CLIENT_MODE ||
2651 session->opmode == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2653
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302654 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302657 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002658 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002659 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002660 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302661
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002662 if (session->ftPEContext.pFTPreAuthReq)
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302663 ch_freq_tx_frame = cds_chan_to_freq(
2664 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum);
2665
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302666 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2667 (uint16_t)frame_len,
2668 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2669 7, lim_tx_complete, frame,
2670 lim_auth_tx_complete_cnf,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302671 tx_flag, sme_sessionid, false,
2672 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302673 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2674 session->peSessionId, qdf_status));
2675 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2676 pe_err("*** Could not send Auth frame, retCode=%X ***",
2677 qdf_status);
2678 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2679 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002680 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302681 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 return;
2684}
2685
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002686QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687{
2688 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002689 tpDphHashNode sta_ds;
2690 tLimMlmDeauthReq *deauth_req;
2691 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002692 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002694 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2695 if (deauth_req) {
2696 if (tx_timer_running(
2697 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2698 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002701 session_entry = pe_find_session_by_session_id(mac_ctx,
2702 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002703 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002704 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002705 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 eSIR_SME_INVALID_PARAMETERS;
2707 goto end;
2708 }
2709
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002710 sta_ds =
2711 dph_lookup_hash_entry(mac_ctx,
2712 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002713 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002714 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002715 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002716 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 goto end;
2718 }
2719
2720 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002721 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2722 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2723 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2724 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302725#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002726 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302727#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002728 (session_entry->isFastRoamIniFeatureEnabled) ||
2729 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002730 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002731 session_entry,
2732 session_entry->peSessionId,
2733 deauth_req->reasonCode,
2734 deauth_req->deauthTrigger);
2735 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002736 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002737#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302738 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002739 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002740 " isLFR %d"
2741 " is11r %d, Deauth reason %d Trigger = %d",
2742 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002743 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002744 session_entry->isFastRoamIniFeatureEnabled,
2745 session_entry->is11Rconnection,
2746 deauth_req->reasonCode,
2747 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302748#else
2749 pe_debug("No FT Preauth Session Cleanup in role %d"
2750 " isLFR %d"
2751 " is11r %d, Deauth reason %d Trigger = %d",
2752 session_entry->limSystemRole,
2753 session_entry->isFastRoamIniFeatureEnabled,
2754 session_entry->is11Rconnection,
2755 deauth_req->reasonCode,
2756 deauth_req->deauthTrigger);
2757#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002758 }
2759 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002760 qdf_mem_free(deauth_req);
2761 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302763 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002765 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2766 &deauth_req->peer_macaddr);
2767 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2768 deauth_cnf.aid = deauth_req->aid;
2769 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770
2771 /* Free up buffer allocated */
2772 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002773 qdf_mem_free(deauth_req);
2774 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002776 lim_post_sme_message(mac_ctx,
2777 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302778 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779}
2780
2781/**
2782 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2783 *
2784 * @mac_ctx: Handle to MAC context
2785 *
2786 * Sends disassoc confirmation to SME. Removes disassoc request stored
2787 * in lim.
2788 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302789 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002790 */
2791
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002792QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793{
2794 uint16_t aid;
2795 tpDphHashNode sta_ds;
2796 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002797 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 tLimMlmDisassocReq *disassoc_req;
2799
2800 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2801 if (disassoc_req) {
2802 if (tx_timer_running(
2803 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2804 lim_deactivate_and_change_timer(mac_ctx,
2805 eLIM_DISASSOC_ACK_TIMER);
2806
2807 pe_session = pe_find_session_by_session_id(
2808 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002809 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002810 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002811 disassoc_cnf.resultCode =
2812 eSIR_SME_INVALID_PARAMETERS;
2813 goto end;
2814 }
2815
2816 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002817 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002819 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002820 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2822 goto end;
2823 }
2824 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002825 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2827 disassoc_cnf.resultCode =
2828 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002829 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 goto end;
2831 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002832 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002833 (disassoc_req->reasonCode !=
2834 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002835 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002836 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 /* Delete FT session if there exists one */
2839 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302842 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302844 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302846 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 }
2848end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302849 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002850 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302851 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 disassoc_cnf.aid = disassoc_req->aid;
2853 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2854
2855 /* Update PE session ID */
2856 disassoc_cnf.sessionId = disassoc_req->sessionId;
2857
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002858 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2862 }
2863
2864 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2865 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302866 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867}
2868
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302869QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002870 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302871 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002873 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302874
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002875 pe_debug("tx_success: %d", tx_success);
2876
2877 return lim_send_disassoc_cnf(max_ctx);
2878}
2879
2880static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2881 qdf_nbuf_t buf,
2882 uint32_t tx_success,
2883 void *params)
2884{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002885 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002886 QDF_STATUS status_code;
2887 struct scheduler_msg msg = {0};
2888
2889 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302890
2891 if (buf)
2892 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002893 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2894 msg.bodyptr = params;
2895 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302896
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002897 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2898 if (status_code != QDF_STATUS_SUCCESS)
2899 pe_err("posting message: %X to LIM failed, reason: %d",
2900 msg.type, status_code);
2901 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902}
2903
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302904QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002905 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302906 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002908 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302909
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002910 pe_debug("tx_success: %d", tx_success);
2911
2912 return lim_send_deauth_cnf(mac_ctx);
2913}
2914
2915static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2916 qdf_nbuf_t buf,
2917 uint32_t tx_success,
2918 void *params)
2919{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002920 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002921 QDF_STATUS status_code;
2922 struct scheduler_msg msg = {0};
2923
2924 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302925
2926 if (buf)
2927 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002928 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2929 msg.bodyptr = params;
2930 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302931
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002932 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2933 if (status_code != QDF_STATUS_SUCCESS)
2934 pe_err("posting message: %X to LIM failed, reason: %d",
2935 msg.type, status_code);
2936 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937}
2938
2939/**
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302940 * lim_append_ies_to_frame() - Append IEs to the frame
2941 *
2942 * @frame: Pointer to the frame buffer that needs to be populated
2943 * @frame_len: Pointer for current frame length
2944 * @ie: pointer for disconnect IEs
2945 *
2946 * This function is called by lim_send_disassoc_mgmt_frame and
2947 * lim_send_deauth_mgmt_frame APIs as part of disconnection.
2948 * Append IEs and update frame length.
2949 *
2950 * Return: None
2951 */
2952static void
2953lim_append_ies_to_frame(uint8_t *frame, uint32_t *frame_len,
2954 struct wlan_ies *ie)
2955{
2956 if (!ie || !ie->len || !ie->data)
2957 return;
2958 qdf_mem_copy(frame, ie->data, ie->len);
2959 *frame_len += ie->len;
2960 pe_debug("Appended IEs len: %u", ie->len);
2961}
2962
2963/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 * \brief This function is called to send Disassociate frame.
2965 *
2966 *
Jeff Johnson99f25042018-11-21 22:49:06 -08002967 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 *
2969 * \param nReason Indicates the reason that need to be sent in
2970 * Disassociation frame
2971 *
2972 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2973 * sent
2974 *
2975 *
2976 */
2977
2978void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002979lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002980 uint16_t nReason,
2981 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002982 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983{
2984 tDot11fDisassociation frm;
2985 uint8_t *pFrame;
2986 tpSirMacMgmtHdr pMacHdr;
2987 uint32_t nBytes, nPayload, nStatus;
2988 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 uint8_t txFlag = 0;
2991 uint32_t val = 0;
2992 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05302993 struct wlan_ies *discon_ie;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002994
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002995 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002996 return;
2997 }
2998
2999 /*
3000 * In case when cac timer is running for this SAP session then
3001 * avoid sending disassoc out. It is violation of dfs specification.
3002 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303003 if (((pe_session->opmode == QDF_SAP_MODE) ||
3004 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003005 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303006 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303007 FL("CAC timer is running, drop disassoc from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303008 if (waitForAck)
3009 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 return;
3011 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003012 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013
hangtian127c9532019-01-12 13:29:07 +08003014 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015
3016 frm.Reason.code = nReason;
3017
Jeff Johnson99f25042018-11-21 22:49:06 -08003018 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003020 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 nStatus);
3022 /* We'll fall back on the worst case scenario: */
3023 nPayload = sizeof(tDot11fDisassociation);
3024 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003025 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
3026 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 }
3028
3029 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3030
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303031 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3032 if (discon_ie && discon_ie->len)
3033 nBytes += discon_ie->len;
3034
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303035 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303037 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003038 pe_err("Failed to allocate %d bytes for a Disassociation",
3039 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303040 if (waitForAck)
3041 lim_send_disassoc_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 return;
3043 }
3044 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003045 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046
3047 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003048 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303049 SIR_MAC_MGMT_DISASSOC, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3051
3052 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003053 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003054
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003055 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056
Jeff Johnson99f25042018-11-21 22:49:06 -08003057 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 sizeof(tSirMacMgmtHdr),
3059 nPayload, &nPayload);
3060 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003061 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 nStatus);
3063 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303064 if (waitForAck)
3065 lim_send_disassoc_cnf(mac);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003066 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003068 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
3069 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 }
3071
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303072 /* Copy disconnect IEs to the end of the frame */
3073 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3074 &nPayload, discon_ie);
3075 mlme_free_self_disconnect_ies(pe_session->vdev);
3076
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003077 pe_debug("***Sessionid %d Sending Disassociation frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003078 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR " ,From "
3079 QDF_MAC_ADDR_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003080 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303081 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082
Liangwei Dong419d7302019-07-15 15:38:28 +08003083 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3084 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3085 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087
Sushant Kaushik46556062015-12-02 16:57:47 +05303088 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089
3090 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303091 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003092 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003094 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003095 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003096 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 /* Queue Disassociation frame in high priority WQ */
3098 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303099 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003100 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 TXRX_FRM_802_11_MGMT,
3102 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003103 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003104 txFlag, smeSessionId, false, 0,
3105 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303106 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303107 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003108 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109
3110 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3111
3112 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003113 (&mac->lim.limTimers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003115 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 return;
3117 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003118 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003120 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003121 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 eLIM_DISASSOC_ACK_TIMER);
3123 return;
3124 }
3125 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303126 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003127 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003129 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003130 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003131 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003133 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 TXRX_FRM_802_11_MGMT,
3135 ANI_TXDIR_TODS,
3136 7,
3137 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003138 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303139 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303140 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003141 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303142 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003143 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303144 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 /* Pkt will be freed up by the callback */
3146 }
3147 }
3148} /* End lim_send_disassoc_mgmt_frame. */
3149
3150/**
3151 * \brief This function is called to send a Deauthenticate frame
3152 *
3153 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003154 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 *
3156 * \param nReason Indicates the reason that need to be sent in the
3157 * Deauthenticate frame
3158 *
3159 * \param peeer address of the STA to which the frame is to be sent
3160 *
3161 *
3162 */
3163
3164void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003165lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 uint16_t nReason,
3167 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003168 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169{
3170 tDot11fDeAuth frm;
3171 uint8_t *pFrame;
3172 tpSirMacMgmtHdr pMacHdr;
3173 uint32_t nBytes, nPayload, nStatus;
3174 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303175 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 uint8_t txFlag = 0;
3177 uint32_t val = 0;
3178#ifdef FEATURE_WLAN_TDLS
3179 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003180 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181#endif
3182 uint8_t smeSessionId = 0;
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303183 struct wlan_ies *discon_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003185 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 return;
3187 }
3188
3189 /*
3190 * In case when cac timer is running for this SAP session then
3191 * avoid deauth frame out. It is violation of dfs specification.
3192 */
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05303193 if (((pe_session->opmode == QDF_SAP_MODE) ||
3194 (pe_session->opmode == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003195 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303196 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 FL
3198 ("CAC timer is running, drop the deauth from going out"));
Abhishek Singh06522c52019-05-08 12:13:42 +05303199 if (waitForAck)
3200 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 return;
3202 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003203 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
hangtian127c9532019-01-12 13:29:07 +08003205 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
3207 frm.Reason.code = nReason;
3208
Jeff Johnson99f25042018-11-21 22:49:06 -08003209 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003211 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003212 nStatus);
3213 /* We'll fall back on the worst case scenario: */
3214 nPayload = sizeof(tDot11fDeAuth);
3215 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003216 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3217 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 }
3219
3220 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303221 discon_ie = mlme_get_self_disconnect_ies(pe_session->vdev);
3222 if (discon_ie && discon_ie->len)
3223 nBytes += discon_ie->len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303225 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003228 pe_err("Failed to allocate %d bytes for a De-Authentication",
3229 nBytes);
Abhishek Singh06522c52019-05-08 12:13:42 +05303230 if (waitForAck)
3231 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 return;
3233 }
3234 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003235 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236
3237 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003238 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303239 SIR_MAC_MGMT_DEAUTH, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3241
3242 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003243 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003245 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246
Jeff Johnson99f25042018-11-21 22:49:06 -08003247 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003248 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3249 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003250 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 nStatus);
3252 cds_packet_free((void *)pPacket);
Abhishek Singh06522c52019-05-08 12:13:42 +05303253 if (waitForAck)
3254 lim_send_deauth_cnf(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 return;
3256 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003257 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3258 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 }
Srinivas Dasarie2ee0942019-06-29 14:34:50 +05303260
3261 /* Copy disconnect IEs to the end of the frame */
3262 lim_append_ies_to_frame(pFrame + sizeof(tSirMacMgmtHdr) + nPayload,
3263 &nPayload, discon_ie);
3264 mlme_free_self_disconnect_ies(pe_session->vdev);
3265
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003266 pe_debug("***Sessionid %d Sending Deauth frame with "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003267 "reason %u and waitForAck %d to " QDF_MAC_ADDR_STR
3268 " ,From " QDF_MAC_ADDR_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003269 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003270 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303271 QDF_MAC_ADDR_ARRAY(pe_session->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272
Liangwei Dong419d7302019-07-15 15:38:28 +08003273 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3274 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3275 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277
Sushant Kaushik46556062015-12-02 16:57:47 +05303278 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003280 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003281 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003282 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283#endif
3284
3285 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303286 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003287 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003289 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003290 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003291 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003294 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 TXRX_FRM_802_11_MGMT,
3296 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003297 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003298 txFlag, smeSessionId, false, 0,
3299 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303300 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303301 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003302 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303304 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003305 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307
3308 /* Call lim_process_deauth_ack_timeout which will send
3309 * DeauthCnf for this frame
3310 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003311 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 return;
3313 }
3314
3315 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3316
3317 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003318 (&mac->lim.limTimers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003320 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 return;
3322 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003323 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003325 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003326 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 eLIM_DEAUTH_ACK_TIMER);
3328 return;
3329 }
3330 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303331 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003332 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333 pMacHdr->fc.subType));
3334#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003335 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003336 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003338 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003339 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003340 QDF_STATUS_SUCCESS,
3341 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303342 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003343 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3345 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003346 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 } else {
3348#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003349 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003350 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003351 QDF_STATUS_SUCCESS,
3352 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303354 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003355 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003356 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3357 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003358 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359#ifdef FEATURE_WLAN_TDLS
3360 }
3361#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303362 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003363 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303364 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003365 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303366 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 /* Pkt will be freed up by the callback */
3368 }
3369 }
3370
3371} /* End lim_send_deauth_mgmt_frame. */
3372
3373#ifdef ANI_SUPPORT_11H
3374/**
3375 * \brief Send a Measurement Report Action frame
3376 *
3377 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003378 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 *
3380 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3381 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003382 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 *
3384 *
3385 */
3386
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003387QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003388lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003390 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391{
3392 tDot11fMeasurementReport frm;
3393 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003394 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 tpSirMacMgmtHdr pMacHdr;
3396 uint32_t nBytes, nPayload, nStatus;
3397 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303398 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399
hangtian127c9532019-01-12 13:29:07 +08003400 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003402 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003403 frm.Action.action = ACTION_SPCT_MSR_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3405
3406 switch (pMeasReqFrame->measReqIE.measType) {
3407 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3408 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003409 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 &frm.MeasurementReport);
3411 break;
3412 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3413 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003414 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 &frm.MeasurementReport);
3416 break;
3417 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3418 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003419 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 &frm.MeasurementReport);
3421 break;
3422 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003423 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003425 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 }
3427
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003428 if (QDF_STATUS_SUCCESS != nSirStatus)
3429 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430
Jeff Johnson99f25042018-11-21 22:49:06 -08003431 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003433 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 nStatus);
3435 /* We'll fall back on the worst case scenario: */
3436 nPayload = sizeof(tDot11fMeasurementReport);
3437 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003438 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3439 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 }
3441
3442 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3443
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303444 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003445 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 (uint16_t) nBytes, (void **)&pFrame,
3447 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303448 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003449 pe_err("Failed to allocate %d bytes for a De-Authentication",
3450 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003451 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 }
3453 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003454 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455
3456 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003457 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 SIR_MAC_MGMT_ACTION, peer);
3459 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3460
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003461 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003463 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464
Jeff Johnson99f25042018-11-21 22:49:06 -08003465 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 sizeof(tSirMacMgmtHdr),
3467 nPayload, &nPayload);
3468 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003469 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003471 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003473 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003475 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3476 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 }
3478
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303479 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003480 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003481 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303482 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003483 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003485 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303486 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303487 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003488 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303489 qdf_status));
3490 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003491 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303492 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003494 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 }
3496
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003497 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498
3499} /* End lim_send_meas_report_frame. */
3500
3501/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003502 * \brief Send a TPC Report Action frame
3503 *
3504 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003505 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 *
3507 * \param pTpcReqFrame Pointer to the received TPC Request
3508 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003509 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 *
3511 *
3512 */
3513
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003514QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003515lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003517 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518{
3519 tDot11fTPCReport frm;
3520 uint8_t *pFrame;
3521 tpSirMacMgmtHdr pMacHdr;
3522 uint32_t nBytes, nPayload, nStatus;
3523 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525
hangtian127c9532019-01-12 13:29:07 +08003526 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003528 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003529 frm.Action.action = ACTION_SPCT_TPC_RPRT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3531
3532 frm.TPCReport.tx_power = 0;
3533 frm.TPCReport.link_margin = 0;
3534 frm.TPCReport.present = 1;
3535
Jeff Johnson99f25042018-11-21 22:49:06 -08003536 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003538 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539 /* We'll fall back on the worst case scenario: */
3540 nPayload = sizeof(tDot11fTPCReport);
3541 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003542 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3543 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003544 }
3545
3546 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3547
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003549 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 (uint16_t) nBytes, (void **)&pFrame,
3551 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303552 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003553 pe_err("Failed to allocate %d bytes for a TPC"
3554 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003555 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 }
3557 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003558 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559
3560 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003561 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 SIR_MAC_MGMT_ACTION, peer);
3563
3564 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3565
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003566 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003568 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569
Jeff Johnson99f25042018-11-21 22:49:06 -08003570 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 sizeof(tSirMacMgmtHdr),
3572 nPayload, &nPayload);
3573 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003574 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003576 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003578 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003580 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3581 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303583 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003584 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303586 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003587 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003589 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303590 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003591 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003592 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003593 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303594 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003595 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303596 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003598 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 }
3600
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003601 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602
3603} /* End lim_send_tpc_report_frame. */
3604#endif /* ANI_SUPPORT_11H */
3605
3606/**
3607 * \brief Send a Channel Switch Announcement
3608 *
3609 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003610 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 *
3612 * \param peer MAC address to which this frame will be sent
3613 *
3614 * \param nMode
3615 *
3616 * \param nNewChannel
3617 *
3618 * \param nCount
3619 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003620 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 *
3622 *
3623 */
3624
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003625QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003626lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 tSirMacAddr peer,
3628 uint8_t nMode,
3629 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003630 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631{
3632 tDot11fChannelSwitch frm;
3633 uint8_t *pFrame;
3634 tpSirMacMgmtHdr pMacHdr;
3635 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3636 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303637 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 uint8_t txFlag = 0;
3639
3640 uint8_t smeSessionId = 0;
3641
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003642 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003643 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003644 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003646 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647
hangtian127c9532019-01-12 13:29:07 +08003648 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003650 frm.Category.category = ACTION_CATEGORY_SPECTRUM_MGMT;
Srinivas Girigowdaf8e5d2e2019-05-28 11:49:29 -07003651 frm.Action.action = ACTION_SPCT_CHL_SWITCH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 frm.ChanSwitchAnn.switchMode = nMode;
3653 frm.ChanSwitchAnn.newChannel = nNewChannel;
3654 frm.ChanSwitchAnn.switchCount = nCount;
3655 frm.ChanSwitchAnn.present = 1;
3656
Jeff Johnson99f25042018-11-21 22:49:06 -08003657 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003659 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 nStatus);
3661 /* We'll fall back on the worst case scenario: */
3662 nPayload = sizeof(tDot11fChannelSwitch);
3663 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003664 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3665 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 }
3667
3668 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3669
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303670 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3672 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303673 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003674 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003675 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 }
3677 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003678 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679
3680 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003681 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 SIR_MAC_MGMT_ACTION, peer,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303683 pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303685 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003686 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003688 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689
Jeff Johnson99f25042018-11-21 22:49:06 -08003690 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 sizeof(tSirMacMgmtHdr),
3692 nPayload, &nPayload);
3693 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003694 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 nStatus);
3696 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003697 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003699 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3700 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003701 }
3702
Liangwei Dong419d7302019-07-15 15:38:28 +08003703 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
3704 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
3705 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303708 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003709 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003710 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 TXRX_FRM_802_11_MGMT,
3712 ANI_TXDIR_TODS,
3713 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003714 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303715 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003716 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303717 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003718 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303719 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003721 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 }
3723
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725
3726} /* End lim_send_channel_switch_mgmt_frame. */
3727
Abhishek Singh518323d2015-10-19 17:42:01 +05303728/**
3729 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3730 * action frame over the air .
3731 * @mac_ctx: pointer to global mac structure
3732 * @peer: Destination mac.
3733 * @mode: channel switch mode
3734 * @new_op_class: new op class
3735 * @new_channel: new channel to switch
3736 * @count: channel switch count
3737 *
3738 * This function is called to send ECSA frame.
3739 *
3740 * Return: success if frame is sent else return failure
3741 */
3742
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003743QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003744lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303745 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003746 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303747{
3748 tDot11fext_channel_switch_action_frame frm;
3749 uint8_t *frame;
3750 tpSirMacMgmtHdr mac_hdr;
3751 uint32_t num_bytes, n_payload, status;
3752 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303753 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303754 uint8_t txFlag = 0;
3755 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303756 uint8_t ch_spacing;
3757 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303758
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003759 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003760 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003761 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303762 }
3763
3764 sme_session_id = session_entry->smeSessionId;
3765
hangtian127c9532019-01-12 13:29:07 +08003766 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303767
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07003768 frm.Category.category = ACTION_CATEGORY_PUBLIC;
Abhishek Singh518323d2015-10-19 17:42:01 +05303769 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3770
3771 frm.ext_chan_switch_ann_action.switch_mode = mode;
3772 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3773 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3774 frm.ext_chan_switch_ann_action.switch_count = count;
3775
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303776 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3777 mac_ctx->scan.countryCodeCurrent, new_channel,
3778 new_op_class);
3779 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3780
3781 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3782 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3783 frm.WiderBWChanSwitchAnn.newChanWidth =
3784 wide_bw_ie->newChanWidth;
3785 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3786 wide_bw_ie->newCenterChanFreq0;
3787 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3788 wide_bw_ie->newCenterChanFreq1;
3789 frm.WiderBWChanSwitchAnn.present = 1;
3790 pe_debug("wrapper: width:%d f0:%d f1:%d",
3791 frm.WiderBWChanSwitchAnn.newChanWidth,
3792 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3793 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3794 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303795
3796 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3797 &frm, &n_payload);
3798 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003799 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303800 status);
3801 /* We'll fall back on the worst case scenario*/
3802 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3803 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003804 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303805 status);
3806 }
3807
3808 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3809
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303810 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303811 (void **) &frame, (void **) &packet);
3812
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303813 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003814 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303815 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003816 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303817 }
3818
3819 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003820 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303821
3822 /* Next, we fill out the buffer descriptor */
3823 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303824 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh518323d2015-10-19 17:42:01 +05303825 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303826 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303827 (uint8_t *) session_entry->bssId,
3828 sizeof(tSirMacAddr));
3829
gaolez4b62a9e2018-08-16 15:57:50 +08003830 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3831
Abhishek Singh518323d2015-10-19 17:42:01 +05303832 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3833 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3834 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003835 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303836 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003837 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303838 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003839 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303840 status);
3841 }
3842
Liangwei Dong419d7302019-07-15 15:38:28 +08003843 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
3844 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
3845 session_entry->opmode == QDF_P2P_GO_MODE)
Abhishek Singh518323d2015-10-19 17:42:01 +05303846 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Abhishek Singh518323d2015-10-19 17:42:01 +05303847
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003848 pe_debug("Send Ext channel Switch to :"QDF_MAC_ADDR_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003849 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303850 frm.ext_chan_switch_ann_action.switch_count,
3851 frm.ext_chan_switch_ann_action.switch_mode,
3852 frm.ext_chan_switch_ann_action.new_channel,
3853 frm.ext_chan_switch_ann_action.op_class);
3854
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303855 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303856 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303857 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303858 TXRX_FRM_802_11_MGMT,
3859 ANI_TXDIR_TODS,
3860 7,
3861 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003862 txFlag, sme_session_id, 0,
3863 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303864 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303865 session_entry->peSessionId, qdf_status));
3866 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003867 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303868 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303869 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003870 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303871 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003872 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303873} /* End lim_send_extended_chan_switch_action_frame */
3874
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303875
3876/**
3877 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3878 * sent over the air
3879 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303880 * @context: pointer to global mac
3881 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303882 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303883 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303884 *
3885 * Return: This returns QDF_STATUS
3886 */
3887
3888static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303889 void *context,
3890 qdf_nbuf_t buf,
3891 uint32_t tx_complete,
3892 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303893{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003894 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003895 if (buf)
3896 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303897 return QDF_STATUS_SUCCESS;
3898}
3899
3900/**
3901 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3902 * p2p oper chan change confirm action frame
3903 * @mac_ctx: pointer to global mac structure
3904 * @peer: Destination mac.
3905 * @session_entry: session entry
3906 *
3907 * This function is called to send p2p oper chan change confirm action frame.
3908 *
3909 * Return: success if frame is sent else return failure
3910 */
3911
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003912QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003913lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08003914 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303915{
3916 tDot11fp2p_oper_chan_change_confirm frm;
3917 uint8_t *frame;
3918 tpSirMacMgmtHdr mac_hdr;
3919 uint32_t num_bytes, n_payload, status;
3920 void *packet;
3921 QDF_STATUS qdf_status;
3922 uint8_t tx_flag = 0;
3923 uint8_t sme_session_id = 0;
3924
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003925 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003926 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003927 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303928 }
3929
3930 sme_session_id = session_entry->smeSessionId;
3931
hangtian127c9532019-01-12 13:29:07 +08003932 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303933
3934 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3935
3936 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3937 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3938 frm.p2p_action_subtype.subtype = 0x04;
3939 frm.DialogToken.token = 0x0;
3940
3941 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003942 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303943 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3944 }
3945
3946 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003947 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303948 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3949 populate_dot11f_operating_mode(mac_ctx,
3950 &frm.OperatingMode, session_entry);
3951 }
3952
3953 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3954 &frm, &n_payload);
3955 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003956 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303957 /* We'll fall back on the worst case scenario*/
3958 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3959 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003960 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3961 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303962 }
3963
3964 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3965
3966 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3967 (void **) &frame, (void **) &packet);
3968
3969 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003970 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003971 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303972 }
3973
hangtian127c9532019-01-12 13:29:07 +08003974 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303975
3976 /* Next, fill out the buffer descriptor */
3977 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05303978 SIR_MAC_MGMT_ACTION, peer, session_entry->self_mac_addr);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303979 mac_hdr = (tpSirMacMgmtHdr) frame;
3980 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3981 (uint8_t *) session_entry->bssId,
3982 sizeof(tSirMacAddr));
3983
3984 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3985 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3986 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003987 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303988 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003989 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303990 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003991 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303992 status);
3993 }
3994
Liangwei Dong419d7302019-07-15 15:38:28 +08003995 if (wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq) ||
3996 session_entry->opmode == QDF_P2P_CLIENT_MODE ||
3997 session_entry->opmode == QDF_P2P_GO_MODE) {
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303998 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3999 }
Liangwei Dong419d7302019-07-15 15:38:28 +08004000 pe_debug("Send frame on channel freq %d to mac "
4001 QDF_MAC_ADDR_STR, session_entry->curr_op_freq,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004002 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304003
4004 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4005 session_entry->peSessionId, mac_hdr->fc.subType));
4006
4007 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4008 (uint16_t)num_bytes,
4009 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4010 7, lim_tx_complete, frame,
4011 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07004012 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304013
4014 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4015 session_entry->peSessionId, qdf_status));
4016 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004017 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304018 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004019 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304020 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004021 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05304022}
4023
4024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025/**
4026 * \brief Send a Neighbor Report Request Action frame
4027 *
4028 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004029 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 *
4031 * \param pNeighborReq Address of a tSirMacNeighborReportReq
4032 *
4033 * \param peer mac address of peer station.
4034 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004035 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004037 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 *
4039 *
4040 */
4041
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004042QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004043lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004045 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304047 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 tDot11fNeighborReportRequest frm;
4049 uint8_t *pFrame;
4050 tpSirMacMgmtHdr pMacHdr;
4051 uint32_t nBytes, nPayload, nStatus;
4052 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304053 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054 uint8_t txFlag = 0;
4055 uint8_t smeSessionId = 0;
4056
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004057 if (!pe_session) {
4058 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004059 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004061 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08004062 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004064 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004065 frm.Action.action = RRM_NEIGHBOR_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 frm.DialogToken.token = pNeighborReq->dialogToken;
4067
4068 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08004069 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 }
4071
4072 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004073 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004075 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 nStatus);
4077 /* We'll fall back on the worst case scenario: */
4078 nPayload = sizeof(tDot11fNeighborReportRequest);
4079 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004080 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
4081 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 }
4083
4084 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4085
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304086 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4088 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304089 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004090 pe_err("Failed to allocate %d bytes for a Neighbor "
4091 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004092 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 }
4094 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004095 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096
4097 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004098 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304099 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100
4101 /* Update A3 with the BSSID */
4102 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4103
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004104 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004105
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004106 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107
4108 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004109 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 &frm,
4111 pFrame +
4112 sizeof(tSirMacMgmtHdr),
4113 nPayload, &nPayload);
4114
4115 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004116 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004117 nStatus);
4118
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004119 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304120 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 goto returnAfterError;
4122 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004123 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
4124 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 }
4126
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004127 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004128 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129
Liangwei Dong419d7302019-07-15 15:38:28 +08004130 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4131 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4132 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304135 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004136 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004137 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 pPacket,
4139 (uint16_t) nBytes,
4140 TXRX_FRM_802_11_MGMT,
4141 ANI_TXDIR_TODS,
4142 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004143 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304144 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004145 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304146 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004147 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304148 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304150 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004152 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153
4154returnAfterError:
4155 cds_packet_free((void *)pPacket);
4156
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304157 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158} /* End lim_send_neighbor_report_request_frame. */
4159
4160/**
4161 * \brief Send a Link Report Action frame
4162 *
4163 *
Jeff Johnson99f25042018-11-21 22:49:06 -08004164 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 *
4166 * \param pLinkReport Address of a tSirMacLinkReport
4167 *
4168 * \param peer mac address of peer station.
4169 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004170 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004172 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 *
4174 *
4175 */
4176
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004177QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004178lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004180 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304182 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 tDot11fLinkMeasurementReport frm;
4184 uint8_t *pFrame;
4185 tpSirMacMgmtHdr pMacHdr;
4186 uint32_t nBytes, nPayload, nStatus;
4187 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304188 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 uint8_t txFlag = 0;
4190 uint8_t smeSessionId = 0;
4191
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004192 if (!pe_session) {
4193 pe_err("(!psession) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 }
4196
hangtian127c9532019-01-12 13:29:07 +08004197 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004199 frm.Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004200 frm.Action.action = RRM_LINK_MEASUREMENT_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 frm.DialogToken.token = pLinkReport->dialogToken;
4202
4203 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4204 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4205 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4206 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4207 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004208 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 frm.TPCEleLen.TPCLen = 2;
4210 frm.TxPower.txPower = pLinkReport->txPower;
4211 frm.LinkMargin.linkMargin = 0;
4212
4213 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4214 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4215 frm.RCPI.rcpi = pLinkReport->rcpi;
4216 frm.RSNI.rsni = pLinkReport->rsni;
4217
4218 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004219 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004221 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 /* We'll fall back on the worst case scenario: */
4223 nPayload = sizeof(tDot11fLinkMeasurementReport);
4224 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004225 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4226 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 }
4228
4229 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4230
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304231 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4233 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304234 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004235 pe_err("Failed to allocate %d bytes for a Link "
4236 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004237 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 }
4239 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004240 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241
4242 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004243 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304244 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245
4246 /* Update A3 with the BSSID */
4247 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4248
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004249 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004251 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004252
4253 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004254 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 &frm,
4256 pFrame +
4257 sizeof(tSirMacMgmtHdr),
4258 nPayload, &nPayload);
4259
4260 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004261 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004263 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304264 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 goto returnAfterError;
4266 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004267 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 nStatus);
4269 }
4270
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004271 pe_warn("Sending a Link Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004272 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273
Liangwei Dong419d7302019-07-15 15:38:28 +08004274 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4275 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4276 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304279 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004280 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004281 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004282 pPacket,
4283 (uint16_t) nBytes,
4284 TXRX_FRM_802_11_MGMT,
4285 ANI_TXDIR_TODS,
4286 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004287 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304288 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004289 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304290 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004291 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304292 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 /* Pkt will be freed up by the callback */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304294 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297
4298returnAfterError:
4299 cds_packet_free((void *)pPacket);
4300
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304301 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302} /* End lim_send_link_report_action_frame. */
4303
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004304QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004305lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304306 uint8_t dialog_token,
4307 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304308 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304309 tpSirMacRadioMeasureReport pRRMReport,
4310 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004311 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312{
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304313 QDF_STATUS status_code = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 uint8_t *pFrame;
4315 tpSirMacMgmtHdr pMacHdr;
4316 uint32_t nBytes, nPayload, nStatus;
4317 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304318 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 uint8_t i;
4320 uint8_t txFlag = 0;
4321 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304322 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323
4324 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304325 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004326 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004327 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004329 if (!pe_session) {
4330 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304331 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004332 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004335 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004336
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304337 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4338 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304339
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004340 frm->Category.category = ACTION_CATEGORY_RRM;
Srinivas Girigowda395addd2019-05-24 14:03:58 -07004341 frm->Action.action = RRM_RADIO_MEASURE_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 frm->DialogToken.token = dialog_token;
4343
4344 frm->num_MeasurementReport =
4345 (num_report >
4346 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4347 num_report;
4348
4349 for (i = 0; i < frm->num_MeasurementReport; i++) {
4350 frm->MeasurementReport[i].type = pRRMReport[i].type;
4351 frm->MeasurementReport[i].token = pRRMReport[i].token;
4352 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4353 switch (pRRMReport[i].type) {
4354 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304355 /*
4356 * Last beacon report indication needs to be set to 1
4357 * only for the last report in the last frame
4358 */
4359 if (is_last_frame &&
4360 (i == (frm->num_MeasurementReport - 1)))
4361 is_last_report = true;
4362
Jeff Johnson99f25042018-11-21 22:49:06 -08004363 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304364 &frm->MeasurementReport[i],
4365 &pRRMReport[i].report.
4366 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304367 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368 frm->MeasurementReport[i].incapable =
4369 pRRMReport[i].incapable;
4370 frm->MeasurementReport[i].refused =
4371 pRRMReport[i].refused;
4372 frm->MeasurementReport[i].present = 1;
4373 break;
4374 default:
4375 frm->MeasurementReport[i].incapable =
4376 pRRMReport[i].incapable;
4377 frm->MeasurementReport[i].refused =
4378 pRRMReport[i].refused;
4379 frm->MeasurementReport[i].present = 1;
4380 break;
4381 }
4382 }
4383
4384 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004385 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004387 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 nStatus);
4389 /* We'll fall back on the worst case scenario: */
4390 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304391 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004392 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004394 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4395 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 }
4397
4398 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4399
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304400 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4402 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304403 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004404 pe_err("Failed to allocate %d bytes for a Radio Measure "
4405 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304406 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004407 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 }
4409 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004410 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411
4412 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004413 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304414 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415
4416 /* Update A3 with the BSSID */
4417 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4418
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004419 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004421 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422
4423 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004424 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 frm,
4426 pFrame +
4427 sizeof(tSirMacMgmtHdr),
4428 nPayload, &nPayload);
4429
4430 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004431 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 nStatus);
4433
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004434 /* FIXME - Need to convert to QDF_STATUS */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304435 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 goto returnAfterError;
4437 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004438 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4439 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 }
4441
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004442 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004443 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004444
Liangwei Dong419d7302019-07-15 15:38:28 +08004445 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4446 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4447 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304450 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004451 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004452 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 pPacket,
4454 (uint16_t) nBytes,
4455 TXRX_FRM_802_11_MGMT,
4456 ANI_TXDIR_TODS,
4457 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004458 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304459 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004460 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304461 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004462 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304463 status_code = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304465 qdf_mem_free(frm);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304466 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004469 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 }
4471
4472returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304473 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004474 cds_packet_free((void *)pPacket);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05304475 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476}
4477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478#ifdef WLAN_FEATURE_11W
4479/**
4480 * \brief Send SA query request action frame to peer
4481 *
4482 * \sa lim_send_sa_query_request_frame
4483 *
4484 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004485 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 *
4487 * \param transId Transaction identifier
4488 *
4489 * \param peer The Mac address of the station to which this action frame is addressed
4490 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004491 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004493 * \return QDF_STATUS_SUCCESS if setup completes successfully
4494 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 */
4496
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004497QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004499 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500{
4501
4502 tDot11fSaQueryReq frm; /* SA query request action frame */
4503 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004504 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 tpSirMacMgmtHdr pMacHdr;
4506 uint32_t nBytes, nPayload, nStatus;
4507 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304508 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 uint8_t txFlag = 0;
4510 uint8_t smeSessionId = 0;
4511
hangtian127c9532019-01-12 13:29:07 +08004512 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004513 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 /* 11w action field is :
4515 action: 0 --> SA Query Request action frame
4516 action: 1 --> SA Query Response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004517 frm.Action.action = SA_QUERY_REQUEST;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304519 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520
Jeff Johnson99f25042018-11-21 22:49:06 -08004521 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004523 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 nStatus);
4525 /* We'll fall back on the worst case scenario: */
4526 nPayload = sizeof(tDot11fSaQueryReq);
4527 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004528 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4529 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 }
4531
4532 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304533 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304535 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004536 pe_err("Failed to allocate %d bytes for a SA Query Request "
4537 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004538 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 }
4540 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004541 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542
4543 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004544 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304545 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546
4547 /* Update A3 with the BSSID */
4548 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4549
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004550 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551
4552 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4553 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004554 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555
4556 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004557 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558 &frm,
4559 pFrame + sizeof(tSirMacMgmtHdr),
4560 nPayload, &nPayload);
4561
4562 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004563 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004565 /* FIXME - Need to convert to QDF_STATUS */
4566 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 goto returnAfterError;
4568 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004569 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 nStatus);
4571 }
4572
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004573 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004574 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004575 pe_debug("Sending an SA Query Request from ");
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304576 lim_print_mac_addr(mac, pe_session->self_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577
Liangwei Dong419d7302019-07-15 15:38:28 +08004578 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4579 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4580 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +05304582
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004583 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584
Jeff Johnson99f25042018-11-21 22:49:06 -08004585 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 pPacket,
4587 (uint16_t) nBytes,
4588 TXRX_FRM_802_11_MGMT,
4589 ANI_TXDIR_TODS,
4590 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004591 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304592 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004593 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004594 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 /* Pkt will be freed up by the callback */
4596 return nSirStatus;
4597 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004598 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 }
4600
4601returnAfterError:
4602 cds_packet_free((void *)pPacket);
4603 return nSirStatus;
4604} /* End lim_send_sa_query_request_frame */
4605
4606/**
4607 * \brief Send SA query response action frame to peer
4608 *
4609 * \sa lim_send_sa_query_response_frame
4610 *
4611 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004612 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 *
4614 * \param transId Transaction identifier received in SA query request action frame
4615 *
4616 * \param peer The Mac address of the AP to which this action frame is addressed
4617 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004618 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004620 * \return QDF_STATUS_SUCCESS if setup completes successfully
4621 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 */
4623
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004624QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004626 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627{
4628
Jeff Johnson47d75242018-05-12 15:58:53 -07004629 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004631 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 tpSirMacMgmtHdr pMacHdr;
4633 uint32_t nBytes, nPayload, nStatus;
4634 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304635 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 uint8_t txFlag = 0;
4637 uint8_t smeSessionId = 0;
4638
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004639 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640
hangtian127c9532019-01-12 13:29:07 +08004641 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004642 frm.Category.category = ACTION_CATEGORY_SA_QUERY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 /*11w action field is :
4644 action: 0 --> SA query request action frame
4645 action: 1 --> SA query response action frame */
Srinivas Girigowdafeb23fc2019-06-13 11:12:29 -07004646 frm.Action.action = SA_QUERY_RESPONSE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 /*11w SA query response transId is same as
4648 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304649 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650
Jeff Johnson99f25042018-11-21 22:49:06 -08004651 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004653 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004654 nStatus);
4655 /* We'll fall back on the worst case scenario: */
4656 nPayload = sizeof(tDot11fSaQueryRsp);
4657 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004658 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4659 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660 }
4661
4662 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304663 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304665 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004666 pe_err("Failed to allocate %d bytes for a SA query response"
4667 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004668 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 }
4670 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004671 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672
4673 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004674 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304675 SIR_MAC_MGMT_ACTION, peer, pe_session->self_mac_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676
4677 /* Update A3 with the BSSID */
4678 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4679
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004680 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004681
4682 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4683 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004684 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685
4686 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004687 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 &frm,
4689 pFrame + sizeof(tSirMacMgmtHdr),
4690 nPayload, &nPayload);
4691
4692 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004693 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004695 /* FIXME - Need to convert to QDF_STATUS */
4696 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 goto returnAfterError;
4698 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004699 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 nStatus);
4701 }
4702
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004703 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004704 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705
Liangwei Dong419d7302019-07-15 15:38:28 +08004706 if (wlan_reg_is_5ghz_ch_freq(pe_session->curr_op_freq) ||
4707 pe_session->opmode == QDF_P2P_CLIENT_MODE ||
4708 pe_session->opmode == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304711 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004712 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004713 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 pPacket,
4715 (uint16_t) nBytes,
4716 TXRX_FRM_802_11_MGMT,
4717 ANI_TXDIR_TODS,
4718 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004719 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304720 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004721 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304722 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004723 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004724 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 /* Pkt will be freed up by the callback */
4726 return nSirStatus;
4727 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004728 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 }
4730
4731returnAfterError:
4732 cds_packet_free((void *)pPacket);
4733 return nSirStatus;
4734} /* End lim_send_sa_query_response_frame */
4735#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004736
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004737#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390)
4738#ifdef WLAN_FEATURE_11AX
4739#define IS_PE_SESSION_11N_MODE(_session) \
4740 ((_session)->htCapability && !(_session)->vhtCapability && \
4741 !(_session)->he_capable)
4742#else
4743#define IS_PE_SESSION_11N_MODE(_session) \
4744 ((_session)->htCapability && !(_session)->vhtCapability)
4745#endif /* WLAN_FEATURE_11AX */
4746#else
4747#define IS_PE_SESSION_11N_MODE(_session) false
4748#endif
4749
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004750/**
4751 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4752 * @mac_ctx: mac context
4753 * @peer_mac: Peer MAC address
4754 * @tid: TID for which addba response is being sent
4755 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004756 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004757 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004758 *
4759 * This function is called when ADDBA request is successful. ADDBA response is
4760 * setup by calling addba_response_setup API and frame is then sent out OTA.
4761 *
4762 * Return: QDF_STATUS
4763 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004764QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004765 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004766 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004767 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004768{
4769
4770 tDot11faddba_rsp frm;
4771 uint8_t *frame_ptr;
4772 tpSirMacMgmtHdr mgmt_hdr;
4773 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004774 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004775 QDF_STATUS qdf_status;
4776 uint8_t tx_flag = 0;
4777 uint8_t sme_sessionid = 0;
4778 uint16_t buff_size, status_code, batimeout;
4779 uint8_t peer_id, dialog_token;
4780 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4781 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004782 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004783
4784 sme_sessionid = session->smeSessionId;
4785
4786 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4787 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004788 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004789 return QDF_STATUS_E_FAILURE;
4790 }
4791
Mohit Khannac4c22252017-11-20 11:06:33 -08004792 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4793 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004794 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004795 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004796 return QDF_STATUS_E_FAILURE;
4797 }
4798
4799 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4800 &status_code, &buff_size, &batimeout);
4801
Mohit Khannac4c22252017-11-20 11:06:33 -08004802 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004803 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Srinivas Girigowda48bec1c2019-05-17 16:33:30 -07004804 frm.Category.category = ACTION_CATEGORY_BACK;
Srinivas Girigowdaef0d7142019-05-17 17:07:47 -07004805 frm.Action.action = ADDBA_RESPONSE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004806
4807 frm.DialogToken.token = dialog_token;
4808 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004809 if (mac_ctx->reject_addba_req) {
4810 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4811 pe_err("refused addba req");
4812 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004813 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere22f05d42019-06-28 18:33:43 -07004814 if (lim_is_session_he_capable(session))
4815 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4816 else
4817 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004818 if (mac_ctx->usr_cfg_ba_buff_size)
4819 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004820
4821 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4822 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4823
4824 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4825 if (session->active_ba_64_session) {
4826 frm.addba_param_set.buff_size =
4827 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4828 }
4829 } else if (!session->active_ba_64_session) {
4830 session->active_ba_64_session = true;
4831 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004832
4833 /* disable 11n RX AMSDU */
4834 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
Tushnim Bhattacharyyabb128592019-09-12 11:56:37 -07004835 !IS_PE_SESSION_11N_MODE(session) &&
4836 !WLAN_REG_IS_24GHZ_CH_FREQ(session->curr_op_freq))
Arif Hussain0e246802018-05-01 18:13:44 -07004837 frm.addba_param_set.amsdu_supp = amsdu_support;
4838 else
4839 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004840
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004841 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004842 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004843 if (addba_extn_present) {
4844 frm.addba_extn_element.present = 1;
4845 frm.addba_extn_element.no_fragmentation = 1;
4846 if (lim_is_session_he_capable(session)) {
4847 he_frag = lim_get_session_he_frag_cap(session);
4848 if (he_frag != 0) {
4849 frm.addba_extn_element.no_fragmentation = 0;
4850 frm.addba_extn_element.he_frag_operation =
4851 he_frag;
4852 }
4853 }
4854 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004855
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004856 pe_debug("Sending a ADDBA Response from %pM to %pM",
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304857 session->self_mac_addr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004858 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004859 tid, frm.DialogToken.token, frm.Status.status,
4860 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004861 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4862 addba_extn_present,
4863 lim_is_session_he_capable(session),
4864 frm.addba_extn_element.no_fragmentation,
4865 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004866
4867 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4868 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004869 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004870 status);
4871 /* We'll fall back on the worst case scenario: */
4872 payload_size = sizeof(tDot11faddba_rsp);
4873 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004874 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 -08004875 }
4876
4877 num_bytes = payload_size + sizeof(*mgmt_hdr);
4878 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4879 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004880 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004881 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4882 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004883 return QDF_STATUS_E_FAILURE;
4884 }
hangtian127c9532019-01-12 13:29:07 +08004885 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004886
4887 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +05304888 SIR_MAC_MGMT_ACTION, peer_mac, session->self_mac_addr);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004889
4890 /* Update A3 with the BSSID */
4891 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4892 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4893
4894 /* ADDBA Response is a robust mgmt action frame,
4895 * set the "protect" (aka WEP) bit in the FC
4896 */
4897 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4898
4899 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4900 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4901 &payload_size);
4902
4903 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004904 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004905 status);
4906 qdf_status = QDF_STATUS_E_FAILURE;
4907 goto error_addba_rsp;
4908 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004909 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004910 status);
4911 }
4912
4913
Liangwei Dong419d7302019-07-15 15:38:28 +08004914 if (wlan_reg_is_5ghz_ch_freq(session->curr_op_freq) ||
4915 session->opmode == QDF_P2P_CLIENT_MODE ||
4916 session->opmode == QDF_P2P_GO_MODE)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004917 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004918
4919 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4920 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004921 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4922 (uint16_t)num_bytes,
4923 TXRX_FRM_802_11_MGMT,
4924 ANI_TXDIR_TODS, 7,
4925 NULL, frame_ptr,
4926 lim_addba_rsp_tx_complete_cnf,
4927 tx_flag, sme_sessionid,
4928 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004929 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4930 session->peSessionId, qdf_status));
4931 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004932 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004933 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08004934 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004935 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004936 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004937 }
4938
4939error_addba_rsp:
4940 cds_packet_free((void *)pkt_ptr);
4941 return qdf_status;
4942}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304943
4944/**
4945 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4946 * @mac_ctx Pointer to Global MAC structure
4947 * @mb_msg: Received message info
4948 * @msg_len: Received message length
4949 * @packet: Packet to be transmitted
4950 * @frame: Received frame
4951 *
4952 * Return: None
4953 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004954static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304955 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4956 void *packet, uint8_t *frame)
4957{
4958 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4959 QDF_STATUS qdf_status;
Abhishek Singhefe21e62019-09-20 10:03:24 +05304960 uint8_t vdev_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08004961 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304962 uint16_t auth_ack_status;
4963 enum rateid min_rid = RATEID_DEFAULT;
4964
Abhishek Singhefe21e62019-09-20 10:03:24 +05304965 vdev_id = mb_msg->session_id;
4966 session = pe_find_session_by_vdev_id(mac_ctx, vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004967 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08004968 cds_packet_free((void *)packet);
Abhishek Singhefe21e62019-09-20 10:03:24 +05304969 pe_err("session not found for given vdev_id %d",
4970 vdev_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304971 return;
4972 }
4973
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05304974 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
4975 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304976
4977 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4978 min_rid = lim_get_min_session_txrate(session);
4979
4980 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4981 (uint16_t)msg_len,
4982 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4983 7, lim_tx_complete, frame,
4984 lim_auth_tx_complete_cnf,
Abhishek Singhefe21e62019-09-20 10:03:24 +05304985 0, vdev_id, false, 0, min_rid);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304986 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4987 session->peSessionId, qdf_status));
4988 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304989 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4990 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304991 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4992 auth_ack_status = SENT_FAIL;
4993 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004994 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304995 /* Pkt will be freed up by the callback */
4996 }
4997}
4998
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004999void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305000 struct scheduler_msg *msg)
5001{
5002 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
5003 uint32_t msg_len;
5004 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
5005 uint8_t sme_session_id;
5006 QDF_STATUS qdf_status;
5007 uint8_t *frame;
5008 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05305009 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305010
5011 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
5012 pe_debug("sending fc->type: %d fc->subType: %d",
5013 fc->type, fc->subType);
5014
5015 sme_session_id = mb_msg->session_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05305016 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
5017
5018 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05305019
5020 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
5021 (void **)&packet);
5022 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
5023 pe_err("call to bufAlloc failed for AUTH frame");
5024 return;
5025 }
5026
5027 qdf_mem_copy(frame, mb_msg->data, msg_len);
5028
5029 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
5030}