blob: 4fe354c4925c9a9bab6b4af4ba944740aea06e90 [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"
36#include "lim_sta_hash_api.h"
37#include "sch_api.h"
38#include "lim_send_messages.h"
39#include "lim_assoc_utils.h"
40#include "lim_ft.h"
41#ifdef WLAN_FEATURE_11W
42#include "wni_cfg.h"
43#endif
44
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "lim_session.h"
Anurag Chouhan6d760662016-02-20 16:05:43 +053047#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053048#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "cds_utils.h"
50#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#include "rrm_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053052#include "qdf_crypto.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053
54#include "wma_types.h"
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -080055#include <cdp_txrx_cmn.h>
Tushnim Bhattacharyya45ed04f2017-03-15 10:15:05 -070056#include <cdp_txrx_peer_ops.h>
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053057#include "lim_process_fils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070058#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059
60/**
61 *
62 * \brief This function is called to add the sequence number to the
63 * management frames
64 *
Jeff Johnson99f25042018-11-21 22:49:06 -080065 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 *
67 * \param pMacHdr Pointer to MAC management header
68 *
69 * The pMacHdr argument points to the MAC management header. The
Jeff Johnson99f25042018-11-21 22:49:06 -080070 * sequence number stored in the mac structure will be incremented
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071 * and updated to the MAC management header. The start sequence
72 * number is WLAN_HOST_SEQ_NUM_MIN and the end value is
73 * WLAN_HOST_SEQ_NUM_MAX. After reaching the MAX value, the sequence
74 * number will roll over.
75 *
76 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080077static void lim_add_mgmt_seq_num(struct mac_context *mac, tpSirMacMgmtHdr pMacHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078{
Jeff Johnson99f25042018-11-21 22:49:06 -080079 if (mac->mgmtSeqNum >= WLAN_HOST_SEQ_NUM_MAX) {
80 mac->mgmtSeqNum = WLAN_HOST_SEQ_NUM_MIN - 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 }
82
Jeff Johnson99f25042018-11-21 22:49:06 -080083 mac->mgmtSeqNum++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084
Jeff Johnson99f25042018-11-21 22:49:06 -080085 pMacHdr->seqControl.seqNumLo = (mac->mgmtSeqNum & LOW_SEQ_NUM_MASK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 pMacHdr->seqControl.seqNumHi =
Jeff Johnson99f25042018-11-21 22:49:06 -080087 ((mac->mgmtSeqNum & HIGH_SEQ_NUM_MASK) >> HIGH_SEQ_NUM_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088}
89
90/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 * lim_populate_mac_header() - Fill in 802.11 header of frame
92 *
93 * @mac_ctx: Pointer to Global MAC structure
94 * @buf: Pointer to the frame buffer that needs to be populate
95 * @type: 802.11 Type of the frame
96 * @sub_type: 802.11 Subtype of the frame
97 * @peer_addr: dst address
98 * @self_mac_addr: local mac address
99 *
100 * This function is called by various LIM modules to prepare the
101 * 802.11 frame MAC header
102 *
103 * The buf argument points to the beginning of the frame buffer to
104 * which - a) The 802.11 MAC header is set b) Following this MAC header
105 * will be the MGMT frame payload The payload itself is populated by the
106 * caller API
107 *
108 * Return: None
109 */
110
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800111void lim_populate_mac_header(struct mac_context *mac_ctx, uint8_t *buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 uint8_t type, uint8_t sub_type, tSirMacAddr peer_addr,
113 tSirMacAddr self_mac_addr)
114{
115 tpSirMacMgmtHdr mac_hdr;
116
117 /* Prepare MAC management header */
118 mac_hdr = (tpSirMacMgmtHdr) (buf);
119
120 /* Prepare FC */
121 mac_hdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
122 mac_hdr->fc.type = type;
123 mac_hdr->fc.subType = sub_type;
124
125 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530126 qdf_mem_copy((uint8_t *) mac_hdr->da,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
128
129 /* Prepare Address 2 */
130 sir_copy_mac_addr(mac_hdr->sa, self_mac_addr);
131
132 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530133 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 (uint8_t *) peer_addr, sizeof(tSirMacAddr));
135
136 /* Prepare sequence number */
137 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700138 pe_debug("seqNumLo=%d, seqNumHi=%d, mgmtSeqNum=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 mac_hdr->seqControl.seqNumLo,
140 mac_hdr->seqControl.seqNumHi, mac_ctx->mgmtSeqNum);
141}
142
143/**
144 * lim_send_probe_req_mgmt_frame() - send probe request management frame
145 * @mac_ctx: Pointer to Global MAC structure
146 * @ssid: SSID to be sent in Probe Request frame
147 * @bssid: BSSID to be sent in Probe Request frame
148 * @channel: Channel # on which the Probe Request is going out
149 * @self_macaddr: self MAC address
150 * @dot11mode: self dotllmode
151 * @additional_ielen: if non-zero, include additional_ie in the Probe Request
152 * frame
153 * @additional_ie: if additional_ielen is non zero, include this field in the
154 * Probe Request frame
155 *
156 * This function is called by various LIM modules to send Probe Request frame
157 * during active scan/learn phase.
158 * Probe request is sent out in the following scenarios:
159 * --heartbeat failure: session needed
160 * --join req: session needed
161 * --foreground scan: no session
162 * --background scan: no session
163 * --sch_beacon_processing: to get EDCA parameters: session needed
164 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700165 * Return: QDF_STATUS (QDF_STATUS_SUCCESS on success and error codes otherwise)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700167QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800168lim_send_probe_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 tSirMacSSid *ssid,
170 tSirMacAddr bssid,
171 uint8_t channel,
172 tSirMacAddr self_macaddr,
173 uint32_t dot11mode,
Jeff Johnson919f2c32019-01-16 11:22:24 -0800174 uint16_t *additional_ielen,
175 uint8_t *additional_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176{
177 tDot11fProbeRequest pr;
178 uint32_t status, bytes, payload;
179 uint8_t *frame;
180 void *packet;
Kapil Guptac03eb072016-08-09 14:01:36 +0530181 QDF_STATUS qdf_status;
Jeff Johnsona7815652018-11-18 22:58:30 -0800182 struct pe_session *pesession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 uint8_t sessionid;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700184 const uint8_t *p2pie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 uint8_t txflag = 0;
186 uint8_t sme_sessionid = 0;
187 bool is_vht_enabled = false;
188 uint8_t txPower;
Arif Hussain4c265132018-04-23 18:55:26 -0700189 uint16_t addn_ielen = 0;
Kapil Guptac03eb072016-08-09 14:01:36 +0530190 bool extracted_ext_cap_flag = false;
191 tDot11fIEExtCap extracted_ext_cap;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700192 QDF_STATUS sir_status;
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530193 const uint8_t *qcn_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
Arif Hussain4c265132018-04-23 18:55:26 -0700195 if (additional_ielen)
196 addn_ielen = *additional_ielen;
197
Jeff Johnson919f2c32019-01-16 11:22:24 -0800198 /*
199 * The probe req should not send 11ac capabilities if band is
200 * 2.4GHz, unless gEnableVhtFor24GHzBand is enabled in INI. So
201 * if gEnableVhtFor24GHzBand is false and dot11mode is 11ac
202 * set it to 11n.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
204 if (channel <= SIR_11B_CHANNEL_END &&
Abhinav Kumare057b412018-10-09 17:28:16 +0530205 !mac_ctx->mlme_cfg->vht_caps.vht_cap_info.b24ghz_band &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530206 (MLME_DOT11_MODE_11AC == dot11mode ||
207 MLME_DOT11_MODE_11AC_ONLY == dot11mode))
208 dot11mode = MLME_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 /*
210 * session context may or may not be present, when probe request needs
211 * to be sent out. Following cases exist:
212 * --heartbeat failure: session needed
213 * --join req: session needed
214 * --foreground scan: no session
215 * --background scan: no session
216 * --sch_beacon_processing: to get EDCA parameters: session needed
217 * If session context does not exist, some IEs will be populated from
218 * CFGs, e.g. Supported and Extended rate set IEs
219 */
220 pesession = pe_find_session_by_bssid(mac_ctx, bssid, &sessionid);
221
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700222 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 sme_sessionid = pesession->smeSessionId;
224
225 /* The scheme here is to fill out a 'tDot11fProbeRequest' structure */
226 /* and then hand it off to 'dot11f_pack_probe_request' (for */
227 /* serialization). We start by zero-initializing the structure: */
hangtian127c9532019-01-12 13:29:07 +0800228 qdf_mem_zero((uint8_t *) &pr, sizeof(pr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
230 /* & delegating to assorted helpers: */
231 populate_dot11f_ssid(mac_ctx, ssid, &pr.SSID);
232
233 if (addn_ielen && additional_ie)
234 p2pie = limGetP2pIEPtr(mac_ctx, additional_ie, addn_ielen);
235
236 /*
237 * Don't include 11b rate if it is a P2P serach or probe request is
238 * sent by P2P Client
239 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700240 if ((MLME_DOT11_MODE_11B != dot11mode) && (p2pie) &&
241 ((pesession) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530242 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 /*
244 * In the below API pass channel number > 14, do that it fills
245 * only 11a rates in supported rates
246 */
247 populate_dot11f_supp_rates(mac_ctx, 15, &pr.SuppRates,
248 pesession);
249 } else {
250 populate_dot11f_supp_rates(mac_ctx, channel,
251 &pr.SuppRates, pesession);
252
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530253 if (MLME_DOT11_MODE_11B != dot11mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 populate_dot11f_ext_supp_rates1(mac_ctx, channel,
255 &pr.ExtSuppRates);
256 }
257 }
258
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 /*
260 * Table 7-14 in IEEE Std. 802.11k-2008 says
261 * DS params "can" be present in RRM is disabled and "is" present if
262 * RRM is enabled. It should be ok even if we add it into probe req when
263 * RRM is not enabled.
264 */
265 populate_dot11f_ds_params(mac_ctx, &pr.DSParams, channel);
266 /* Call RRM module to get the tx power for management used. */
267 txPower = (uint8_t) rrm_get_mgmt_tx_power(mac_ctx, pesession);
268 populate_dot11f_wfatpc(mac_ctx, &pr.WFATPC, txPower, 0);
269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700271 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 pesession->htCapability = IS_DOT11_MODE_HT(dot11mode);
273 /* Include HT Capability IE */
274 if (pesession->htCapability)
275 populate_dot11f_ht_caps(mac_ctx, pesession, &pr.HTCaps);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700276 } else { /* !pesession */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 if (IS_DOT11_MODE_HT(dot11mode))
278 populate_dot11f_ht_caps(mac_ctx, NULL, &pr.HTCaps);
279 }
280
281 /*
282 * Set channelbonding information as "disabled" when tunned to a
283 * 2.4 GHz channel
284 */
285 if (channel <= SIR_11B_CHANNEL_END) {
286 if (mac_ctx->roam.configParam.channelBondingMode24GHz
287 == PHY_SINGLE_CHANNEL_CENTERED) {
288 pr.HTCaps.supportedChannelWidthSet =
289 eHT_CHANNEL_WIDTH_20MHZ;
290 pr.HTCaps.shortGI40MHz = 0;
291 } else {
292 pr.HTCaps.supportedChannelWidthSet =
293 eHT_CHANNEL_WIDTH_40MHZ;
294 }
295 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700296 if (pesession) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 pesession->vhtCapability = IS_DOT11_MODE_VHT(dot11mode);
298 /* Include VHT Capability IE */
299 if (pesession->vhtCapability) {
300 populate_dot11f_vht_caps(mac_ctx, pesession,
301 &pr.VHTCaps);
302 is_vht_enabled = true;
303 }
304 } else {
305 if (IS_DOT11_MODE_VHT(dot11mode)) {
306 populate_dot11f_vht_caps(mac_ctx, pesession,
307 &pr.VHTCaps);
308 is_vht_enabled = true;
309 }
310 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700311 if (pesession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &pr.ExtCap,
313 pesession);
314
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700315 if (IS_DOT11_MODE_HE(dot11mode) && pesession)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800316 lim_update_session_he_capable(mac_ctx, pesession);
317
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700318 pe_debug("Populate HE IEs");
Naveen Rawatd8feac12017-09-08 15:08:39 -0700319 populate_dot11f_he_caps(mac_ctx, pesession, &pr.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800320
Sandeep Puligilla493fea22018-04-30 15:31:17 -0700321 if (addn_ielen && additional_ie) {
Kapil Guptac03eb072016-08-09 14:01:36 +0530322 qdf_mem_zero((uint8_t *)&extracted_ext_cap,
323 sizeof(tDot11fIEExtCap));
324 sir_status = lim_strip_extcap_update_struct(mac_ctx,
325 additional_ie,
326 &addn_ielen,
327 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700328 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700329 pe_debug("Unable to Stripoff ExtCap IE from Probe Req");
Kapil Guptac03eb072016-08-09 14:01:36 +0530330 } else {
331 struct s_ext_cap *p_ext_cap =
332 (struct s_ext_cap *)
333 extracted_ext_cap.bytes;
334 if (p_ext_cap->interworking_service)
335 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +0800336 extracted_ext_cap.num_bytes =
337 lim_compute_ext_cap_ie_length
338 (&extracted_ext_cap);
Kapil Guptac03eb072016-08-09 14:01:36 +0530339 extracted_ext_cap_flag =
Hu Wang411e0cc2016-10-28 14:56:01 +0800340 (extracted_ext_cap.num_bytes > 0);
Arif Hussain4c265132018-04-23 18:55:26 -0700341 if (additional_ielen)
342 *additional_ielen = addn_ielen;
Kapil Guptac03eb072016-08-09 14:01:36 +0530343 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530344 qcn_ie = wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_QCN_OUI_TYPE,
345 SIR_MAC_QCN_OUI_TYPE_SIZE,
346 additional_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 }
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530348 /* Add qcn_ie only if qcn ie is not present in additional_ie */
Wu Gao93816212018-08-31 16:49:54 +0800349 if (mac_ctx->mlme_cfg->sta.qcn_ie_support && !qcn_ie)
Abhishek Singh67e02bd2017-12-11 10:47:12 +0530350 populate_dot11f_qcn_ie(&pr.QCN_IE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351
Hu Wang411e0cc2016-10-28 14:56:01 +0800352 /*
353 * Extcap IE now support variable length, merge Extcap IE from addn_ie
354 * may change the frame size. Therefore, MUST merge ExtCap IE before
355 * dot11f get packed payload size.
356 */
357 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800358 lim_merge_extcap_struct(&pr.ExtCap, &extracted_ext_cap, true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800359
360 /* That's it-- now we pack it. First, how much space are we going to */
361 status = dot11f_get_packed_probe_request_size(mac_ctx, &pr, &payload);
362 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700363 pe_err("Failed to calculate the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800364 status);
365 /* We'll fall back on the worst case scenario: */
366 payload = sizeof(tDot11fProbeRequest);
367 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700368 pe_warn("There were warnings while calculating the packed size for a Probe Request (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800369 status);
370 }
371
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 bytes = payload + sizeof(tSirMacMgmtHdr) + addn_ielen;
373
374 /* Ok-- try to allocate some memory: */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530375 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530377 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700378 pe_err("Failed to allocate %d bytes for a Probe Request", bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700379 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 }
381 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800382 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383
384 /* Next, we fill out the buffer descriptor: */
385 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
386 SIR_MAC_MGMT_PROBE_REQ, bssid, self_macaddr);
387
388 /* That done, pack the Probe Request: */
389 status = dot11f_pack_probe_request(mac_ctx, &pr, frame +
390 sizeof(tSirMacMgmtHdr),
391 payload, &payload);
392 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700393 pe_err("Failed to pack a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700395 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700397 pe_warn("There were warnings while packing a Probe Request (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 }
399 /* Append any AddIE if present. */
400 if (addn_ielen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530401 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 additional_ie, addn_ielen);
403 payload += addn_ielen;
404 }
405
406 /* If this probe request is sent during P2P Search State, then we need
407 * to send it at OFDM rate.
408 */
Abhishek Singh221cf992018-02-22 13:44:53 +0530409 if ((BAND_5G == lim_get_rf_band(channel)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 /*
411 * For unicast probe req mgmt from Join function we don't set
412 * above variables. So we need to add one more check whether it
413 * is pePersona is P2P_CLIENT or not
414 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700415 ((pesession) &&
Abhishek Singh221cf992018-02-22 13:44:53 +0530416 (QDF_P2P_CLIENT_MODE == pesession->pePersona))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 txflag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
418 }
419
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530420 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 wma_tx_frame(mac_ctx, packet,
422 (uint16_t) sizeof(tSirMacMgmtHdr) + payload,
423 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
424 lim_tx_complete, frame, txflag, sme_sessionid,
Naveen Rawat296a5182017-09-25 14:02:48 -0700425 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530426 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700427 pe_err("could not send Probe Request frame!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700429 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 }
431
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700432 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433} /* End lim_send_probe_req_mgmt_frame. */
434
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800435static QDF_STATUS lim_get_addn_ie_for_probe_resp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 uint8_t *addIE, uint16_t *addnIELen,
437 uint8_t probeReqP2pIe)
438{
439 /* If Probe request doesn't have P2P IE, then take out P2P IE
440 from additional IE */
441 if (!probeReqP2pIe) {
442 uint8_t *tempbuf = NULL;
443 uint16_t tempLen = 0;
444 int left = *addnIELen;
445 uint8_t *ptr = addIE;
446 uint8_t elem_id, elem_len;
447
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700448 if (!addIE) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700449 pe_err("NULL addIE pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700450 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 }
452
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530453 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700454 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700455 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456
457 while (left >= 2) {
458 elem_id = ptr[0];
459 elem_len = ptr[1];
460 left -= 2;
461 if (elem_len > left) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700462 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530464 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700465 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 }
Srinivas Girigowda61771262019-04-01 11:55:19 -0700467 if (!((WLAN_ELEMID_VENDOR == elem_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 (memcmp
469 (&ptr[2], SIR_MAC_P2P_OUI,
470 SIR_MAC_P2P_OUI_SIZE) == 0))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530471 qdf_mem_copy(tempbuf + tempLen, &ptr[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 elem_len + 2);
473 tempLen += (elem_len + 2);
474 }
475 left -= elem_len;
476 ptr += (elem_len + 2);
477 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530478 qdf_mem_copy(addIE, tempbuf, tempLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 *addnIELen = tempLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530480 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700482 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483}
484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800486lim_send_probe_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 tSirMacAddr peer_macaddr,
488 tpAniSSID ssid,
Jeff Johnson3c08ace2019-03-12 08:50:37 -0700489 struct pe_session *pe_session,
490 uint8_t preq_p2pie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491{
492 tDot11fProbeResponse *frm;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700493 QDF_STATUS sir_status;
Hu Wang411e0cc2016-10-28 14:56:01 +0800494 uint32_t cfg, payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 tpSirMacMgmtHdr mac_hdr;
496 uint8_t *frame;
Arif Hussainfbf50682016-06-15 12:57:43 -0700497 void *packet = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530498 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499 uint32_t addn_ie_present = false;
500
501 uint16_t addn_ie_len = 0;
gaurank kathpalia837f6202018-09-14 21:55:32 +0530502 bool wps_ap = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 uint8_t tx_flag = 0;
504 uint8_t *add_ie = NULL;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700505 const uint8_t *p2p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 uint8_t noalen = 0;
507 uint8_t total_noalen = 0;
508 uint8_t noa_stream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
509 uint8_t noa_ie[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
510 uint8_t sme_sessionid = 0;
511 bool is_vht_enabled = false;
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +0530512 tDot11fIEExtCap extracted_ext_cap = {0};
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530513 bool extracted_ext_cap_flag = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514
515 /* We don't answer requests in this case*/
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700516 if (ANI_DRIVER_TYPE(mac_ctx) == QDF_DRIVER_TYPE_MFG)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 return;
518
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700519 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 return;
521
522 /*
523 * In case when cac timer is running for this SAP session then
524 * avoid sending probe rsp out. It is violation of dfs specification.
525 */
Anurag Chouhan6d760662016-02-20 16:05:43 +0530526 if (((pe_session->pePersona == QDF_SAP_MODE) ||
527 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 (true == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530529 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 FL("CAC timer is running, probe response dropped"));
531 return;
532 }
533 sme_sessionid = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530534 frm = qdf_mem_malloc(sizeof(tDot11fProbeResponse));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700535 if (!frm)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 /*
539 * Fill out 'frm', after which we'll just hand the struct off to
540 * 'dot11f_pack_probe_response'.
541 */
hangtian127c9532019-01-12 13:29:07 +0800542 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fProbeResponse));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543
544 /*
545 * Timestamp to be updated by TFP, below.
546 *
547 * Beacon Interval:
548 */
549 if (LIM_IS_AP_ROLE(pe_session)) {
550 frm->BeaconInterval.interval =
Jeff Johnsonac057412019-01-06 11:08:55 -0800551 mac_ctx->sch.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 } else {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530553 cfg = mac_ctx->mlme_cfg->sap_cfg.beacon_interval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 frm->BeaconInterval.interval = (uint16_t) cfg;
555 }
556
557 populate_dot11f_capabilities(mac_ctx, &frm->Capabilities, pe_session);
558 populate_dot11f_ssid(mac_ctx, (tSirMacSSid *) ssid, &frm->SSID);
559 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
560 &frm->SuppRates, pe_session);
561
562 populate_dot11f_ds_params(mac_ctx, &frm->DSParams,
563 pe_session->currentOperChannel);
564 populate_dot11f_ibss_params(mac_ctx, &frm->IBSSParams, pe_session);
565
566 if (LIM_IS_AP_ROLE(pe_session)) {
567 if (pe_session->wps_state != SAP_WPS_DISABLED)
568 populate_dot11f_probe_res_wpsi_es(mac_ctx,
569 &frm->WscProbeRes,
570 pe_session);
571 } else {
gaurank kathpalia837f6202018-09-14 21:55:32 +0530572 wps_ap = mac_ctx->mlme_cfg->wps_params.enable_wps &
573 WNI_CFG_WPS_ENABLE_AP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 if (wps_ap)
575 populate_dot11f_wsc_in_probe_res(mac_ctx,
576 &frm->WscProbeRes);
577
578 if (mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState ==
579 eLIM_WSC_ENROLL_BEGIN) {
580 populate_dot11f_wsc_registrar_info_in_probe_res(mac_ctx,
581 &frm->WscProbeRes);
582 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
583 eLIM_WSC_ENROLL_IN_PROGRESS;
584 }
585
586 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
587 eLIM_WSC_ENROLL_END) {
588 de_populate_dot11f_wsc_registrar_info_in_probe_res(
589 mac_ctx, &frm->WscProbeRes);
590 mac_ctx->lim.wscIeInfo.probeRespWscEnrollmentState =
591 eLIM_WSC_ENROLL_NOOP;
592 }
593 }
594
595 populate_dot11f_country(mac_ctx, &frm->Country, pe_session);
596 populate_dot11f_edca_param_set(mac_ctx, &frm->EDCAParamSet, pe_session);
597
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +0530598 if (pe_session->dot11mode != MLME_DOT11_MODE_11B)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 populate_dot11f_erp_info(mac_ctx, &frm->ERPInfo, pe_session);
600
601 populate_dot11f_ext_supp_rates(mac_ctx,
602 POPULATE_DOT11F_RATES_OPERATIONAL,
603 &frm->ExtSuppRates, pe_session);
604
605 /* Populate HT IEs, when operating in 11n */
606 if (pe_session->htCapability) {
607 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
608 populate_dot11f_ht_info(mac_ctx, &frm->HTInfo, pe_session);
609 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 if (pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700611 pe_debug("Populate VHT IE in Probe Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
613 populate_dot11f_vht_operation(mac_ctx, pe_session,
614 &frm->VHTOperation);
615 /*
616 * we do not support multi users yet.
617 * populate_dot11f_vht_ext_bss_load( mac_ctx,
618 * &frm.VHTExtBssLoad );
619 */
620 is_vht_enabled = true;
621 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800623 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700624 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800625 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700626 &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800627 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -0700628 &frm->he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800629 }
630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &frm->ExtCap,
632 pe_session);
633
634 if (pe_session->pLimStartBssReq) {
635 populate_dot11f_wpa(mac_ctx,
636 &(pe_session->pLimStartBssReq->rsnIE),
637 &frm->WPA);
638 populate_dot11f_rsn_opaque(mac_ctx,
639 &(pe_session->pLimStartBssReq->rsnIE),
640 &frm->RSNOpaque);
641 }
642
643 populate_dot11f_wmm(mac_ctx, &frm->WMMInfoAp, &frm->WMMParams,
644 &frm->WMMCaps, pe_session);
645
646#if defined(FEATURE_WLAN_WAPI)
647 if (pe_session->pLimStartBssReq)
648 populate_dot11f_wapi(mac_ctx,
649 &(pe_session->pLimStartBssReq->rsnIE),
650 &frm->WAPI);
651#endif /* defined(FEATURE_WLAN_WAPI) */
652
Liangwei Dongd7c5e012018-12-16 23:56:50 -0500653 /*
654 * Only use CFG for non-listen mode. This CFG is not working for
655 * concurrency. In listening mode, probe rsp IEs is passed in
656 * the message from SME to PE.
657 */
658 addn_ie_present =
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800659 (pe_session->add_ie_params.probeRespDataLen != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660
661 if (addn_ie_present) {
662
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530663 add_ie = qdf_mem_malloc(
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800664 pe_session->add_ie_params.probeRespDataLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700665 if (!add_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 goto err_ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530668 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -0800669 pe_session->add_ie_params.probeRespData_buff,
670 pe_session->add_ie_params.probeRespDataLen);
671 addn_ie_len = pe_session->add_ie_params.probeRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700673 if (QDF_STATUS_SUCCESS != lim_get_addn_ie_for_probe_resp(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 add_ie, &addn_ie_len, preq_p2pie)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700675 pe_err("Unable to get addn_ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 goto err_ret;
677 }
678
679 sir_status = lim_strip_extcap_update_struct(mac_ctx,
680 add_ie, &addn_ie_len,
681 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700682 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700683 pe_debug("Unable to strip off ExtCap IE");
Selvaraj, Sridhar94ece202016-06-23 20:44:09 +0530684 } else {
685 extracted_ext_cap_flag = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 }
687
688 bytes = bytes + addn_ie_len;
689
690 if (preq_p2pie)
691 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0],
692 addn_ie_len);
693
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700694 if (p2p_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 /* get NoA attribute stream P2P IE */
696 noalen = lim_get_noa_attr_stream(mac_ctx,
697 noa_stream, pe_session);
698 if (noalen != 0) {
699 total_noalen =
700 lim_build_p2p_ie(mac_ctx, &noa_ie[0],
701 &noa_stream[0], noalen);
702 bytes = bytes + total_noalen;
703 }
704 }
705 }
706
Hu Wang411e0cc2016-10-28 14:56:01 +0800707 /*
708 * Extcap IE now support variable length, merge Extcap IE from addn_ie
709 * may change the frame size. Therefore, MUST merge ExtCap IE before
710 * dot11f get packed payload size.
711 */
712 if (extracted_ext_cap_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +0800713 lim_merge_extcap_struct(&frm->ExtCap, &extracted_ext_cap,
714 true);
Hu Wang411e0cc2016-10-28 14:56:01 +0800715
716 status = dot11f_get_packed_probe_response_size(mac_ctx, frm, &payload);
717 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700718 pe_err("Probe Response size error (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800719 status);
720 /* We'll fall back on the worst case scenario: */
721 payload = sizeof(tDot11fProbeResponse);
722 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700723 pe_warn("Probe Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +0800724 status);
725 }
726
727 bytes += payload + sizeof(tSirMacMgmtHdr);
728
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530729 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530731 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700732 pe_err("Probe Response allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 goto err_ret;
734 }
735 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +0800736 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
738 /* Next, we fill out the buffer descriptor: */
739 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
740 SIR_MAC_MGMT_PROBE_RSP, peer_macaddr,
741 pe_session->selfMacAddr);
742
743 mac_hdr = (tpSirMacMgmtHdr) frame;
744
745 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 /* That done, pack the Probe Response: */
748 status =
749 dot11f_pack_probe_response(mac_ctx, frm,
750 frame + sizeof(tSirMacMgmtHdr),
751 payload, &payload);
752 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700753 pe_err("Probe Response pack failure (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 status);
755 goto err_ret;
756 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700757 pe_warn("Probe Response pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 }
759
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700760 pe_debug("Sending Probe Response frame to");
Nishank Aggarwal46bd31a2017-03-10 16:23:53 +0530761 lim_print_mac_addr(mac_ctx, peer_macaddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 if (addn_ie_present)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530764 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 &add_ie[0], addn_ie_len);
766
767 if (noalen != 0) {
768 if (total_noalen >
769 (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -0700770 pe_err("Not able to insert NoA, total len=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771 total_noalen);
772 goto err_ret;
773 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530774 qdf_mem_copy(&frame[bytes - (total_noalen)],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 &noa_ie[0], total_noalen);
776 }
777 }
778
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800779 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +0530780 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
781 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 )
783 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
842 AddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
843 AddTSReq.DialogToken.token = pAddTS->dialogToken;
844 AddTSReq.Category.category = SIR_MAC_ACTION_QOS_MGMT;
845 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
896 WMMAddTSReq.Action.action = SIR_MAC_QOS_ADD_TS_REQ;
897 WMMAddTSReq.DialogToken.token = pAddTS->dialogToken;
898 WMMAddTSReq.Category.category = SIR_MAC_ACTION_WME;
899
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,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800947 SIR_MAC_MGMT_ACTION, peerMacAddr, pe_session->selfMacAddr);
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
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800988 if ((BAND_5G ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800989 lim_get_rf_band(pe_session->currentOperChannel))
990 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
991 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 ) {
993 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
994 }
995
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530996 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800997 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -0800998 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800999 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001000 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001
1002 /* Queue Addts Response frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08001003 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 TXRX_FRM_802_11_MGMT,
1005 ANI_TXDIR_TODS,
1006 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001007 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301008 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001009 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001011 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
1012 pe_err("Could not send an Add TS Request (%X",
1013 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014} /* End lim_send_addts_req_action_frame. */
1015
1016/**
1017 * lim_send_assoc_rsp_mgmt_frame() - Send assoc response
1018 * @mac_ctx: Handle for mac context
1019 * @status_code: Status code for assoc response frame
1020 * @aid: Association ID
1021 * @peer_addr: Mac address of requesting peer
1022 * @subtype: Assoc/Reassoc
1023 * @sta: Pointer to station node
1024 * @pe_session: PE session id.
1025 *
1026 * Builds and sends association response frame to the requesting peer.
1027 *
1028 * Return: void
1029 */
1030
1031void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001032lim_send_assoc_rsp_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 uint16_t status_code, uint16_t aid, tSirMacAddr peer_addr,
Jeff Johnsona7815652018-11-18 22:58:30 -08001034 uint8_t subtype, tpDphHashNode sta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035{
1036 static tDot11fAssocResponse frm;
1037 uint8_t *frame;
1038 tpSirMacMgmtHdr mac_hdr;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001039 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 uint8_t lle_mode = 0, addts;
1041 tHalBitVal qos_mode, wme_mode;
Hu Wang411e0cc2016-10-28 14:56:01 +08001042 uint32_t payload, bytes = 0, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301044 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 tUpdateBeaconParams beacon_params;
1046 uint8_t tx_flag = 0;
1047 uint32_t addn_ie_len = 0;
1048 uint8_t add_ie[WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN];
1049 tpSirAssocReq assoc_req = NULL;
1050 uint8_t sme_session = 0;
1051 bool is_vht = false;
1052 uint16_t stripoff_len = 0;
1053 tDot11fIEExtCap extracted_ext_cap;
1054 bool extracted_flag = false;
1055#ifdef WLAN_FEATURE_11W
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301056 uint8_t retry_int;
1057 uint16_t max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058#endif
1059
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001060 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001061 pe_err("pe_session is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 return;
1063 }
1064
1065 sme_session = pe_session->smeSessionId;
1066
hangtian127c9532019-01-12 13:29:07 +08001067 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068
1069 limGetQosMode(pe_session, &qos_mode);
1070 limGetWmeMode(pe_session, &wme_mode);
1071
1072 /*
1073 * An Add TS IE is added only if the AP supports it and
1074 * the requesting STA sent a traffic spec.
1075 */
1076 addts = (qos_mode && sta && sta->qos.addtsPresent) ? 1 : 0;
1077
1078 frm.Status.status = status_code;
1079
1080 frm.AID.associd = aid | LIM_AID_MASK;
1081
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001082 if (!sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 populate_dot11f_supp_rates(mac_ctx,
1084 POPULATE_DOT11F_RATES_OPERATIONAL,
1085 &frm.SuppRates, pe_session);
1086 populate_dot11f_ext_supp_rates(mac_ctx,
1087 POPULATE_DOT11F_RATES_OPERATIONAL,
1088 &frm.ExtSuppRates, pe_session);
1089 } else {
1090 populate_dot11f_assoc_rsp_rates(mac_ctx, &frm.SuppRates,
1091 &frm.ExtSuppRates,
1092 sta->supportedRates.llbRates,
1093 sta->supportedRates.llaRates);
1094 }
1095
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001096 if (LIM_IS_AP_ROLE(pe_session) && sta &&
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001097 QDF_STATUS_SUCCESS == status_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098 assoc_req = (tpSirAssocReq)
1099 pe_session->parsedAssocReq[sta->assocId];
1100 /*
1101 * populate P2P IE in AssocRsp when assocReq from the peer
1102 * includes P2P IE
1103 */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001104 if (assoc_req && assoc_req->addIEPresent)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 populate_dot11_assoc_res_p2p_ie(mac_ctx,
1106 &frm.P2PAssocRes,
1107 assoc_req);
1108 }
1109
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001110 if (sta) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 if (eHAL_SET == qos_mode) {
1112 if (sta->lleEnabled) {
1113 lle_mode = 1;
1114 populate_dot11f_edca_param_set(mac_ctx,
1115 &frm.EDCAParamSet, pe_session);
1116 }
1117 }
1118
1119 if ((!lle_mode) && (eHAL_SET == wme_mode) && sta->wmeEnabled) {
1120 populate_dot11f_wmm_params(mac_ctx, &frm.WMMParams,
1121 pe_session);
1122
1123 if (sta->wsmEnabled)
1124 populate_dot11f_wmm_caps(&frm.WMMCaps);
1125 }
1126
1127 if (sta->mlmStaContext.htCapability &&
1128 pe_session->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001129 pe_debug("Populate HT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 populate_dot11f_ht_caps(mac_ctx, pe_session,
1131 &frm.HTCaps);
Krunal Sonief3294b2015-06-12 15:12:19 -07001132 /*
1133 * Check the STA capability and
1134 * update the HTCaps accordingly
1135 */
1136 frm.HTCaps.supportedChannelWidthSet = (
1137 sta->htSupportedChannelWidthSet <
1138 pe_session->htSupportedChannelWidthSet) ?
1139 sta->htSupportedChannelWidthSet :
1140 pe_session->htSupportedChannelWidthSet;
1141 if (!frm.HTCaps.supportedChannelWidthSet)
1142 frm.HTCaps.shortGI40MHz = 0;
1143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 populate_dot11f_ht_info(mac_ctx, &frm.HTInfo,
1145 pe_session);
1146 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001147 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 +05301148 frm.HTCaps.supportedChannelWidthSet,
1149 frm.HTCaps.mimoPowerSave,
1150 frm.HTCaps.greenField, frm.HTCaps.shortGI20MHz,
1151 frm.HTCaps.shortGI40MHz,
1152 frm.HTCaps.dsssCckMode40MHz,
1153 frm.HTCaps.maxRxAMPDUFactor);
1154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 if (sta->mlmStaContext.vhtCapability &&
1156 pe_session->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001157 pe_debug("Populate VHT IEs in Assoc Response");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 populate_dot11f_vht_caps(mac_ctx, pe_session,
1159 &frm.VHTCaps);
1160 populate_dot11f_vht_operation(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301161 &frm.VHTOperation);
1162 is_vht = true;
1163 }
Naveen Rawat903acca2017-09-15 17:32:13 -07001164
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301165 if (pe_session->vhtCapability &&
1166 pe_session->vendor_vht_sap &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001167 (assoc_req) &&
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301168 assoc_req->vendor_vht_ie.VHTCaps.present) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001169 pe_debug("Populate Vendor VHT IEs in Assoc Rsponse");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301170 frm.vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001171 frm.vendor_vht_ie.sub_type =
1172 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301173 frm.vendor_vht_ie.VHTCaps.present = 1;
1174 populate_dot11f_vht_caps(mac_ctx, pe_session,
1175 &frm.vendor_vht_ie.VHTCaps);
Kiran Kumar Lokerecc448682017-07-20 18:08:01 -07001176 populate_dot11f_vht_operation(mac_ctx, pe_session,
1177 &frm.vendor_vht_ie.VHTOperation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 is_vht = true;
1179 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 populate_dot11f_ext_cap(mac_ctx, is_vht, &frm.ExtCap,
1181 pe_session);
1182
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001183 if (lim_is_sta_he_capable(sta) &&
1184 lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001185 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001186 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001187 &frm.he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001188 populate_dot11f_he_operation(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001189 &frm.he_op);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001190 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191#ifdef WLAN_FEATURE_11W
1192 if (eSIR_MAC_TRY_AGAIN_LATER == status_code) {
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301193 max_retries =
1194 mac_ctx->mlme_cfg->gen.pmf_sa_query_max_retries;
1195 retry_int =
1196 mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1197 populate_dot11f_timeout_interval(mac_ctx,
1198 &frm.TimeoutInterval,
1199 SIR_MAC_TI_TYPE_ASSOC_COMEBACK,
1200 (max_retries -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201 sta->pmfSaQueryRetryCount)
1202 * retry_int);
1203 }
1204#endif
Arif Hussain0c816922017-04-06 15:04:44 -07001205
1206 if (LIM_IS_AP_ROLE(pe_session) && sta->non_ecsa_capable)
1207 pe_session->lim_non_ecsa_cap_num++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 }
1209
hangtian127c9532019-01-12 13:29:07 +08001210 qdf_mem_zero((uint8_t *) &beacon_params, sizeof(beacon_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211
1212 if (LIM_IS_AP_ROLE(pe_session) &&
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301213 (pe_session->gLimProtectionControl !=
1214 MLME_FORCE_POLICY_PROTECTION_DISABLE))
1215 lim_decide_ap_protection(mac_ctx, peer_addr, &beacon_params,
1216 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217
1218 lim_update_short_preamble(mac_ctx, peer_addr, &beacon_params,
1219 pe_session);
1220 lim_update_short_slot_time(mac_ctx, peer_addr, &beacon_params,
1221 pe_session);
1222
1223 /*
1224 * Populate Do11capabilities after updating session with
1225 * Assos req details
1226 */
1227 populate_dot11f_capabilities(mac_ctx, &frm.Capabilities, pe_session);
1228
1229 beacon_params.bssIdx = pe_session->bssIdx;
1230
1231 /* Send message to HAL about beacon parameter change. */
1232 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1233 && beacon_params.paramChangeBitmap) {
1234 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1235 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session);
1236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237
Arif Hussain1513cb22018-01-05 19:56:31 -08001238 lim_obss_send_detection_cfg(mac_ctx, pe_session, false);
1239
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001240 if (assoc_req) {
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001241 addn_ie_len = pe_session->add_ie_params.assocRespDataLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
1243 /* Nonzero length indicates Assoc rsp IE available */
Krishna Kumaar Natarajane4e3a142016-04-01 16:27:51 -07001244 if (addn_ie_len > 0 &&
1245 addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN &&
1246 (bytes + addn_ie_len) <= SIR_MAX_PACKET_SIZE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301247 qdf_mem_copy(add_ie,
Jeff Johnson21aac3a2019-02-02 14:26:13 -08001248 pe_session->add_ie_params.assocRespData_buff,
1249 pe_session->add_ie_params.assocRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250
hangtian127c9532019-01-12 13:29:07 +08001251 qdf_mem_zero((uint8_t *) &extracted_ext_cap,
1252 sizeof(extracted_ext_cap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253
1254 stripoff_len = addn_ie_len;
1255 sir_status =
1256 lim_strip_extcap_update_struct
1257 (mac_ctx, &add_ie[0], &stripoff_len,
1258 &extracted_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001259 if (QDF_STATUS_SUCCESS != sir_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001260 pe_debug("strip off extcap IE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 } else {
1262 addn_ie_len = stripoff_len;
1263 extracted_flag = true;
1264 }
1265 bytes = bytes + addn_ie_len;
1266 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001267 pe_debug("addn_ie_len: %d for Assoc Resp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 addn_ie_len, assoc_req->addIEPresent);
1269 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001270
1271 /*
1272 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1273 * may change the frame size. Therefore, MUST merge ExtCap IE before
1274 * dot11f get packed payload size.
1275 */
1276 if (extracted_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001277 lim_merge_extcap_struct(&(frm.ExtCap), &extracted_ext_cap,
1278 true);
Hu Wang411e0cc2016-10-28 14:56:01 +08001279
1280 /* Allocate a buffer for this frame: */
1281 status = dot11f_get_packed_assoc_response_size(mac_ctx, &frm, &payload);
1282 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001283 pe_err("get Association Response size failure (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001284 status);
1285 return;
1286 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001287 pe_warn("get Association Response size warning (0x%08x)",
Hu Wang411e0cc2016-10-28 14:56:01 +08001288 status);
1289 }
1290
1291 bytes += sizeof(tSirMacMgmtHdr) + payload;
1292
Min Liu0daa0982019-02-01 17:50:44 +08001293 if (sta)
1294 bytes += sta->mlmStaContext.owe_ie_len;
1295
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301296 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301298 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001299 pe_err("cds_packet_alloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 return;
1301 }
1302 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001303 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304
1305 /* Next, we fill out the buffer descriptor: */
1306 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1307 (LIM_ASSOC == subtype) ?
1308 SIR_MAC_MGMT_ASSOC_RSP : SIR_MAC_MGMT_REASSOC_RSP,
1309 peer_addr,
1310 pe_session->selfMacAddr);
1311 mac_hdr = (tpSirMacMgmtHdr) frame;
1312
1313 sir_copy_mac_addr(mac_hdr->bssId, pe_session->bssId);
1314
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 status = dot11f_pack_assoc_response(mac_ctx, &frm,
1316 frame + sizeof(tSirMacMgmtHdr),
1317 payload, &payload);
1318 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001319 pe_err("Association Response pack failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 status);
1321 cds_packet_free((void *)packet);
1322 return;
1323 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001324 pe_warn("Association Response pack warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 status);
1326 }
1327
1328 if (subtype == LIM_ASSOC)
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001329 pe_debug("*** Sending Assoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 status_code, aid);
1331 else
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001332 pe_debug("*** Sending ReAssoc Resp status %d aid %d to",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 status_code, aid);
1334
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301335 lim_print_mac_addr(mac_ctx, mac_hdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336
1337 if (addn_ie_len && addn_ie_len <= WNI_CFG_ASSOC_RSP_ADDNIE_DATA_LEN)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301338 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 &add_ie[0], addn_ie_len);
1340
Min Liu0daa0982019-02-01 17:50:44 +08001341 if (sta && sta->mlmStaContext.owe_ie_len)
1342 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload
1343 + addn_ie_len,
1344 sta->mlmStaContext.owe_ie,
1345 sta->mlmStaContext.owe_ie_len);
1346
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001347 if ((BAND_5G ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 lim_get_rf_band(pe_session->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05301349 (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
1350 (pe_session->pePersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1352
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301353 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 pe_session->peSessionId, mac_hdr->fc.subType));
Krunal Sonic65fc492018-03-09 15:53:28 -08001355 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001356 pe_session, QDF_STATUS_SUCCESS, status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 /* Queue Association Response frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301358 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 TXRX_FRM_802_11_MGMT,
1360 ANI_TXDIR_TODS,
1361 7, lim_tx_complete, frame, tx_flag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001362 sme_session, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301363 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301364 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
1366 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301367 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001368 pe_err("Could not Send Re/AssocRsp, retCode=%X",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301369 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370
1371 /*
1372 * update the ANI peer station count.
1373 * FIXME_PROTECTION : take care of different type of station
1374 * counter inside this function.
1375 */
1376 lim_util_count_sta_add(mac_ctx, sta, pe_session);
1377
1378}
1379
1380void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001381lim_send_delts_req_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 tSirMacAddr peer,
1383 uint8_t wmmTspecPresent,
Jeff Johnson312348f2018-12-22 13:33:54 -08001384 struct mac_ts_info *pTsinfo,
Jeff Johnson56471b92018-12-22 14:36:06 -08001385 struct mac_tspec_ie *pTspecIe,
Jeff Johnson312348f2018-12-22 13:33:54 -08001386 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387{
1388 uint8_t *pFrame;
1389 tpSirMacMgmtHdr pMacHdr;
1390 tDot11fDelTS DelTS;
1391 tDot11fWMMDelTS WMMDelTS;
1392 uint32_t nBytes, nPayload, nStatus;
1393 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301394 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 uint8_t txFlag = 0;
1396 uint8_t smeSessionId = 0;
1397
Jeff Johnson312348f2018-12-22 13:33:54 -08001398 if (!pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001401 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402
1403 if (!wmmTspecPresent) {
hangtian127c9532019-01-12 13:29:07 +08001404 qdf_mem_zero((uint8_t *) &DelTS, sizeof(DelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
1406 DelTS.Category.category = SIR_MAC_ACTION_QOS_MGMT;
1407 DelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1408 populate_dot11f_ts_info(pTsinfo, &DelTS.TSInfo);
1409
Jeff Johnson99f25042018-11-21 22:49:06 -08001410 nStatus = dot11f_get_packed_del_ts_size(mac, &DelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001412 pe_err("Failed to calculate the packed size for a Del TS (0x%08x)",
1413 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 /* We'll fall back on the worst case scenario: */
1415 nPayload = sizeof(tDot11fDelTS);
1416 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001417 pe_warn("There were warnings while calculating the packed size for a Del TS (0x%08x)",
1418 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 }
1420 } else {
hangtian127c9532019-01-12 13:29:07 +08001421 qdf_mem_zero((uint8_t *) &WMMDelTS, sizeof(WMMDelTS));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422
1423 WMMDelTS.Category.category = SIR_MAC_ACTION_WME;
1424 WMMDelTS.Action.action = SIR_MAC_QOS_DEL_TS_REQ;
1425 WMMDelTS.DialogToken.token = 0;
1426 WMMDelTS.StatusCode.statusCode = 0;
1427 populate_dot11f_wmmtspec(pTspecIe, &WMMDelTS.WMMTSPEC);
1428 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08001429 dot11f_get_packed_wmm_del_ts_size(mac, &WMMDelTS, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 if (DOT11F_FAILED(nStatus)) {
Jeff Johnson312348f2018-12-22 13:33:54 -08001431 pe_err("Failed to calculate the packed size for a WMM Del TS (0x%08x)",
1432 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 /* We'll fall back on the worst case scenario: */
1434 nPayload = sizeof(tDot11fDelTS);
1435 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001436 pe_warn("There were warnings while calculating the packed size for a WMM Del TS (0x%08x)",
1437 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 }
1439 }
1440
1441 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
1442
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301443 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
1445 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301446 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001447 pe_err("Failed to allocate %d bytes for an Add TS Response",
1448 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 return;
1450 }
1451 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001452 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453
1454 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08001455 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001456 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 pMacHdr = (tpSirMacMgmtHdr) pFrame;
1458
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001459 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001461 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462
1463 /* That done, pack the struct: */
1464 if (!wmmTspecPresent) {
Jeff Johnson99f25042018-11-21 22:49:06 -08001465 nStatus = dot11f_pack_del_ts(mac, &DelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 pFrame + sizeof(tSirMacMgmtHdr),
1467 nPayload, &nPayload);
1468 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001469 pe_err("Failed to pack a Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 nStatus);
1471 cds_packet_free((void *)pPacket);
1472 return; /* allocated! */
1473 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001474 pe_warn("There were warnings while packing a Del TS frame (0x%08x)",
1475 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 }
1477 } else {
Jeff Johnson99f25042018-11-21 22:49:06 -08001478 nStatus = dot11f_pack_wmm_del_ts(mac, &WMMDelTS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 pFrame + sizeof(tSirMacMgmtHdr),
1480 nPayload, &nPayload);
1481 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001482 pe_err("Failed to pack a WMM Del TS frame (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 nStatus);
1484 cds_packet_free((void *)pPacket);
1485 return; /* allocated! */
1486 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001487 pe_warn("There were warnings while packing a WMM Del TS frame (0x%08x)",
1488 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 }
1490 }
1491
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001492 pe_debug("Sending DELTS REQ (size %d) to ", nBytes);
Jeff Johnson99f25042018-11-21 22:49:06 -08001493 lim_print_mac_addr(mac, pMacHdr->da, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001495 if ((BAND_5G ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001496 lim_get_rf_band(pe_session->currentOperChannel))
1497 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
1498 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 ) {
1500 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
1501 }
1502
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301503 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001504 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08001505 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001506 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001507 QDF_STATUS_SUCCESS);
Jeff Johnson99f25042018-11-21 22:49:06 -08001508 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 TXRX_FRM_802_11_MGMT,
1510 ANI_TXDIR_TODS,
1511 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07001512 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301513 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001514 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 /* Pkt will be freed up by the callback */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301516 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001517 pe_err("Failed to send Del TS (%X)!", qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518
1519} /* End lim_send_delts_req_action_frame. */
1520
1521/**
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301522 * lim_assoc_tx_complete_cnf()- Confirmation for assoc sent over the air
1523 * @context: pointer to global mac
1524 * @buf: buffer
1525 * @tx_complete : Sent status
1526 * @params; tx completion params
1527 *
1528 * Return: This returns QDF_STATUS
1529 */
1530
1531static QDF_STATUS lim_assoc_tx_complete_cnf(void *context,
1532 qdf_nbuf_t buf,
1533 uint32_t tx_complete,
1534 void *params)
1535{
1536 uint16_t assoc_ack_status;
1537 uint16_t reason_code;
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001538 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301539
1540 pe_debug("tx_complete= %d", tx_complete);
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08001541 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301542 assoc_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001543 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301544 } else {
1545 assoc_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001546 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05301547 }
1548 if (buf)
1549 qdf_nbuf_free(buf);
1550
1551 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
1552 NULL, assoc_ack_status, reason_code);
1553 return QDF_STATUS_SUCCESS;
1554}
1555
1556/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 * lim_send_assoc_req_mgmt_frame() - Send association request
1558 * @mac_ctx: Handle to MAC context
1559 * @mlm_assoc_req: Association request information
1560 * @pe_session: PE session information
1561 *
1562 * Builds and transmits association request frame to AP.
1563 *
1564 * Return: Void
1565 */
1566
1567void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001568lim_send_assoc_req_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 tLimMlmAssocReq *mlm_assoc_req,
Jeff Johnsona7815652018-11-18 22:58:30 -08001570 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571{
Naveen Rawat72475db2017-12-13 18:07:35 -08001572 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001573 tDot11fAssocRequest *frm;
1574 uint16_t caps;
1575 uint8_t *frame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001576 QDF_STATUS sir_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 tLimMlmAssocCnf assoc_cnf;
Hu Wang411e0cc2016-10-28 14:56:01 +08001578 uint32_t bytes = 0, payload, status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 uint8_t qos_enabled, wme_enabled, wsm_enabled;
1580 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301581 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 uint16_t add_ie_len;
1583 uint8_t *add_ie;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001584 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 uint8_t power_caps = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 uint8_t tx_flag = 0;
1587 uint8_t sme_sessionid = 0;
1588 bool vht_enabled = false;
1589 tDot11fIEExtCap extr_ext_cap;
1590 bool extr_ext_flag = true;
1591 tpSirMacMgmtHdr mac_hdr;
Hu Wangfbd279d2016-10-31 18:24:34 +08001592 uint32_t ie_offset = 0;
1593 uint8_t *p_ext_cap = NULL;
1594 tDot11fIEExtCap bcn_ext_cap;
1595 uint8_t *bcn_ie = NULL;
1596 uint32_t bcn_ie_len = 0;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301597 uint32_t aes_block_size_len = 0;
Naveen Rawat296a5182017-09-25 14:02:48 -07001598 enum rateid min_rid = RATEID_DEFAULT;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301599 uint8_t *mbo_ie = NULL;
1600 uint8_t mbo_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001602 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001603 pe_err("pe_session is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301604 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 return;
1606 }
1607
1608 sme_sessionid = pe_session->smeSessionId;
1609
1610 /* check this early to avoid unncessary operation */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001611 if (!pe_session->pLimJoinReq) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001612 pe_err("pe_session->pLimJoinReq is NULL");
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301613 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 return;
1615 }
1616 add_ie_len = pe_session->pLimJoinReq->addIEAssoc.length;
1617 add_ie = pe_session->pLimJoinReq->addIEAssoc.addIEdata;
1618
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301619 frm = qdf_mem_malloc(sizeof(tDot11fAssocRequest));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001620 if (!frm) {
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301621 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 return;
1623 }
hangtian127c9532019-01-12 13:29:07 +08001624 qdf_mem_zero((uint8_t *) frm, sizeof(tDot11fAssocRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301626 if (add_ie_len && pe_session->is_ext_caps_present) {
hangtian127c9532019-01-12 13:29:07 +08001627 qdf_mem_zero((uint8_t *) &extr_ext_cap,
1628 sizeof(tDot11fIEExtCap));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 sir_status = lim_strip_extcap_update_struct(mac_ctx,
1630 add_ie, &add_ie_len, &extr_ext_cap);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001631 if (QDF_STATUS_SUCCESS != sir_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 extr_ext_flag = false;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001633 pe_debug("Unable to Stripoff ExtCap IE from Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 } else {
1635 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
1636 extr_ext_cap.bytes;
1637
1638 if (p_ext_cap->interworking_service)
1639 p_ext_cap->qos_map = 1;
Hu Wang411e0cc2016-10-28 14:56:01 +08001640 extr_ext_cap.num_bytes =
1641 lim_compute_ext_cap_ie_length(&extr_ext_cap);
1642 extr_ext_flag = (extr_ext_cap.num_bytes > 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 }
1644 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07001645 pe_debug("No addn IE or peer doesn't support addnIE for Assoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 extr_ext_flag = false;
1647 }
1648
1649 caps = mlm_assoc_req->capabilityInfo;
1650#if defined(FEATURE_WLAN_WAPI)
1651 /*
1652 * According to WAPI standard:
1653 * 7.3.1.4 Capability Information field
1654 * In WAPI, non-AP STAs within an ESS set the Privacy subfield to 0
1655 * in transmitted Association or Reassociation management frames.
1656 * APs ignore the Privacy subfield within received Association and
1657 * Reassociation management frames.
1658 */
1659 if (pe_session->encryptType == eSIR_ED_WPI)
1660 ((tSirMacCapabilityInfo *) &caps)->privacy = 0;
1661#endif
1662 swap_bit_field16(caps, (uint16_t *) &frm->Capabilities);
1663
1664 frm->ListenInterval.interval = mlm_assoc_req->listenInterval;
1665 populate_dot11f_ssid2(mac_ctx, &frm->SSID);
1666 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
1667 &frm->SuppRates, pe_session);
1668
1669 qos_enabled = (pe_session->limQosEnabled) &&
1670 SIR_MAC_GET_QOS(pe_session->limCurrentBssCaps);
1671
1672 wme_enabled = (pe_session->limWmeEnabled) &&
1673 LIM_BSS_CAPS_GET(WME, pe_session->limCurrentBssQosCaps);
1674
1675 /* We prefer .11e asociations: */
1676 if (qos_enabled)
1677 wme_enabled = false;
1678
1679 wsm_enabled = (pe_session->limWsmEnabled) && wme_enabled &&
1680 LIM_BSS_CAPS_GET(WSM, pe_session->limCurrentBssQosCaps);
1681
1682 if (pe_session->lim11hEnable &&
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07001683 pe_session->pLimJoinReq->spectrumMgtIndicator == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 power_caps = true;
1685
1686 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1687 LIM_ASSOC, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 populate_dot11f_supp_channels(mac_ctx, &frm->SuppChannels,
1689 LIM_ASSOC, pe_session);
1690
1691 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1693 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps)) {
1694 if (power_caps == false) {
1695 power_caps = true;
1696 populate_dot11f_power_caps(mac_ctx, &frm->PowerCaps,
1697 LIM_ASSOC, pe_session);
1698 }
1699 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 if (qos_enabled)
Naveen Rawatcd118312016-11-22 10:46:21 -08001701 populate_dot11f_qos_caps_station(mac_ctx, pe_session,
1702 &frm->QOSCapsStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703
1704 populate_dot11f_ext_supp_rates(mac_ctx,
1705 POPULATE_DOT11F_RATES_OPERATIONAL, &frm->ExtSuppRates,
1706 pe_session);
1707
Gupta, Kapil54a16992016-01-13 19:34:02 +05301708 if (mac_ctx->rrm.rrmPEContext.rrmEnable &&
1709 SIR_MAC_GET_RRM(pe_session->limCurrentBssCaps))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 populate_dot11f_rrm_ie(mac_ctx, &frm->RRMEnabledCap,
1711 pe_session);
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08001712
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 /*
1714 * The join request *should* contain zero or one of the WPA and RSN
1715 * IEs. The payload send along with the request is a
Jeff Johnson701444f2019-02-02 22:35:13 -08001716 * 'struct join_req'; the IE portion is held inside a 'tSirRSNie':
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 * typedef struct sSirRSNie
1718 * {
1719 * uint16_t length;
Srinivas Girigowdacf161402019-03-14 11:37:33 -07001720 * uint8_t rsnIEdata[WLAN_MAX_IE_LEN+2];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 * } tSirRSNie, *tpSirRSNie;
1722 * So, we should be able to make the following two calls harmlessly,
1723 * since they do nothing if they don't find the given IE in the
1724 * bytestream with which they're provided.
1725 * The net effect of this will be to faithfully transmit whatever
1726 * security IE is in the join request.
1727 * However, if we're associating for the purpose of WPS
1728 * enrollment, and we've been configured to indicate that by
1729 * eliding the WPA or RSN IE, we just skip this:
1730 */
1731 if (add_ie_len && add_ie)
1732 wps_ie = limGetWscIEPtr(mac_ctx, add_ie, add_ie_len);
1733
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001734 if (!wps_ie) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 populate_dot11f_rsn_opaque(mac_ctx,
1736 &(pe_session->pLimJoinReq->rsnIE),
1737 &frm->RSNOpaque);
1738 populate_dot11f_wpa_opaque(mac_ctx,
1739 &(pe_session->pLimJoinReq->rsnIE),
1740 &frm->WPAOpaque);
1741#if defined(FEATURE_WLAN_WAPI)
1742 populate_dot11f_wapi_opaque(mac_ctx,
1743 &(pe_session->pLimJoinReq->rsnIE),
1744 &frm->WAPIOpaque);
1745#endif /* defined(FEATURE_WLAN_WAPI) */
1746 }
1747 /* include WME EDCA IE as well */
1748 if (wme_enabled) {
1749 populate_dot11f_wmm_info_station_per_session(mac_ctx,
1750 pe_session, &frm->WMMInfoStation);
1751
1752 if (wsm_enabled)
1753 populate_dot11f_wmm_caps(&frm->WMMCaps);
1754 }
1755
1756 /*
1757 * Populate HT IEs, when operating in 11n and
1758 * when AP is also operating in 11n mode
1759 */
1760 if (pe_session->htCapability &&
1761 mac_ctx->lim.htCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001762 pe_debug("Populate HT Caps in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 populate_dot11f_ht_caps(mac_ctx, pe_session, &frm->HTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001764 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1765 &frm->HTCaps, sizeof(frm->HTCaps));
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001766 } else if (pe_session->he_with_wep_tkip) {
1767 pe_debug("Populate HT Caps in Assoc Request with WEP/TKIP");
1768 populate_dot11f_ht_caps(mac_ctx, NULL, &frm->HTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001770 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 +05301771 frm->HTCaps.supportedChannelWidthSet,
1772 frm->HTCaps.mimoPowerSave,
1773 frm->HTCaps.greenField, frm->HTCaps.shortGI20MHz,
1774 frm->HTCaps.shortGI40MHz,
1775 frm->HTCaps.dsssCckMode40MHz,
1776 frm->HTCaps.maxRxAMPDUFactor);
1777
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 if (pe_session->vhtCapability &&
1779 pe_session->vhtCapabilityPresentInBeacon) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001780 pe_debug("Populate VHT IEs in Assoc Request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 populate_dot11f_vht_caps(mac_ctx, pe_session, &frm->VHTCaps);
Naveen Rawata410c5a2016-09-19 14:22:33 -07001782 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1783 &frm->VHTCaps, sizeof(frm->VHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 vht_enabled = true;
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001785 if (pe_session->enableHtSmps &&
1786 !pe_session->supported_nss_1x1) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001787 pe_err("VHT OP mode IE in Assoc Req");
Kiran Kumar Lokere1d4094e2016-08-31 19:04:04 -07001788 populate_dot11f_operating_mode(mac_ctx,
1789 &frm->OperatingMode, pe_session);
1790 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001791 } else if (pe_session->he_with_wep_tkip) {
1792 pe_debug("Populate VHT IEs in Assoc Request with WEP/TKIP");
1793 populate_dot11f_vht_caps(mac_ctx, NULL, &frm->VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 }
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 if (!vht_enabled &&
1797 pe_session->is_vendor_specific_vhtcaps) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001798 pe_debug("Populate Vendor VHT IEs in Assoc Request");
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301799 frm->vendor_vht_ie.present = 1;
Kiran Kumar Lokere81722632017-09-26 12:11:43 -07001800 frm->vendor_vht_ie.sub_type =
1801 pe_session->vendor_specific_vht_ie_sub_type;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301802 frm->vendor_vht_ie.VHTCaps.present = 1;
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05301803 if (!mac_ctx->mlme_cfg->vht_caps.vht_cap_info.vendor_vhtie &&
Abhishek Singh68844282018-01-25 16:48:41 +05301804 pe_session->vht_config.su_beam_formee) {
1805 pe_debug("Disable SU beamformee for vendor IE");
1806 pe_session->vht_config.su_beam_formee = 0;
1807 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 populate_dot11f_vht_caps(mac_ctx, pe_session,
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301809 &frm->vendor_vht_ie.VHTCaps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 vht_enabled = true;
1811 }
Agrawal Ashish0f94b572016-02-22 13:27:06 +05301812 if (pe_session->is_ext_caps_present)
1813 populate_dot11f_ext_cap(mac_ctx, vht_enabled,
1814 &frm->ExtCap, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815
Wu Gao93816212018-08-31 16:49:54 +08001816 if (mac_ctx->mlme_cfg->sta.qcn_ie_support)
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05301817 populate_dot11f_qcn_ie(&frm->QCN_IE);
1818
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001819 if (lim_is_session_he_capable(pe_session)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07001820 pe_debug("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001821 populate_dot11f_he_caps(mac_ctx, pe_session,
Naveen Rawatd8feac12017-09-08 15:08:39 -07001822 &frm->he_cap);
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08001823 } else if (pe_session->he_with_wep_tkip) {
1824 pe_debug("Populate HE IEs in Assoc Request with WEP/TKIP");
1825 populate_dot11f_he_caps(mac_ctx, NULL, &frm->he_cap);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001826 }
Selvaraj, Sridharc2fe7a32017-02-02 19:20:16 +05301827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 if (pe_session->pLimJoinReq->is11Rconnection) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 tSirBssDescription *bssdescr;
1830
1831 bssdescr = &pe_session->pLimJoinReq->bssDescription;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001832 pe_debug("mdie = %02x %02x %02x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 (unsigned int) bssdescr->mdie[0],
1834 (unsigned int) bssdescr->mdie[1],
1835 (unsigned int) bssdescr->mdie[2]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 populate_mdie(mac_ctx, &frm->MobilityDomain,
1837 pe_session->pLimJoinReq->bssDescription.mdie);
1838 } else {
1839 /* No 11r IEs dont send any MDIE */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001840 pe_debug("MDIE not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842
1843#ifdef FEATURE_WLAN_ESE
1844 /*
1845 * ESE Version IE will be included in association request
1846 * when ESE is enabled on DUT through ini and it is also
1847 * advertised by the peer AP to which we are trying to
1848 * associate to.
1849 */
1850 if (pe_session->is_ese_version_ie_present &&
Wu Gao51a63562018-11-08 16:29:10 +08001851 mac_ctx->mlme_cfg->lfr.ese_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 populate_dot11f_ese_version(&frm->ESEVersion);
1853 /* For ESE Associations fill the ESE IEs */
1854 if (pe_session->isESEconnection &&
1855 pe_session->pLimJoinReq->isESEFeatureIniEnabled) {
1856#ifndef FEATURE_DISABLE_RM
1857 populate_dot11f_ese_rad_mgmt_cap(&frm->ESERadMgmtCap);
1858#endif
1859 }
1860#endif
1861
Hu Wang411e0cc2016-10-28 14:56:01 +08001862 /*
1863 * Extcap IE now support variable length, merge Extcap IE from addn_ie
1864 * may change the frame size. Therefore, MUST merge ExtCap IE before
1865 * dot11f get packed payload size.
1866 */
1867 if (extr_ext_flag)
Hu Wangfbd279d2016-10-31 18:24:34 +08001868 lim_merge_extcap_struct(&frm->ExtCap, &extr_ext_cap, true);
1869
1870 /* Clear the bits in EXTCAP IE if AP not advertise it in beacon */
1871 if (frm->ExtCap.present && pe_session->is_ext_caps_present) {
1872 ie_offset = DOT11F_FF_TIMESTAMP_LEN +
1873 DOT11F_FF_BEACONINTERVAL_LEN +
1874 DOT11F_FF_CAPABILITIES_LEN;
1875
1876 qdf_mem_zero((uint8_t *)&bcn_ext_cap, sizeof(tDot11fIEExtCap));
1877 if (pe_session->beacon && pe_session->bcnLen > ie_offset) {
1878 bcn_ie = pe_session->beacon + ie_offset;
1879 bcn_ie_len = pe_session->bcnLen - ie_offset;
Naveen Rawat08db88f2017-09-08 15:07:48 -07001880 p_ext_cap = (uint8_t *)wlan_get_ie_ptr_from_eid(
Hu Wangfbd279d2016-10-31 18:24:34 +08001881 DOT11F_EID_EXTCAP,
Naveen Rawat08db88f2017-09-08 15:07:48 -07001882 bcn_ie, bcn_ie_len);
Hu Wangfbd279d2016-10-31 18:24:34 +08001883 lim_update_extcap_struct(mac_ctx, p_ext_cap,
1884 &bcn_ext_cap);
1885 lim_merge_extcap_struct(&frm->ExtCap, &bcn_ext_cap,
1886 false);
1887 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07001888 /*
1889 * TWT extended capabilities should be populated after the
1890 * intersection of beacon caps and self caps is done because
1891 * the bits for TWT are unique to STA and AP and cannot be
1892 * intersected.
1893 */
1894 populate_dot11f_twt_extended_caps(mac_ctx, pe_session,
1895 &frm->ExtCap);
Hu Wangfbd279d2016-10-31 18:24:34 +08001896 }
Hu Wang411e0cc2016-10-28 14:56:01 +08001897
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001898 if (QDF_STATUS_SUCCESS != lim_strip_supp_op_class_update_struct(mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001899 add_ie, &add_ie_len, &frm->SuppOperatingClasses))
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001900 pe_debug("Unable to Stripoff supp op classes IE from Assoc Req");
Arif Hussain6cec6bc2017-02-14 13:46:26 -08001901
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301902 if (lim_is_fils_connection(pe_session)) {
1903 populate_dot11f_fils_params(mac_ctx, frm, pe_session);
1904 aes_block_size_len = AES_BLOCK_SIZE;
1905 }
1906
1907 /*
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301908 * MBO IE needs to be appendded at the end of the assoc request
1909 * frame and is not parsed and unpacked by the frame parser
1910 * as the supplicant can send multiple TLVs with same Attribute
1911 * in the MBO IE and the frame parser does not support multiple
1912 * TLVs with same attribute in a single IE.
1913 * Strip off the MBO IE from add_ie and append it at the end.
1914 */
1915 if (wlan_get_vendor_ie_ptr_from_oui(SIR_MAC_MBO_OUI,
1916 SIR_MAC_MBO_OUI_SIZE, add_ie, add_ie_len)) {
1917 mbo_ie = qdf_mem_malloc(DOT11F_IE_MBO_IE_MAX_LEN + 2);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001918 if (!mbo_ie)
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301919 goto end;
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301920
1921 qdf_status = lim_strip_ie(mac_ctx, add_ie, &add_ie_len,
Srinivas Girigowda61771262019-04-01 11:55:19 -07001922 WLAN_ELEMID_VENDOR, ONE_BYTE,
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301923 SIR_MAC_MBO_OUI,
1924 SIR_MAC_MBO_OUI_SIZE,
1925 mbo_ie, DOT11F_IE_MBO_IE_MAX_LEN);
1926 if (QDF_IS_STATUS_ERROR(qdf_status)) {
1927 pe_err("Failed to strip MBO IE");
1928 goto free_mbo_ie;
1929 }
1930
1931 /* Include the EID and length fields */
1932 mbo_ie_len = mbo_ie[1] + 2;
1933 pe_debug("Stripped MBO IE of length %d", mbo_ie_len);
1934 }
1935
1936 /*
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301937 * Do unpack to populate the add_ie buffer to frm structure
1938 * before packing the frm structure. In this way, the IE ordering
1939 * which the latest 802.11 spec mandates is maintained.
1940 */
Naveen Rawat72475db2017-12-13 18:07:35 -08001941 if (add_ie_len) {
1942 ret = dot11f_unpack_assoc_request(mac_ctx, add_ie,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301943 add_ie_len, frm, true);
Naveen Rawat72475db2017-12-13 18:07:35 -08001944 if (DOT11F_FAILED(ret)) {
1945 pe_err("unpack failed, ret: 0x%x", ret);
1946 goto end;
1947 }
1948 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 status = dot11f_get_packed_assoc_request_size(mac_ctx, frm, &payload);
1951 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001952 pe_err("Association Request packet size failure(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 status);
1954 /* We'll fall back on the worst case scenario: */
1955 payload = sizeof(tDot11fAssocRequest);
1956 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001957 pe_warn("Association request packet size warning (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 status);
1959 }
1960
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05301961 bytes = payload + sizeof(tSirMacMgmtHdr) +
Vignesh Viswanathandada7932018-09-18 12:57:55 +05301962 aes_block_size_len + mbo_ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301964 qdf_status = cds_packet_alloc((uint16_t) bytes, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 (void **)&packet);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301966 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001967 pe_err("Failed to allocate %d bytes", bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968
1969 pe_session->limMlmState = pe_session->limPrevMlmState;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301970 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_MLM_STATE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 pe_session->peSessionId,
1972 pe_session->limMlmState));
1973
1974 /* Update PE session id */
1975 assoc_cnf.sessionId = pe_session->peSessionId;
1976
1977 assoc_cnf.resultCode = eSIR_SME_RESOURCES_UNAVAILABLE;
1978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_CNF,
1980 (uint32_t *) &assoc_cnf);
1981
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301982 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 }
1984 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08001985 qdf_mem_zero(frame, bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 /* Next, we fill out the buffer descriptor: */
1988 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
1989 SIR_MAC_MGMT_ASSOC_REQ, pe_session->bssId,
1990 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 /* That done, pack the Assoc Request: */
1992 status = dot11f_pack_assoc_request(mac_ctx, frm,
1993 frame + sizeof(tSirMacMgmtHdr), payload, &payload);
1994 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001995 pe_err("Assoc request pack failure (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 cds_packet_free((void *)packet);
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05301997 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07001999 pe_warn("Assoc request pack warning (0x%08x)", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 }
2001
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302002 /* Copy the MBO IE to the end of the frame */
2003 qdf_mem_copy(frame + sizeof(tSirMacMgmtHdr) + payload,
2004 mbo_ie, mbo_ie_len);
2005 payload = payload + mbo_ie_len;
2006
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002007 if (pe_session->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302008 qdf_mem_free(pe_session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 pe_session->assocReq = NULL;
Naveen Rawat83102ef2015-11-03 10:42:34 -08002010 pe_session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 }
2012
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302013 if (lim_is_fils_connection(pe_session)) {
2014 qdf_status = aead_encrypt_assoc_req(mac_ctx, pe_session,
2015 frame, &payload);
2016 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2017 cds_packet_free((void *)packet);
2018 qdf_mem_free(frm);
2019 return;
2020 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002021 }
2022
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302023 pe_session->assocReq = qdf_mem_malloc(payload);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002024 if (pe_session->assocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 /*
2026 * Store the Assoc request. This is sent to csr/hdd in
2027 * join cnf response.
2028 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 qdf_mem_copy(pe_session->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 frame + sizeof(tSirMacMgmtHdr), payload);
2031 pe_session->assocReqLen = payload;
2032 }
2033
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002034 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Anurag Chouhan6d760662016-02-20 16:05:43 +05302035 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE)
2036 || (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 )
2038 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2039
Anurag Chouhan6d760662016-02-20 16:05:43 +05302040 if (pe_session->pePersona == QDF_P2P_CLIENT_MODE ||
2041 pe_session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302045 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 pe_session->peSessionId, mac_hdr->fc.subType));
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05302047
2048 pe_debug("Sending Association Request length %d to ", bytes);
Naveen Rawat296a5182017-09-25 14:02:48 -07002049 min_rid = lim_get_min_session_txrate(pe_session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002050 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002051 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Krunal Sonic65fc492018-03-09 15:53:28 -08002052 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002053 pe_session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302054 qdf_status =
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302055 wma_tx_frameWithTxComplete(mac_ctx, packet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
2057 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302058 lim_tx_complete, frame, lim_assoc_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07002059 tx_flag, sme_sessionid, false, 0, min_rid);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302060 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302061 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302062 pe_session->peSessionId, qdf_status));
Naveen Rawat296a5182017-09-25 14:02:48 -07002063
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302064 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002065 pe_err("Failed to send Association Request (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302066 qdf_status);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302067 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002068 pe_session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 /* Pkt will be freed up by the callback */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 }
Vignesh Viswanathandada7932018-09-18 12:57:55 +05302071free_mbo_ie:
2072 if (mbo_ie)
2073 qdf_mem_free(mbo_ie);
2074
yeshwanth sriram guntuka07831012017-06-30 12:26:57 +05302075end:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076 /* Free up buffer allocated for mlm_assoc_req */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302077 qdf_mem_free(mlm_assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 mlm_assoc_req = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302079 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 return;
2081}
2082
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083/**
Krunal Sonid2136c72018-06-01 17:26:39 -07002084 * lim_addba_rsp_tx_complete_cnf() - Confirmation for add BA response OTA
2085 * @context: pointer to global mac
2086 * @buf: buffer which is nothing but entire ADD BA frame
2087 * @tx_complete : Sent status
2088 * @params; tx completion params
2089 *
2090 * Return: This returns QDF_STATUS
2091 */
2092static QDF_STATUS lim_addba_rsp_tx_complete_cnf(void *context,
2093 qdf_nbuf_t buf,
2094 uint32_t tx_complete,
2095 void *params)
2096{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002097 struct mac_context *mac_ctx = (struct mac_context *)context;
Krunal Sonid2136c72018-06-01 17:26:39 -07002098 tSirMacMgmtHdr *mac_hdr;
2099 tDot11faddba_rsp rsp;
2100 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2101 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
2102 uint8_t peer_id;
2103 void *peer;
2104 uint32_t frame_len;
2105 QDF_STATUS status;
2106 uint8_t *data;
2107
2108 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK)
2109 pe_debug("Add ba response successfully sent");
2110 else
2111 pe_debug("Fail to send add ba response");
2112
2113 if (!buf) {
2114 pe_err("Addba response frame buffer is NULL");
2115 return QDF_STATUS_E_FAILURE;
2116 }
2117
2118 data = qdf_nbuf_data(buf);
2119
2120 if (!data) {
2121 pe_err("Addba response frame is NULL");
2122 return QDF_STATUS_E_FAILURE;
2123 }
2124
2125 mac_hdr = (tSirMacMgmtHdr *)data;
2126 qdf_mem_zero((void *)&rsp, sizeof(tDot11faddba_rsp));
2127 frame_len = sizeof(rsp);
2128 status = dot11f_unpack_addba_rsp(mac_ctx, (uint8_t *)data +
2129 sizeof(*mac_hdr), frame_len,
2130 &rsp, false);
2131
2132 if (DOT11F_FAILED(status)) {
2133 pe_err("Failed to unpack and parse (0x%08x, %d bytes)",
2134 status, frame_len);
2135 goto error;
2136 }
2137
2138 peer = cdp_peer_get_ref_by_addr(soc, pdev, mac_hdr->da, &peer_id,
2139 PEER_DEBUG_ID_WMA_ADDBA_REQ);
2140 if (!peer) {
2141 pe_debug("no PEER found for mac_addr:%pM", mac_hdr->da);
2142 goto error;
2143 }
2144 cdp_addba_resp_tx_completion(soc, peer, rsp.addba_param_set.tid,
2145 tx_complete);
2146 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_WMA_ADDBA_REQ);
2147error:
2148 if (buf)
2149 qdf_nbuf_free(buf);
2150
2151 return QDF_STATUS_SUCCESS;
2152}
2153
2154/**
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302155 * lim_auth_tx_complete_cnf()- Confirmation for auth sent over the air
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302156 * @context: pointer to global mac
2157 * @buf: buffer
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302158 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302159 * @params; tx completion params
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302160 *
2161 * Return: This returns QDF_STATUS
2162 */
2163
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302164static QDF_STATUS lim_auth_tx_complete_cnf(void *context,
2165 qdf_nbuf_t buf,
2166 uint32_t tx_complete,
2167 void *params)
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302168{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002169 struct mac_context *mac_ctx = (struct mac_context *)context;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302170 uint16_t auth_ack_status;
2171 uint16_t reason_code;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302172
Naveen Rawat684e8b12017-09-20 15:54:44 -07002173 pe_debug("tx_complete = %d %s", tx_complete,
Zhu Jianmin5d8e3fe2018-01-04 16:16:20 +08002174 (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) ?
2175 "success" : "fail");
2176 if (tx_complete == WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK) {
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302177 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_SUCCESS;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302178 auth_ack_status = ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002179 reason_code = QDF_STATUS_SUCCESS;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302180 /* 'Change' timer for future activations */
2181 lim_deactivate_and_change_timer(mac_ctx, eLIM_AUTH_RETRY_TIMER);
2182 } else {
2183 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302184 auth_ack_status = NOT_ACKED;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002185 reason_code = QDF_STATUS_E_FAILURE;
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302186 }
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302187
2188 if (buf)
2189 qdf_nbuf_free(buf);
2190
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302191 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
2192 NULL, auth_ack_status, reason_code);
2193
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302194 return QDF_STATUS_SUCCESS;
2195}
2196
2197/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 * lim_send_auth_mgmt_frame() - Send an Authentication frame
2199 *
2200 * @mac_ctx: Pointer to Global MAC structure
2201 * @auth_frame: Pointer to Authentication frame structure
2202 * @peer_addr: MAC address of destination peer
2203 * @wep_bit: wep bit in frame control for Authentication frame3
2204 * @session: PE session information
2205 *
2206 * This function is called by lim_process_mlm_messages(). Authentication frame
2207 * is formatted and sent when this function is called.
2208 *
2209 * Return: void
2210 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002212lim_send_auth_mgmt_frame(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 tpSirMacAuthFrameBody auth_frame,
2214 tSirMacAddr peer_addr,
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302215 uint8_t wep_challenge_len,
Jeff Johnsona7815652018-11-18 22:58:30 -08002216 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217{
2218 uint8_t *frame, *body;
2219 uint32_t frame_len = 0, body_len = 0;
2220 tpSirMacMgmtHdr mac_hdr;
2221 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302222 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 uint8_t tx_flag = 0;
2224 uint8_t sme_sessionid = 0;
2225 uint16_t ft_ies_length = 0;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002226 bool challenge_req = false;
Naveen Rawat296a5182017-09-25 14:02:48 -07002227 enum rateid min_rid = RATEID_DEFAULT;
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302228 uint16_t ch_freq_tx_frame = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002230 if (!session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002231 pe_err("Error: psession Entry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 return;
2233 }
2234
2235 sme_sessionid = session->smeSessionId;
2236
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302237 if (wep_challenge_len) {
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002238 /*
2239 * Auth frame3 to be sent with encrypted framebody
2240 *
2241 * Allocate buffer for Authenticaton frame of size
2242 * equal to management frame header length plus 2 bytes
2243 * each for auth algorithm number, transaction number,
2244 * status code, 128 bytes for challenge text and
2245 * 4 bytes each for IV & ICV.
2246 */
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002247 pe_debug("Sending encrypted auth frame to " MAC_ADDRESS_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002248 QDF_MAC_ADDR_ARRAY(peer_addr));
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002249
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302250 body_len = wep_challenge_len + LIM_ENCR_AUTH_INFO_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002251 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002252
2253 goto alloc_packet;
2254 }
2255
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002256 pe_debug("Sending Auth seq# %d status %d (%d) to "
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002257 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 auth_frame->authTransactionSeqNumber,
2259 auth_frame->authStatusCode,
2260 (auth_frame->authStatusCode == eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002261 QDF_MAC_ADDR_ARRAY(peer_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262
2263 switch (auth_frame->authTransactionSeqNumber) {
2264 case SIR_MAC_AUTH_FRAME_1:
2265 /*
2266 * Allocate buffer for Authenticaton frame of size
2267 * equal to management frame header length plus 2 bytes
2268 * each for auth algorithm number, transaction number
2269 * and status code.
2270 */
2271
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002272 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2273 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302275 frame_len += lim_create_fils_auth_data(mac_ctx,
2276 auth_frame, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 if (auth_frame->authAlgoNumber == eSIR_FT_AUTH) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002278 if (session->ftPEContext.pFTPreAuthReq &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 0 != session->ftPEContext.pFTPreAuthReq->
2280 ft_ies_length) {
2281 ft_ies_length = session->ftPEContext.
2282 pFTPreAuthReq->ft_ies_length;
2283 frame_len += ft_ies_length;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002284 pe_debug("Auth frame, FTIES length added=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 ft_ies_length);
2286 } else {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002287 pe_debug("Auth frame, Does not contain FTIES!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 frame_len += (2 + SIR_MDIE_SIZE);
2289 }
2290 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302291
2292 /* include MDIE in FILS authentication frame */
2293 if (session->pLimJoinReq->is11Rconnection &&
2294 auth_frame->authAlgoNumber == SIR_FILS_SK_WITHOUT_PFS &&
2295 session->pLimJoinReq->bssDescription.mdiePresent)
2296 frame_len += (2 + SIR_MDIE_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 break;
2298
2299 case SIR_MAC_AUTH_FRAME_2:
2300 if ((auth_frame->authAlgoNumber == eSIR_OPEN_SYSTEM) ||
2301 ((auth_frame->authAlgoNumber == eSIR_SHARED_KEY) &&
2302 (auth_frame->authStatusCode !=
2303 eSIR_MAC_SUCCESS_STATUS))) {
2304 /*
2305 * Allocate buffer for Authenticaton frame of size
2306 * equal to management frame header length plus
2307 * 2 bytes each for auth algorithm number,
2308 * transaction number and status code.
2309 */
2310
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002311 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2312 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 } else {
2314 /*
2315 * Shared Key algorithm with challenge text
2316 * to be sent.
2317 *
2318 * Allocate buffer for Authenticaton frame of size
2319 * equal to management frame header length plus
2320 * 2 bytes each for auth algorithm number,
2321 * transaction number, status code and 128 bytes
2322 * for challenge text.
2323 */
2324
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002325 challenge_req = true;
2326 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN +
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302327 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2328 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002329 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 }
2331 break;
2332
2333 case SIR_MAC_AUTH_FRAME_3:
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002334 /*
2335 * Auth frame3 to be sent without encrypted framebody
2336 *
2337 * Allocate buffer for Authenticaton frame of size equal
2338 * to management frame header length plus 2 bytes each
2339 * for auth algorithm number, transaction number and
2340 * status code.
2341 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002343 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2344 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 break;
2346
2347 case SIR_MAC_AUTH_FRAME_4:
2348 /*
2349 * Allocate buffer for Authenticaton frame of size equal
2350 * to management frame header length plus 2 bytes each
2351 * for auth algorithm number, transaction number and
2352 * status code.
2353 */
2354
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002355 body_len = SIR_MAC_AUTH_FRAME_INFO_LEN;
2356 frame_len = sizeof(tSirMacMgmtHdr) + body_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357
2358 break;
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002359 default:
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002360 pe_err("Invalid auth transaction seq num");
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002361 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 } /* switch (auth_frame->authTransactionSeqNumber) */
2363
Krishna Kumaar Natarajan7e6a23c2016-04-05 14:45:24 -07002364alloc_packet:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302365 qdf_status = cds_packet_alloc((uint16_t) frame_len, (void **)&frame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 (void **)&packet);
2367
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302368 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002369 pe_err("call to bufAlloc failed for AUTH frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 return;
2371 }
2372
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302373 qdf_mem_zero(frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374
2375 /* Prepare BD */
2376 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
2377 SIR_MAC_MGMT_AUTH, peer_addr, session->selfMacAddr);
2378 mac_hdr = (tpSirMacMgmtHdr) frame;
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302379 if (wep_challenge_len)
2380 mac_hdr->fc.wep = LIM_WEP_IN_FC;
2381 else
2382 mac_hdr->fc.wep = LIM_NO_WEP_IN_FC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383
2384 /* Prepare BSSId */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07002385 if (LIM_IS_AP_ROLE(session))
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302386 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 (uint8_t *) session->bssId,
2388 sizeof(tSirMacAddr));
2389
2390 /* Prepare Authentication frame body */
2391 body = frame + sizeof(tSirMacMgmtHdr);
2392
yeshwanth sriram guntuka343a3f22017-07-27 18:30:18 +05302393 if (wep_challenge_len) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302394 qdf_mem_copy(body, (uint8_t *) auth_frame, body_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002396 pe_debug("Sending Auth seq# 3 to " MAC_ADDRESS_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002397 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398
2399 } else {
2400 *((uint16_t *) (body)) =
2401 sir_swap_u16if_needed(auth_frame->authAlgoNumber);
2402 body += sizeof(uint16_t);
2403 body_len -= sizeof(uint16_t);
2404
2405 *((uint16_t *) (body)) =
2406 sir_swap_u16if_needed(
2407 auth_frame->authTransactionSeqNumber);
2408 body += sizeof(uint16_t);
2409 body_len -= sizeof(uint16_t);
2410
2411 *((uint16_t *) (body)) =
2412 sir_swap_u16if_needed(auth_frame->authStatusCode);
2413 body += sizeof(uint16_t);
2414 body_len -= sizeof(uint16_t);
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002415
2416 if (challenge_req) {
2417 if (body_len < SIR_MAC_AUTH_CHALLENGE_BODY_LEN) {
Himanshu Agarwalc422ca72017-09-19 11:07:36 +05302418 /* copy challenge IE id, len, challenge text */
2419 *body = auth_frame->type;
2420 body++;
2421 body_len -= sizeof(uint8_t);
2422 *body = auth_frame->length;
2423 body++;
2424 body_len -= sizeof(uint8_t);
2425 qdf_mem_copy(body, auth_frame->challengeText,
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002426 body_len);
2427 pe_err("Incomplete challenge info: length: %d, expected: %d",
2428 body_len,
2429 SIR_MAC_AUTH_CHALLENGE_BODY_LEN);
2430 body += body_len;
2431 body_len = 0;
2432 } else {
2433 /* copy challenge IE id, len, challenge text */
2434 *body = auth_frame->type;
2435 body++;
2436 *body = auth_frame->length;
2437 body++;
2438 qdf_mem_copy(body, auth_frame->challengeText,
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302439 SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH);
2440 body += SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002441
yeshwanth sriram guntuka5c71a292017-08-24 15:51:19 +05302442 body_len -= SIR_MAC_SAP_AUTH_CHALLENGE_LENGTH +
2443 SIR_MAC_CHALLENGE_ID_LEN;
Krishna Kumaar Natarajan0517c602017-06-02 14:58:21 -07002444 }
2445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 if ((auth_frame->authAlgoNumber == eSIR_FT_AUTH) &&
2448 (auth_frame->authTransactionSeqNumber ==
2449 SIR_MAC_AUTH_FRAME_1) &&
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002450 (session->ftPEContext.pFTPreAuthReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451
2452 if (ft_ies_length > 0) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302453 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 session->ftPEContext.
2455 pFTPreAuthReq->ft_ies,
2456 ft_ies_length);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002457 pe_debug("Auth1 Frame FTIE is: ");
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002458 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2459 QDF_TRACE_LEVEL_DEBUG,
2460 (uint8_t *) body,
2461 ft_ies_length);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002462 } else if (session->ftPEContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 pFTPreAuthReq->pbssDescription) {
2464 /* MDID attr is 54 */
Srinivas Girigowda61771262019-04-01 11:55:19 -07002465 *body = WLAN_ELEMID_MOBILITY_DOMAIN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 body++;
2467 *body = SIR_MDIE_SIZE;
2468 body++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302469 qdf_mem_copy(body,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 &session->ftPEContext.pFTPreAuthReq->
2471 pbssDescription->mdie[0],
2472 SIR_MDIE_SIZE);
2473 }
Pragaspathi Thilagaraj239883a2019-03-08 00:33:50 +05302474 } else if ((auth_frame->authAlgoNumber ==
2475 SIR_FILS_SK_WITHOUT_PFS) &&
2476 (auth_frame->authTransactionSeqNumber ==
2477 SIR_MAC_AUTH_FRAME_1)) {
2478 pe_debug("FILS: appending fils Auth data");
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302479 lim_add_fils_data_to_auth_frame(session, body);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002482 pe_debug("*** Sending Auth seq# %d status %d (%d) to "
2483 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 auth_frame->authTransactionSeqNumber,
2485 auth_frame->authStatusCode,
2486 (auth_frame->authStatusCode ==
2487 eSIR_MAC_SUCCESS_STATUS),
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002488 QDF_MAC_ADDR_ARRAY(mac_hdr->da));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 }
Srinivas Girigowdab896a562017-03-16 17:41:26 -07002490 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
2491 QDF_TRACE_LEVEL_DEBUG,
2492 frame, frame_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002494 if ((session->ftPEContext.pFTPreAuthReq) &&
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002495 (BAND_5G == lim_get_rf_band(
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302496 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002498 else if ((BAND_5G ==
Deepthi Gowri1de51e32016-09-01 15:47:28 +05302499 lim_get_rf_band(session->currentOperChannel))
2500 || (session->pePersona == QDF_P2P_CLIENT_MODE)
2501 || (session->pePersona == QDF_P2P_GO_MODE))
2502 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503
Anurag Chouhan6d760662016-02-20 16:05:43 +05302504 if (session->pePersona == QDF_P2P_CLIENT_MODE ||
2505 session->pePersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
2507
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302508 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 session->peSessionId, mac_hdr->fc.subType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302511 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
Naveen Rawat296a5182017-09-25 14:02:48 -07002512 min_rid = lim_get_min_session_txrate(session);
Krunal Sonic65fc492018-03-09 15:53:28 -08002513 lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002514 session, QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302515
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002516 if (session->ftPEContext.pFTPreAuthReq)
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302517 ch_freq_tx_frame = cds_chan_to_freq(
2518 session->ftPEContext.pFTPreAuthReq->preAuthchannelNum);
2519
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302520 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
2521 (uint16_t)frame_len,
2522 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
2523 7, lim_tx_complete, frame,
2524 lim_auth_tx_complete_cnf,
Rajasekaran Kalidoss7152a352018-11-19 09:58:35 +05302525 tx_flag, sme_sessionid, false,
2526 ch_freq_tx_frame, min_rid);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302527 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
2528 session->peSessionId, qdf_status));
2529 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
2530 pe_err("*** Could not send Auth frame, retCode=%X ***",
2531 qdf_status);
2532 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
2533 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002534 session, SENT_FAIL, QDF_STATUS_E_FAILURE);
Abhishek Singhdd2cb572017-08-11 11:10:19 +05302535 /* Pkt will be freed up by the callback */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +05302536 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 return;
2538}
2539
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002540QDF_STATUS lim_send_deauth_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541{
2542 uint16_t aid;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002543 tpDphHashNode sta_ds;
2544 tLimMlmDeauthReq *deauth_req;
2545 tLimMlmDeauthCnf deauth_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002546 struct pe_session *session_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002548 deauth_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq;
2549 if (deauth_req) {
2550 if (tx_timer_running(
2551 &mac_ctx->lim.limTimers.gLimDeauthAckTimer))
2552 lim_deactivate_and_change_timer(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002553 eLIM_DEAUTH_ACK_TIMER);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002555 session_entry = pe_find_session_by_session_id(mac_ctx,
2556 deauth_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002557 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002558 pe_err("session does not exist for given sessionId");
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002559 deauth_cnf.resultCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 eSIR_SME_INVALID_PARAMETERS;
2561 goto end;
2562 }
2563
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002564 sta_ds =
2565 dph_lookup_hash_entry(mac_ctx,
2566 deauth_req->peer_macaddr.bytes,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002567 &aid,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002568 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002569 if (!sta_ds) {
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002570 deauth_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571 goto end;
2572 }
2573
2574 /* / Receive path cleanup with dummy packet */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002575 lim_ft_cleanup_pre_auth_info(mac_ctx, session_entry);
2576 lim_cleanup_rx_path(mac_ctx, sta_ds, session_entry);
2577 if ((session_entry->limSystemRole == eLIM_STA_ROLE) &&
2578 (
Abhishek Singhe0680852015-12-16 14:28:48 +05302579#ifdef FEATURE_WLAN_ESE
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002580 (session_entry->isESEconnection) ||
Abhishek Singhe0680852015-12-16 14:28:48 +05302581#endif
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002582 (session_entry->isFastRoamIniFeatureEnabled) ||
2583 (session_entry->is11Rconnection))) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002584 pe_debug("FT Preauth (%pK,%d) Deauth rc %d src = %d",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002585 session_entry,
2586 session_entry->peSessionId,
2587 deauth_req->reasonCode,
2588 deauth_req->deauthTrigger);
2589 lim_ft_cleanup(mac_ctx, session_entry);
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002590 } else {
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002591#ifdef FEATURE_WLAN_ESE
Nirav Shahf359dd22019-02-20 10:34:28 +05302592 pe_debug("No FT Preauth Session Cleanup in role %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002593 " isESE %d"
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002594 " isLFR %d"
2595 " is11r %d, Deauth reason %d Trigger = %d",
2596 session_entry->limSystemRole,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002597 session_entry->isESEconnection,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002598 session_entry->isFastRoamIniFeatureEnabled,
2599 session_entry->is11Rconnection,
2600 deauth_req->reasonCode,
2601 deauth_req->deauthTrigger);
Nirav Shahf359dd22019-02-20 10:34:28 +05302602#else
2603 pe_debug("No FT Preauth Session Cleanup in role %d"
2604 " isLFR %d"
2605 " is11r %d, Deauth reason %d Trigger = %d",
2606 session_entry->limSystemRole,
2607 session_entry->isFastRoamIniFeatureEnabled,
2608 session_entry->is11Rconnection,
2609 deauth_req->reasonCode,
2610 deauth_req->deauthTrigger);
2611#endif
Deepak Dhamdhere262d95a2016-01-10 16:36:53 -08002612 }
2613 /* Free up buffer allocated for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002614 qdf_mem_free(deauth_req);
2615 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302617 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618end:
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002619 qdf_copy_macaddr(&deauth_cnf.peer_macaddr,
2620 &deauth_req->peer_macaddr);
2621 deauth_cnf.deauthTrigger = deauth_req->deauthTrigger;
2622 deauth_cnf.aid = deauth_req->aid;
2623 deauth_cnf.sessionId = deauth_req->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624
2625 /* Free up buffer allocated */
2626 /* for mlmDeauthReq */
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002627 qdf_mem_free(deauth_req);
2628 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDeauthReq = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002630 lim_post_sme_message(mac_ctx,
2631 LIM_MLM_DEAUTH_CNF, (uint32_t *) &deauth_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302632 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633}
2634
2635/**
2636 * lim_send_disassoc_cnf() - Send disassoc confirmation to SME
2637 *
2638 * @mac_ctx: Handle to MAC context
2639 *
2640 * Sends disassoc confirmation to SME. Removes disassoc request stored
2641 * in lim.
2642 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302643 * Return: QDF_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 */
2645
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002646QDF_STATUS lim_send_disassoc_cnf(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647{
2648 uint16_t aid;
2649 tpDphHashNode sta_ds;
2650 tLimMlmDisassocCnf disassoc_cnf;
Jeff Johnsona7815652018-11-18 22:58:30 -08002651 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 tLimMlmDisassocReq *disassoc_req;
2653
2654 disassoc_req = mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq;
2655 if (disassoc_req) {
2656 if (tx_timer_running(
2657 &mac_ctx->lim.limTimers.gLimDisassocAckTimer))
2658 lim_deactivate_and_change_timer(mac_ctx,
2659 eLIM_DISASSOC_ACK_TIMER);
2660
2661 pe_session = pe_find_session_by_session_id(
2662 mac_ctx, disassoc_req->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002663 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002664 pe_err("No session for given sessionId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 disassoc_cnf.resultCode =
2666 eSIR_SME_INVALID_PARAMETERS;
2667 goto end;
2668 }
2669
2670 sta_ds = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002671 disassoc_req->peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 &pe_session->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002673 if (!sta_ds) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002674 pe_err("StaDs Null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 disassoc_cnf.resultCode = eSIR_SME_INVALID_PARAMETERS;
2676 goto end;
2677 }
2678 /* Receive path cleanup with dummy packet */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002679 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 lim_cleanup_rx_path(mac_ctx, sta_ds, pe_session)) {
2681 disassoc_cnf.resultCode =
2682 eSIR_SME_RESOURCES_UNAVAILABLE;
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002683 pe_err("cleanup_rx_path error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 goto end;
2685 }
Deepak Dhamdhere57c95ff2016-09-30 16:44:44 -07002686 if (LIM_IS_STA_ROLE(pe_session) &&
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002687 (disassoc_req->reasonCode !=
2688 eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON)) {
Jeff Johnson11bd4f32017-09-18 08:15:17 -07002689 pe_debug("FT Preauth Session (%pK %d) Clean up",
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002690 pe_session, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 /* Delete FT session if there exists one */
2693 lim_ft_cleanup_pre_auth_info(mac_ctx, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 /* Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302696 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302698 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302700 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 }
2702end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302703 qdf_mem_copy((uint8_t *) &disassoc_cnf.peerMacAddr,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -08002704 (uint8_t *) disassoc_req->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302705 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 disassoc_cnf.aid = disassoc_req->aid;
2707 disassoc_cnf.disassocTrigger = disassoc_req->disassocTrigger;
2708
2709 /* Update PE session ID */
2710 disassoc_cnf.sessionId = disassoc_req->sessionId;
2711
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002712 if (disassoc_req) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 /* / Free up buffer allocated for mlmDisassocReq */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302714 qdf_mem_free(disassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715 mac_ctx->lim.limDisassocDeauthCnfReq.pMlmDisassocReq = NULL;
2716 }
2717
2718 lim_post_sme_message(mac_ctx, LIM_MLM_DISASSOC_CNF,
2719 (uint32_t *) &disassoc_cnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302720 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721}
2722
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302723QDF_STATUS lim_disassoc_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002724 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302725 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002727 struct mac_context *max_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302728
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002729 pe_debug("tx_success: %d", tx_success);
2730
2731 return lim_send_disassoc_cnf(max_ctx);
2732}
2733
2734static QDF_STATUS lim_disassoc_tx_complete_cnf_handler(void *context,
2735 qdf_nbuf_t buf,
2736 uint32_t tx_success,
2737 void *params)
2738{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002739 struct mac_context *max_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002740 QDF_STATUS status_code;
2741 struct scheduler_msg msg = {0};
2742
2743 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302744
2745 if (buf)
2746 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002747 msg.type = (uint16_t) WMA_DISASSOC_TX_COMP;
2748 msg.bodyptr = params;
2749 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302750
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002751 status_code = lim_post_msg_high_priority(max_ctx, &msg);
2752 if (status_code != QDF_STATUS_SUCCESS)
2753 pe_err("posting message: %X to LIM failed, reason: %d",
2754 msg.type, status_code);
2755 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756}
2757
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302758QDF_STATUS lim_deauth_tx_complete_cnf(void *context,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002759 uint32_t tx_success,
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302760 void *params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002762 struct mac_context *mac_ctx = (struct mac_context *)context;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302763
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002764 pe_debug("tx_success: %d", tx_success);
2765
2766 return lim_send_deauth_cnf(mac_ctx);
2767}
2768
2769static QDF_STATUS lim_deauth_tx_complete_cnf_handler(void *context,
2770 qdf_nbuf_t buf,
2771 uint32_t tx_success,
2772 void *params)
2773{
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002774 struct mac_context *mac_ctx = (struct mac_context *)context;
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002775 QDF_STATUS status_code;
2776 struct scheduler_msg msg = {0};
2777
2778 pe_debug("tx_success: %d", tx_success);
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302779
2780 if (buf)
2781 qdf_nbuf_free(buf);
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002782 msg.type = (uint16_t) WMA_DEAUTH_TX_COMP;
2783 msg.bodyptr = params;
2784 msg.bodyval = tx_success;
Himanshu Agarwal8b472bc2017-01-20 20:49:41 +05302785
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002786 status_code = lim_post_msg_high_priority(mac_ctx, &msg);
2787 if (status_code != QDF_STATUS_SUCCESS)
2788 pe_err("posting message: %X to LIM failed, reason: %d",
2789 msg.type, status_code);
2790 return status_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791}
2792
2793/**
2794 * \brief This function is called to send Disassociate frame.
2795 *
2796 *
Jeff Johnson99f25042018-11-21 22:49:06 -08002797 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 *
2799 * \param nReason Indicates the reason that need to be sent in
2800 * Disassociation frame
2801 *
2802 * \param peerMacAddr MAC address of the STA to which Disassociation frame is
2803 * sent
2804 *
2805 *
2806 */
2807
2808void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002809lim_send_disassoc_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002810 uint16_t nReason,
2811 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002812 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813{
2814 tDot11fDisassociation frm;
2815 uint8_t *pFrame;
2816 tpSirMacMgmtHdr pMacHdr;
2817 uint32_t nBytes, nPayload, nStatus;
2818 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302819 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 uint8_t txFlag = 0;
2821 uint32_t val = 0;
2822 uint8_t smeSessionId = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07002823
Jeff Johnson8e9530b2019-03-18 13:41:42 -07002824 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002825 return;
2826 }
2827
2828 /*
2829 * In case when cac timer is running for this SAP session then
2830 * avoid sending disassoc out. It is violation of dfs specification.
2831 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002832 if (((pe_session->pePersona == QDF_SAP_MODE) ||
2833 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08002834 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302835 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836 FL
2837 ("CAC timer is running, drop disassoc from going out"));
2838 return;
2839 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002840 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841
hangtian127c9532019-01-12 13:29:07 +08002842 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843
2844 frm.Reason.code = nReason;
2845
Jeff Johnson99f25042018-11-21 22:49:06 -08002846 nStatus = dot11f_get_packed_disassociation_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002848 pe_err("Failed to calculate the packed size for a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 nStatus);
2850 /* We'll fall back on the worst case scenario: */
2851 nPayload = sizeof(tDot11fDisassociation);
2852 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002853 pe_warn("There were warnings while calculating the packed size for a Disassociation (0x%08x)",
2854 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 }
2856
2857 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
2858
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302859 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302861 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002862 pe_err("Failed to allocate %d bytes for a Disassociation",
2863 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 return;
2865 }
2866 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08002867 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002868
2869 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08002870 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002871 SIR_MAC_MGMT_DISASSOC, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 pMacHdr = (tpSirMacMgmtHdr) pFrame;
2873
2874 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002875 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002877 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878
Jeff Johnson99f25042018-11-21 22:49:06 -08002879 nStatus = dot11f_pack_disassociation(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 sizeof(tSirMacMgmtHdr),
2881 nPayload, &nPayload);
2882 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002883 pe_err("Failed to pack a Disassociation (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 nStatus);
2885 cds_packet_free((void *)pPacket);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002886 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002888 pe_warn("There were warnings while packing a Disassociation (0x%08x)",
2889 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 }
2891
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002892 pe_debug("***Sessionid %d Sending Disassociation frame with "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 "reason %u and waitForAck %d to " MAC_ADDRESS_STR " ,From "
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002894 MAC_ADDRESS_STR, pe_session->peSessionId, nReason,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002895 waitForAck, QDF_MAC_ADDR_ARRAY(pMacHdr->da),
2896 QDF_MAC_ADDR_ARRAY(pe_session->selfMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002897
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002898 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
2899 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
2900 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 ) {
2902 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
2903 }
2904
Sushant Kaushik46556062015-12-02 16:57:47 +05302905 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906
2907 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302908 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002909 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08002911 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002912 pe_session, QDF_STATUS_SUCCESS,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002913 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914 /* Queue Disassociation frame in high priority WQ */
2915 /* get the duration from the request */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302916 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08002917 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 TXRX_FRM_802_11_MGMT,
2919 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05002920 pFrame, lim_disassoc_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07002921 txFlag, smeSessionId, false, 0,
2922 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302923 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302924 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002925 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926
2927 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
2928
2929 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08002930 (&mac->lim.limTimers.gLimDisassocAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002932 pe_err("Unable to change Disassoc ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 return;
2934 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08002935 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 gLimDisassocAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002937 pe_err("Unable to activate Disassoc ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08002938 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 eLIM_DISASSOC_ACK_TIMER);
2940 return;
2941 }
2942 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302943 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002944 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08002946 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002947 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002948 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08002950 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 TXRX_FRM_802_11_MGMT,
2952 ANI_TXDIR_TODS,
2953 7,
2954 lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07002955 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302956 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05302957 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002958 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302959 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07002960 pe_err("Failed to send Disassociation (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302961 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 /* Pkt will be freed up by the callback */
2963 }
2964 }
2965} /* End lim_send_disassoc_mgmt_frame. */
2966
2967/**
2968 * \brief This function is called to send a Deauthenticate frame
2969 *
2970 *
Jeff Johnson99f25042018-11-21 22:49:06 -08002971 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 *
2973 * \param nReason Indicates the reason that need to be sent in the
2974 * Deauthenticate frame
2975 *
2976 * \param peeer address of the STA to which the frame is to be sent
2977 *
2978 *
2979 */
2980
2981void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002982lim_send_deauth_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 uint16_t nReason,
2984 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002985 struct pe_session *pe_session, bool waitForAck)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986{
2987 tDot11fDeAuth frm;
2988 uint8_t *pFrame;
2989 tpSirMacMgmtHdr pMacHdr;
2990 uint32_t nBytes, nPayload, nStatus;
2991 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302992 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 uint8_t txFlag = 0;
2994 uint32_t val = 0;
2995#ifdef FEATURE_WLAN_TDLS
2996 uint16_t aid;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08002997 tpDphHashNode sta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998#endif
2999 uint8_t smeSessionId = 0;
3000
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003001 if (!pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 return;
3003 }
3004
3005 /*
3006 * In case when cac timer is running for this SAP session then
3007 * avoid deauth frame out. It is violation of dfs specification.
3008 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003009 if (((pe_session->pePersona == QDF_SAP_MODE) ||
3010 (pe_session->pePersona == QDF_P2P_GO_MODE)) &&
Jeff Johnson99f25042018-11-21 22:49:06 -08003011 (true == mac->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303012 QDF_TRACE(QDF_MODULE_ID_SAP, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 FL
3014 ("CAC timer is running, drop the deauth from going out"));
3015 return;
3016 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003017 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018
hangtian127c9532019-01-12 13:29:07 +08003019 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021 frm.Reason.code = nReason;
3022
Jeff Johnson99f25042018-11-21 22:49:06 -08003023 nStatus = dot11f_get_packed_de_auth_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003025 pe_err("Failed to calculate the packed size for a De-Authentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003026 nStatus);
3027 /* We'll fall back on the worst case scenario: */
3028 nPayload = sizeof(tDot11fDeAuth);
3029 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003030 pe_warn("There were warnings while calculating the packed size for a De-Authentication (0x%08x)",
3031 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 }
3033
3034 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3035
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303036 qdf_status = cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303038 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003039 pe_err("Failed to allocate %d bytes for a De-Authentication",
3040 nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 return;
3042 }
3043 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003044 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045
3046 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003047 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003048 SIR_MAC_MGMT_DEAUTH, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3050
3051 /* Prepare the BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003052 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003054 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055
Jeff Johnson99f25042018-11-21 22:49:06 -08003056 nStatus = dot11f_pack_de_auth(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 sizeof(tSirMacMgmtHdr), nPayload, &nPayload);
3058 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003059 pe_err("Failed to pack a DeAuthentication (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 nStatus);
3061 cds_packet_free((void *)pPacket);
3062 return;
3063 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003064 pe_warn("There were warnings while packing a De-Authentication (0x%08x)",
3065 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003067 pe_debug("***Sessionid %d Sending Deauth frame with "
3068 "reason %u and waitForAck %d to " MAC_ADDRESS_STR
3069 " ,From " MAC_ADDRESS_STR,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003070 pe_session->peSessionId, nReason, waitForAck,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003071 QDF_MAC_ADDR_ARRAY(pMacHdr->da),
3072 QDF_MAC_ADDR_ARRAY(pe_session->selfMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003074 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
3075 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
3076 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077 ) {
3078 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3079 }
3080
Sushant Kaushik46556062015-12-02 16:57:47 +05303081 txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003083 sta =
Jeff Johnson99f25042018-11-21 22:49:06 -08003084 dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003085 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086#endif
3087
3088 if (waitForAck) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303089 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003090 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003092 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003093 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003094 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303096 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003097 wma_tx_frameWithTxComplete(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 TXRX_FRM_802_11_MGMT,
3099 ANI_TXDIR_TODS, 7, lim_tx_complete,
Liangwei Dongc0b2e332017-11-16 06:04:46 -05003100 pFrame, lim_deauth_tx_complete_cnf_handler,
Naveen Rawat296a5182017-09-25 14:02:48 -07003101 txFlag, smeSessionId, false, 0,
3102 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303103 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303104 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003105 pe_session->peSessionId, qdf_status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 /* Pkt will be freed up by the callback lim_tx_complete */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303107 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003108 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110
3111 /* Call lim_process_deauth_ack_timeout which will send
3112 * DeauthCnf for this frame
3113 */
Jeff Johnson99f25042018-11-21 22:49:06 -08003114 lim_process_deauth_ack_timeout(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 return;
3116 }
3117
3118 val = SYS_MS_TO_TICKS(LIM_DISASSOC_DEAUTH_ACK_TIMEOUT);
3119
3120 if (tx_timer_change
Jeff Johnson99f25042018-11-21 22:49:06 -08003121 (&mac->lim.limTimers.gLimDeauthAckTimer, val, 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 != TX_SUCCESS) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003123 pe_err("Unable to change Deauth ack Timer val");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 return;
3125 } else if (TX_SUCCESS !=
Jeff Johnson99f25042018-11-21 22:49:06 -08003126 tx_timer_activate(&mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 gLimDeauthAckTimer)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003128 pe_err("Unable to activate Deauth ack Timer");
Jeff Johnson99f25042018-11-21 22:49:06 -08003129 lim_deactivate_and_change_timer(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 eLIM_DEAUTH_ACK_TIMER);
3131 return;
3132 }
3133 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303134 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003135 pe_session->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 pMacHdr->fc.subType));
3137#ifdef FEATURE_WLAN_TDLS
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003138 if ((sta)
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08003139 && (STA_ENTRY_TDLS_PEER == sta->staType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 /* Queue Disassociation frame in high priority WQ */
Jeff Johnson99f25042018-11-21 22:49:06 -08003141 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003142 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003143 QDF_STATUS_SUCCESS,
3144 QDF_STATUS_SUCCESS);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303145 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003146 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
3148 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003149 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 } else {
3151#endif
Jeff Johnson99f25042018-11-21 22:49:06 -08003152 lim_diag_mgmt_tx_event_report(mac, pMacHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003153 pe_session,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003154 QDF_STATUS_SUCCESS,
3155 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 /* Queue Disassociation frame in high priority WQ */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303157 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003158 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3160 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003161 smeSessionId, 0, RATEID_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162#ifdef FEATURE_WLAN_TDLS
3163 }
3164#endif
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303165 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003166 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303167 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003168 pe_err("Failed to send De-Authentication (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303169 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 /* Pkt will be freed up by the callback */
3171 }
3172 }
3173
3174} /* End lim_send_deauth_mgmt_frame. */
3175
3176#ifdef ANI_SUPPORT_11H
3177/**
3178 * \brief Send a Measurement Report Action frame
3179 *
3180 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003181 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 *
3183 * \param pMeasReqFrame Address of a tSirMacMeasReqActionFrame
3184 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003185 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 *
3187 *
3188 */
3189
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003190QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003191lim_send_meas_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 tpSirMacMeasReqActionFrame pMeasReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003193 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194{
3195 tDot11fMeasurementReport frm;
3196 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003197 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 tpSirMacMgmtHdr pMacHdr;
3199 uint32_t nBytes, nPayload, nStatus;
3200 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303201 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202
hangtian127c9532019-01-12 13:29:07 +08003203 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204
3205 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3206 frm.Action.action = SIR_MAC_ACTION_MEASURE_REPORT_ID;
3207 frm.DialogToken.token = pMeasReqFrame->actionHeader.dialogToken;
3208
3209 switch (pMeasReqFrame->measReqIE.measType) {
3210 case SIR_MAC_BASIC_MEASUREMENT_TYPE:
3211 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003212 populate_dot11f_measurement_report0(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 &frm.MeasurementReport);
3214 break;
3215 case SIR_MAC_CCA_MEASUREMENT_TYPE:
3216 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003217 populate_dot11f_measurement_report1(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 &frm.MeasurementReport);
3219 break;
3220 case SIR_MAC_RPI_MEASUREMENT_TYPE:
3221 nSirStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003222 populate_dot11f_measurement_report2(mac, pMeasReqFrame,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 &frm.MeasurementReport);
3224 break;
3225 default:
Jeff Johnson0711e272018-12-14 23:16:38 -08003226 pe_err("Unknown measurement type %d in limSendMeasReportFrame",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 pMeasReqFrame->measReqIE.measType);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003228 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 }
3230
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003231 if (QDF_STATUS_SUCCESS != nSirStatus)
3232 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233
Jeff Johnson99f25042018-11-21 22:49:06 -08003234 nStatus = dot11f_get_packed_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003236 pe_err("Failed to calculate the packed size for a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 nStatus);
3238 /* We'll fall back on the worst case scenario: */
3239 nPayload = sizeof(tDot11fMeasurementReport);
3240 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003241 pe_warn("There were warnings while calculating the packed size for a Measurement Report (0x%08x)",
3242 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 }
3244
3245 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3246
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303247 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003248 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 (uint16_t) nBytes, (void **)&pFrame,
3250 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303251 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0711e272018-12-14 23:16:38 -08003252 pe_err("Failed to allocate %d bytes for a De-Authentication",
3253 nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003254 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 }
3256 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003257 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258
3259 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003260 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 SIR_MAC_MGMT_ACTION, peer);
3262 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3263
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003264 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003266 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267
Jeff Johnson99f25042018-11-21 22:49:06 -08003268 nStatus = dot11f_pack_measurement_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 sizeof(tSirMacMgmtHdr),
3270 nPayload, &nPayload);
3271 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003272 pe_err("Failed to pack a Measurement Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003274 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003276 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003278 pe_warn("There were warnings while packing a Measurement Report (0x%08x)",
3279 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 }
3281
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303282 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003283 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303285 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003286 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003288 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303289 MTRACE(qdf_trace
Anurag Chouhan6d760662016-02-20 16:05:43 +05303290 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003291 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303292 qdf_status));
3293 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003294 pe_err("Failed to send a Measurement Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003297 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 }
3299
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003300 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301
3302} /* End lim_send_meas_report_frame. */
3303
3304/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 * \brief Send a TPC Report Action frame
3306 *
3307 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003308 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 *
3310 * \param pTpcReqFrame Pointer to the received TPC Request
3311 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003312 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 *
3314 *
3315 */
3316
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003317QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003318lim_send_tpc_report_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 tpSirMacTpcReqActionFrame pTpcReqFrame,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003320 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321{
3322 tDot11fTPCReport frm;
3323 uint8_t *pFrame;
3324 tpSirMacMgmtHdr pMacHdr;
3325 uint32_t nBytes, nPayload, nStatus;
3326 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303327 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328
hangtian127c9532019-01-12 13:29:07 +08003329 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330
3331 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3332 frm.Action.action = SIR_MAC_ACTION_TPC_REPORT_ID;
3333 frm.DialogToken.token = pTpcReqFrame->actionHeader.dialogToken;
3334
3335 frm.TPCReport.tx_power = 0;
3336 frm.TPCReport.link_margin = 0;
3337 frm.TPCReport.present = 1;
3338
Jeff Johnson99f25042018-11-21 22:49:06 -08003339 nStatus = dot11f_get_packed_tpc_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003341 pe_err("Failed to calculate the packed size for a TPC Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 /* We'll fall back on the worst case scenario: */
3343 nPayload = sizeof(tDot11fTPCReport);
3344 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003345 pe_warn("There were warnings while calculating the packed size for a TPC Report (0x%08x)",
3346 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347 }
3348
3349 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3350
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303351 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003352 cds_packet_alloc(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353 (uint16_t) nBytes, (void **)&pFrame,
3354 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303355 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003356 pe_err("Failed to allocate %d bytes for a TPC"
3357 " Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003358 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 }
3360 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003361 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362
3363 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003364 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 SIR_MAC_MGMT_ACTION, peer);
3366
3367 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3368
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003369 qdf_mem_copy(pMacHdr->bssId, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003371 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372
Jeff Johnson99f25042018-11-21 22:49:06 -08003373 nStatus = dot11f_pack_tpc_report(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374 sizeof(tSirMacMgmtHdr),
3375 nPayload, &nPayload);
3376 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003377 pe_err("Failed to pack a TPC Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 nStatus);
Jeff Johnson99f25042018-11-21 22:49:06 -08003379 cds_packet_free(mac->hdd_handle, TXRX_FRM_802_11_MGMT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 (void *)pFrame, (void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003381 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003383 pe_warn("There were warnings while packing a TPC Report (0x%08x)",
3384 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303386 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003387 ((pe_session) ? pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 peSessionId : NO_SESSION), pMacHdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303389 qdf_status =
Jeff Johnson99f25042018-11-21 22:49:06 -08003390 wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
Naveen Rawat296a5182017-09-25 14:02:48 -07003392 lim_tx_complete, pFrame, 0, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303393 MTRACE(qdf_trace
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003394 (QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003395 ((pe_session) ? pe_session->peSessionId : NO_SESSION),
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003396 qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303397 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003398 pe_err("Failed to send a TPC Report (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303399 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003401 return QDF_STATUS_E_FAILURE; /* just allocated... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 }
3403
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003404 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405
3406} /* End lim_send_tpc_report_frame. */
3407#endif /* ANI_SUPPORT_11H */
3408
3409/**
3410 * \brief Send a Channel Switch Announcement
3411 *
3412 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003413 * \param mac Pointer to the global MAC datastructure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 *
3415 * \param peer MAC address to which this frame will be sent
3416 *
3417 * \param nMode
3418 *
3419 * \param nNewChannel
3420 *
3421 * \param nCount
3422 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003423 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 *
3425 *
3426 */
3427
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003428QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003429lim_send_channel_switch_mgmt_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 tSirMacAddr peer,
3431 uint8_t nMode,
3432 uint8_t nNewChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003433 uint8_t nCount, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434{
3435 tDot11fChannelSwitch frm;
3436 uint8_t *pFrame;
3437 tpSirMacMgmtHdr pMacHdr;
3438 uint32_t nBytes, nPayload, nStatus; /* , nCfg; */
3439 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303440 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 uint8_t txFlag = 0;
3442
3443 uint8_t smeSessionId = 0;
3444
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003445 if (!pe_session) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003446 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003447 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003449 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450
hangtian127c9532019-01-12 13:29:07 +08003451 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452
3453 frm.Category.category = SIR_MAC_ACTION_SPECTRUM_MGMT;
3454 frm.Action.action = SIR_MAC_ACTION_CHANNEL_SWITCH_ID;
3455 frm.ChanSwitchAnn.switchMode = nMode;
3456 frm.ChanSwitchAnn.newChannel = nNewChannel;
3457 frm.ChanSwitchAnn.switchCount = nCount;
3458 frm.ChanSwitchAnn.present = 1;
3459
Jeff Johnson99f25042018-11-21 22:49:06 -08003460 nStatus = dot11f_get_packed_channel_switch_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003462 pe_err("Failed to calculate the packed size for a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 nStatus);
3464 /* We'll fall back on the worst case scenario: */
3465 nPayload = sizeof(tDot11fChannelSwitch);
3466 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003467 pe_warn("There were warnings while calculating the packed size for a Channel Switch (0x%08x)",
3468 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 }
3470
3471 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3472
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303473 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3475 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003477 pe_err("Failed to allocate %d bytes for a TPC Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003478 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 }
3480 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003481 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482
3483 /* Next, we fill out the buffer descriptor: */
Jeff Johnson99f25042018-11-21 22:49:06 -08003484 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 SIR_MAC_MGMT_ACTION, peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003486 pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 pMacHdr = (tpSirMacMgmtHdr) pFrame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303488 qdf_mem_copy((uint8_t *) pMacHdr->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003489 (uint8_t *) pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003491 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492
Jeff Johnson99f25042018-11-21 22:49:06 -08003493 nStatus = dot11f_pack_channel_switch(mac, &frm, pFrame +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494 sizeof(tSirMacMgmtHdr),
3495 nPayload, &nPayload);
3496 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003497 pe_err("Failed to pack a Channel Switch (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 nStatus);
3499 cds_packet_free((void *)pPacket);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003500 return QDF_STATUS_E_FAILURE; /* allocated! */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003502 pe_warn("There were warnings while packing a Channel Switch (0x%08x)",
3503 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 }
3505
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003506 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
3507 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
3508 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 ) {
3510 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3511 }
3512
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303513 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003514 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003515 qdf_status = wma_tx_frame(mac, pPacket, (uint16_t) nBytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 TXRX_FRM_802_11_MGMT,
3517 ANI_TXDIR_TODS,
3518 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003519 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303520 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003521 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003523 pe_err("Failed to send a Channel Switch (%X)!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303524 qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003526 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 }
3528
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003529 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530
3531} /* End lim_send_channel_switch_mgmt_frame. */
3532
Abhishek Singh518323d2015-10-19 17:42:01 +05303533/**
3534 * lim_send_extended_chan_switch_action_frame()- function to send ECSA
3535 * action frame over the air .
3536 * @mac_ctx: pointer to global mac structure
3537 * @peer: Destination mac.
3538 * @mode: channel switch mode
3539 * @new_op_class: new op class
3540 * @new_channel: new channel to switch
3541 * @count: channel switch count
3542 *
3543 * This function is called to send ECSA frame.
3544 *
3545 * Return: success if frame is sent else return failure
3546 */
3547
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003548QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003549lim_send_extended_chan_switch_action_frame(struct mac_context *mac_ctx,
Abhishek Singh518323d2015-10-19 17:42:01 +05303550 tSirMacAddr peer, uint8_t mode, uint8_t new_op_class,
Jeff Johnsona7815652018-11-18 22:58:30 -08003551 uint8_t new_channel, uint8_t count, struct pe_session *session_entry)
Abhishek Singh518323d2015-10-19 17:42:01 +05303552{
3553 tDot11fext_channel_switch_action_frame frm;
3554 uint8_t *frame;
3555 tpSirMacMgmtHdr mac_hdr;
3556 uint32_t num_bytes, n_payload, status;
3557 void *packet;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303558 QDF_STATUS qdf_status;
Abhishek Singh518323d2015-10-19 17:42:01 +05303559 uint8_t txFlag = 0;
3560 uint8_t sme_session_id = 0;
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303561 uint8_t ch_spacing;
3562 tLimWiderBWChannelSwitchInfo *wide_bw_ie;
Abhishek Singh518323d2015-10-19 17:42:01 +05303563
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003564 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003565 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003566 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303567 }
3568
3569 sme_session_id = session_entry->smeSessionId;
3570
hangtian127c9532019-01-12 13:29:07 +08003571 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh518323d2015-10-19 17:42:01 +05303572
3573 frm.Category.category = SIR_MAC_ACTION_PUBLIC_USAGE;
3574 frm.Action.action = SIR_MAC_ACTION_EXT_CHANNEL_SWITCH_ID;
3575
3576 frm.ext_chan_switch_ann_action.switch_mode = mode;
3577 frm.ext_chan_switch_ann_action.op_class = new_op_class;
3578 frm.ext_chan_switch_ann_action.new_channel = new_channel;
3579 frm.ext_chan_switch_ann_action.switch_count = count;
3580
Vignesh Viswanathan93b7f702017-12-19 17:48:45 +05303581 ch_spacing = wlan_reg_dmn_get_chanwidth_from_opclass(
3582 mac_ctx->scan.countryCodeCurrent, new_channel,
3583 new_op_class);
3584 pe_debug("wrapper: ch_spacing %hu", ch_spacing);
3585
3586 if ((ch_spacing == 80) || (ch_spacing == 160)) {
3587 wide_bw_ie = &session_entry->gLimWiderBWChannelSwitch;
3588 frm.WiderBWChanSwitchAnn.newChanWidth =
3589 wide_bw_ie->newChanWidth;
3590 frm.WiderBWChanSwitchAnn.newCenterChanFreq0 =
3591 wide_bw_ie->newCenterChanFreq0;
3592 frm.WiderBWChanSwitchAnn.newCenterChanFreq1 =
3593 wide_bw_ie->newCenterChanFreq1;
3594 frm.WiderBWChanSwitchAnn.present = 1;
3595 pe_debug("wrapper: width:%d f0:%d f1:%d",
3596 frm.WiderBWChanSwitchAnn.newChanWidth,
3597 frm.WiderBWChanSwitchAnn.newCenterChanFreq0,
3598 frm.WiderBWChanSwitchAnn.newCenterChanFreq1);
3599 }
Abhishek Singh518323d2015-10-19 17:42:01 +05303600
3601 status = dot11f_get_packed_ext_channel_switch_action_frame_size(mac_ctx,
3602 &frm, &n_payload);
3603 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003604 pe_err("Failed to get packed size for Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303605 status);
3606 /* We'll fall back on the worst case scenario*/
3607 n_payload = sizeof(tDot11fext_channel_switch_action_frame);
3608 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003609 pe_warn("There were warnings while calculating the packed size for a Ext Channel Switch (0x%08x)",
Abhishek Singh518323d2015-10-19 17:42:01 +05303610 status);
3611 }
3612
3613 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3614
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303615 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303616 (void **) &frame, (void **) &packet);
3617
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303618 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003619 pe_err("Failed to allocate %d bytes for a Ext Channel Switch",
Abhishek Singh518323d2015-10-19 17:42:01 +05303620 num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003621 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303622 }
3623
3624 /* Paranoia*/
hangtian127c9532019-01-12 13:29:07 +08003625 qdf_mem_zero(frame, num_bytes);
Abhishek Singh518323d2015-10-19 17:42:01 +05303626
3627 /* Next, we fill out the buffer descriptor */
3628 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3629 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3630 mac_hdr = (tpSirMacMgmtHdr) frame;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303631 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
Abhishek Singh518323d2015-10-19 17:42:01 +05303632 (uint8_t *) session_entry->bssId,
3633 sizeof(tSirMacAddr));
3634
gaolez4b62a9e2018-08-16 15:57:50 +08003635 lim_set_protected_bit(mac_ctx, session_entry, peer, mac_hdr);
3636
Abhishek Singh518323d2015-10-19 17:42:01 +05303637 status = dot11f_pack_ext_channel_switch_action_frame(mac_ctx, &frm,
3638 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3639 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003640 pe_err("Failed to pack a Channel Switch 0x%08x", status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303641 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003642 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303643 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003644 pe_warn("There were warnings while packing a Channel Switch 0x%08x",
Abhishek Singh518323d2015-10-19 17:42:01 +05303645 status);
3646 }
3647
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003648 if ((BAND_5G ==
Abhishek Singh518323d2015-10-19 17:42:01 +05303649 lim_get_rf_band(session_entry->currentOperChannel)) ||
Anurag Chouhan6d760662016-02-20 16:05:43 +05303650 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3651 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
Abhishek Singh518323d2015-10-19 17:42:01 +05303652 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3653 }
3654
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003655 pe_debug("Send Ext channel Switch to :"MAC_ADDRESS_STR" with swcount %d, swmode %d , newchannel %d newops %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003656 QDF_MAC_ADDR_ARRAY(mac_hdr->da),
Abhishek Singh518323d2015-10-19 17:42:01 +05303657 frm.ext_chan_switch_ann_action.switch_count,
3658 frm.ext_chan_switch_ann_action.switch_mode,
3659 frm.ext_chan_switch_ann_action.new_channel,
3660 frm.ext_chan_switch_ann_action.op_class);
3661
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303662 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Abhishek Singh518323d2015-10-19 17:42:01 +05303663 session_entry->peSessionId, mac_hdr->fc.subType));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664 qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) num_bytes,
Abhishek Singh518323d2015-10-19 17:42:01 +05303665 TXRX_FRM_802_11_MGMT,
3666 ANI_TXDIR_TODS,
3667 7,
3668 lim_tx_complete, frame,
Naveen Rawat296a5182017-09-25 14:02:48 -07003669 txFlag, sme_session_id, 0,
3670 RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303671 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303672 session_entry->peSessionId, qdf_status));
3673 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003674 pe_err("Failed to send a Ext Channel Switch %X!",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303675 qdf_status);
Abhishek Singh518323d2015-10-19 17:42:01 +05303676 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003677 return QDF_STATUS_E_FAILURE;
Abhishek Singh518323d2015-10-19 17:42:01 +05303678 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003679 return QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +05303680} /* End lim_send_extended_chan_switch_action_frame */
3681
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303682
3683/**
3684 * lim_oper_chan_change_confirm_tx_complete_cnf()- Confirmation for oper_chan_change_confirm
3685 * sent over the air
3686 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303687 * @context: pointer to global mac
3688 * @buf: buffer
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303689 * @tx_complete : Sent status
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303690 * @params: tx completion params
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303691 *
3692 * Return: This returns QDF_STATUS
3693 */
3694
3695static QDF_STATUS lim_oper_chan_change_confirm_tx_complete_cnf(
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303696 void *context,
3697 qdf_nbuf_t buf,
3698 uint32_t tx_complete,
3699 void *params)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303700{
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003701 pe_debug("tx_complete: %d", tx_complete);
Zhu Jianmin83e8b122018-05-18 19:24:45 +08003702 if (buf)
3703 qdf_nbuf_free(buf);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303704 return QDF_STATUS_SUCCESS;
3705}
3706
3707/**
3708 * lim_p2p_oper_chan_change_confirm_action_frame()- function to send
3709 * p2p oper chan change confirm action frame
3710 * @mac_ctx: pointer to global mac structure
3711 * @peer: Destination mac.
3712 * @session_entry: session entry
3713 *
3714 * This function is called to send p2p oper chan change confirm action frame.
3715 *
3716 * Return: success if frame is sent else return failure
3717 */
3718
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003719QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003720lim_p2p_oper_chan_change_confirm_action_frame(struct mac_context *mac_ctx,
Jeff Johnsona7815652018-11-18 22:58:30 -08003721 tSirMacAddr peer, struct pe_session *session_entry)
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303722{
3723 tDot11fp2p_oper_chan_change_confirm frm;
3724 uint8_t *frame;
3725 tpSirMacMgmtHdr mac_hdr;
3726 uint32_t num_bytes, n_payload, status;
3727 void *packet;
3728 QDF_STATUS qdf_status;
3729 uint8_t tx_flag = 0;
3730 uint8_t sme_session_id = 0;
3731
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003732 if (!session_entry) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003733 pe_err("Session entry is NULL!!!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003734 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303735 }
3736
3737 sme_session_id = session_entry->smeSessionId;
3738
hangtian127c9532019-01-12 13:29:07 +08003739 qdf_mem_zero(&frm, sizeof(frm));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303740
3741 frm.Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
3742
3743 qdf_mem_copy(frm.p2p_action_oui.oui_data,
3744 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
3745 frm.p2p_action_subtype.subtype = 0x04;
3746 frm.DialogToken.token = 0x0;
3747
3748 if (session_entry->htCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003749 pe_debug("Populate HT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303750 populate_dot11f_ht_caps(mac_ctx, session_entry, &frm.HTCaps);
3751 }
3752
3753 if (session_entry->vhtCapability) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003754 pe_debug("Populate VHT Caps in Assoc Request");
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303755 populate_dot11f_vht_caps(mac_ctx, session_entry, &frm.VHTCaps);
3756 populate_dot11f_operating_mode(mac_ctx,
3757 &frm.OperatingMode, session_entry);
3758 }
3759
3760 status = dot11f_get_packed_p2p_oper_chan_change_confirmSize(mac_ctx,
3761 &frm, &n_payload);
3762 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003763 pe_err("Failed to get packed size 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303764 /* We'll fall back on the worst case scenario*/
3765 n_payload = sizeof(tDot11fp2p_oper_chan_change_confirm);
3766 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003767 pe_warn("There were warnings while calculating the packed size (0x%08x)",
3768 status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303769 }
3770
3771 num_bytes = n_payload + sizeof(tSirMacMgmtHdr);
3772
3773 qdf_status = cds_packet_alloc((uint16_t)num_bytes,
3774 (void **) &frame, (void **) &packet);
3775
3776 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003777 pe_err("Failed to allocate %d bytes", num_bytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003778 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303779 }
3780
hangtian127c9532019-01-12 13:29:07 +08003781 qdf_mem_zero(frame, num_bytes);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303782
3783 /* Next, fill out the buffer descriptor */
3784 lim_populate_mac_header(mac_ctx, frame, SIR_MAC_MGMT_FRAME,
3785 SIR_MAC_MGMT_ACTION, peer, session_entry->selfMacAddr);
3786 mac_hdr = (tpSirMacMgmtHdr) frame;
3787 qdf_mem_copy((uint8_t *) mac_hdr->bssId,
3788 (uint8_t *) session_entry->bssId,
3789 sizeof(tSirMacAddr));
3790
3791 status = dot11f_pack_p2p_oper_chan_change_confirm(mac_ctx, &frm,
3792 frame + sizeof(tSirMacMgmtHdr), n_payload, &n_payload);
3793 if (DOT11F_FAILED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003794 pe_err("Failed to pack 0x%08x", status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303795 cds_packet_free((void *)packet);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003796 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303797 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003798 pe_warn("There were warnings while packing 0x%08x",
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303799 status);
3800 }
3801
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003802 if ((BAND_5G ==
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303803 lim_get_rf_band(session_entry->currentOperChannel)) ||
3804 (session_entry->pePersona == QDF_P2P_CLIENT_MODE) ||
3805 (session_entry->pePersona == QDF_P2P_GO_MODE)) {
3806 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3807 }
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003808 pe_debug("Send frame on channel %d to mac "
3809 MAC_ADDRESS_STR, session_entry->currentOperChannel,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003810 QDF_MAC_ADDR_ARRAY(peer));
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303811
3812 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
3813 session_entry->peSessionId, mac_hdr->fc.subType));
3814
3815 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
3816 (uint16_t)num_bytes,
3817 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
3818 7, lim_tx_complete, frame,
3819 lim_oper_chan_change_confirm_tx_complete_cnf,
Naveen Rawat296a5182017-09-25 14:02:48 -07003820 tx_flag, sme_session_id, false, 0, RATEID_DEFAULT);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303821
3822 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
3823 session_entry->peSessionId, qdf_status));
3824 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003825 pe_err("Failed to send status %X!", qdf_status);
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303826 /* Pkt will be freed up by the callback */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003827 return QDF_STATUS_E_FAILURE;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303828 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003829 return QDF_STATUS_SUCCESS;
Abhishek Singh5695e2a2016-10-28 10:39:12 +05303830}
3831
3832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833/**
3834 * \brief Send a Neighbor Report Request Action frame
3835 *
3836 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003837 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838 *
3839 * \param pNeighborReq Address of a tSirMacNeighborReportReq
3840 *
3841 * \param peer mac address of peer station.
3842 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003843 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003845 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 *
3847 *
3848 */
3849
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003850QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003851lim_send_neighbor_report_request_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003852 tpSirMacNeighborReportReq pNeighborReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003853 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003855 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 tDot11fNeighborReportRequest frm;
3857 uint8_t *pFrame;
3858 tpSirMacMgmtHdr pMacHdr;
3859 uint32_t nBytes, nPayload, nStatus;
3860 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303861 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 uint8_t txFlag = 0;
3863 uint8_t smeSessionId = 0;
3864
Jeff Johnson8e9530b2019-03-18 13:41:42 -07003865 if (!pe_session) {
3866 pe_err("(!psession) in Request to send Neighbor Report request action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003867 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003869 smeSessionId = pe_session->smeSessionId;
hangtian127c9532019-01-12 13:29:07 +08003870 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871
3872 frm.Category.category = SIR_MAC_ACTION_RRM;
3873 frm.Action.action = SIR_MAC_RRM_NEIGHBOR_REQ;
3874 frm.DialogToken.token = pNeighborReq->dialogToken;
3875
3876 if (pNeighborReq->ssid_present) {
Jeff Johnson99f25042018-11-21 22:49:06 -08003877 populate_dot11f_ssid(mac, &pNeighborReq->ssid, &frm.SSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 }
3879
3880 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08003881 dot11f_get_packed_neighbor_report_request_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003883 pe_err("Failed to calculate the packed size for a Neighbor Report Request(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 nStatus);
3885 /* We'll fall back on the worst case scenario: */
3886 nPayload = sizeof(tDot11fNeighborReportRequest);
3887 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003888 pe_warn("There were warnings while calculating the packed size for a Neighbor Report Request(0x%08x)",
3889 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 }
3891
3892 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
3893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303894 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
3896 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303897 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003898 pe_err("Failed to allocate %d bytes for a Neighbor "
3899 "Report Request", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003900 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 }
3902 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08003903 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904
3905 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08003906 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003907 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908
3909 /* Update A3 with the BSSID */
3910 pMacHdr = (tpSirMacMgmtHdr) pFrame;
3911
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003912 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003914 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915
3916 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08003917 nStatus = dot11f_pack_neighbor_report_request(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 &frm,
3919 pFrame +
3920 sizeof(tSirMacMgmtHdr),
3921 nPayload, &nPayload);
3922
3923 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003924 pe_err("Failed to pack an Neighbor Report Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 nStatus);
3926
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003927 /* FIXME - Need to convert to QDF_STATUS */
3928 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 goto returnAfterError;
3930 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003931 pe_warn("There were warnings while packing Neighbor Report Request (0x%08x)",
3932 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 }
3934
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003935 pe_debug("Sending a Neighbor Report Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08003936 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003938 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
3939 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
3940 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 ) {
3942 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
3943 }
3944
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303945 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003946 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08003947 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 pPacket,
3949 (uint16_t) nBytes,
3950 TXRX_FRM_802_11_MGMT,
3951 ANI_TXDIR_TODS,
3952 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07003953 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303954 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003955 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303956 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07003957 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003958 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 /* Pkt will be freed up by the callback */
3960 return statusCode;
3961 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003962 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963
3964returnAfterError:
3965 cds_packet_free((void *)pPacket);
3966
3967 return statusCode;
3968} /* End lim_send_neighbor_report_request_frame. */
3969
3970/**
3971 * \brief Send a Link Report Action frame
3972 *
3973 *
Jeff Johnson99f25042018-11-21 22:49:06 -08003974 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975 *
3976 * \param pLinkReport Address of a tSirMacLinkReport
3977 *
3978 * \param peer mac address of peer station.
3979 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003980 * \param pe_session address of session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003982 * \return QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 *
3984 *
3985 */
3986
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003987QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08003988lim_send_link_report_action_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 tpSirMacLinkReport pLinkReport,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003990 tSirMacAddr peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003992 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 tDot11fLinkMeasurementReport frm;
3994 uint8_t *pFrame;
3995 tpSirMacMgmtHdr pMacHdr;
3996 uint32_t nBytes, nPayload, nStatus;
3997 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303998 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 uint8_t txFlag = 0;
4000 uint8_t smeSessionId = 0;
4001
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004002 if (!pe_session) {
4003 pe_err("(!psession) in Request to send Link Report action frame");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004004 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 }
4006
hangtian127c9532019-01-12 13:29:07 +08004007 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008
4009 frm.Category.category = SIR_MAC_ACTION_RRM;
4010 frm.Action.action = SIR_MAC_RRM_LINK_MEASUREMENT_RPT;
4011 frm.DialogToken.token = pLinkReport->dialogToken;
4012
4013 /* IEEE Std. 802.11 7.3.2.18. for the report element. */
4014 /* Even though TPC report an IE, it is represented using fixed fields since it is positioned */
4015 /* in the middle of other fixed fields in the link report frame(IEEE Std. 802.11k section7.4.6.4 */
4016 /* and frame parser always expects IEs to come after all fixed fields. It is easier to handle */
4017 /* such case this way than changing the frame parser. */
Srinivas Girigowda61771262019-04-01 11:55:19 -07004018 frm.TPCEleID.TPCId = WLAN_ELEMID_TPCREP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 frm.TPCEleLen.TPCLen = 2;
4020 frm.TxPower.txPower = pLinkReport->txPower;
4021 frm.LinkMargin.linkMargin = 0;
4022
4023 frm.RxAntennaId.antennaId = pLinkReport->rxAntenna;
4024 frm.TxAntennaId.antennaId = pLinkReport->txAntenna;
4025 frm.RCPI.rcpi = pLinkReport->rcpi;
4026 frm.RSNI.rsni = pLinkReport->rsni;
4027
4028 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004029 dot11f_get_packed_link_measurement_report_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004031 pe_err("Failed to calculate the packed size for a Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 /* We'll fall back on the worst case scenario: */
4033 nPayload = sizeof(tDot11fLinkMeasurementReport);
4034 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004035 pe_warn("There were warnings while calculating the packed size for a Link Report (0x%08x)",
4036 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
4038
4039 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4040
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304041 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4043 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304044 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004045 pe_err("Failed to allocate %d bytes for a Link "
4046 "Report", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004047 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004048 }
4049 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004050 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051
4052 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004053 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004054 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055
4056 /* Update A3 with the BSSID */
4057 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4058
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004059 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004061 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062
4063 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004064 nStatus = dot11f_pack_link_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065 &frm,
4066 pFrame +
4067 sizeof(tSirMacMgmtHdr),
4068 nPayload, &nPayload);
4069
4070 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004071 pe_err("Failed to pack an Link Report (0x%08x)", nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004073 /* FIXME - Need to convert to QDF_STATUS */
4074 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 goto returnAfterError;
4076 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004077 pe_warn("There were warnings while packing Link Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 nStatus);
4079 }
4080
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004081 pe_warn("Sending a Link Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004082 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004084 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
4085 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
4086 (pe_session->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4088 }
4089
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304090 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004091 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004092 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 pPacket,
4094 (uint16_t) nBytes,
4095 TXRX_FRM_802_11_MGMT,
4096 ANI_TXDIR_TODS,
4097 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004098 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304099 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004100 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304101 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004102 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004103 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 /* Pkt will be freed up by the callback */
4105 return statusCode;
4106 } else
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004107 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108
4109returnAfterError:
4110 cds_packet_free((void *)pPacket);
4111
4112 return statusCode;
4113} /* End lim_send_link_report_action_frame. */
4114
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004115QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004116lim_send_radio_measure_report_action_frame(struct mac_context *mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304117 uint8_t dialog_token,
4118 uint8_t num_report,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304119 bool is_last_frame,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304120 tpSirMacRadioMeasureReport pRRMReport,
4121 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004122 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004124 QDF_STATUS statusCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 uint8_t *pFrame;
4126 tpSirMacMgmtHdr pMacHdr;
4127 uint32_t nBytes, nPayload, nStatus;
4128 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304129 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004130 uint8_t i;
4131 uint8_t txFlag = 0;
4132 uint8_t smeSessionId = 0;
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304133 bool is_last_report = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134
4135 tDot11fRadioMeasurementReport *frm =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304136 qdf_mem_malloc(sizeof(tDot11fRadioMeasurementReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004137 if (!frm)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004138 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004140 if (!pe_session) {
4141 pe_err("(!psession) in Request to send Beacon Report action frame");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304142 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004143 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004146 smeSessionId = pe_session->smeSessionId;
Deepak Dhamdhere6a021482017-04-20 17:59:58 -07004147
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05304148 pe_debug("dialog_token %d num_report %d is_last_frame %d",
4149 dialog_token, num_report, is_last_frame);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05304150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 frm->Category.category = SIR_MAC_ACTION_RRM;
4152 frm->Action.action = SIR_MAC_RRM_RADIO_MEASURE_RPT;
4153 frm->DialogToken.token = dialog_token;
4154
4155 frm->num_MeasurementReport =
4156 (num_report >
4157 RADIO_REPORTS_MAX_IN_A_FRAME) ? RADIO_REPORTS_MAX_IN_A_FRAME :
4158 num_report;
4159
4160 for (i = 0; i < frm->num_MeasurementReport; i++) {
4161 frm->MeasurementReport[i].type = pRRMReport[i].type;
4162 frm->MeasurementReport[i].token = pRRMReport[i].token;
4163 frm->MeasurementReport[i].late = 0; /* IEEE 802.11k section 7.3.22. (always zero in rrm) */
4164 switch (pRRMReport[i].type) {
4165 case SIR_MAC_RRM_BEACON_TYPE:
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304166 /*
4167 * Last beacon report indication needs to be set to 1
4168 * only for the last report in the last frame
4169 */
4170 if (is_last_frame &&
4171 (i == (frm->num_MeasurementReport - 1)))
4172 is_last_report = true;
4173
Jeff Johnson99f25042018-11-21 22:49:06 -08004174 populate_dot11f_beacon_report(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05304175 &frm->MeasurementReport[i],
4176 &pRRMReport[i].report.
4177 beaconReport,
Vignesh Viswanathan793328d2018-11-02 11:32:35 +05304178 is_last_report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 frm->MeasurementReport[i].incapable =
4180 pRRMReport[i].incapable;
4181 frm->MeasurementReport[i].refused =
4182 pRRMReport[i].refused;
4183 frm->MeasurementReport[i].present = 1;
4184 break;
4185 default:
4186 frm->MeasurementReport[i].incapable =
4187 pRRMReport[i].incapable;
4188 frm->MeasurementReport[i].refused =
4189 pRRMReport[i].refused;
4190 frm->MeasurementReport[i].present = 1;
4191 break;
4192 }
4193 }
4194
4195 nStatus =
Jeff Johnson99f25042018-11-21 22:49:06 -08004196 dot11f_get_packed_radio_measurement_report_size(mac, frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004198 pe_err("Failed to calculate the packed size for a Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 nStatus);
4200 /* We'll fall back on the worst case scenario: */
4201 nPayload = sizeof(tDot11fLinkMeasurementReport);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304202 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004203 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004205 pe_warn("There were warnings while calculating the packed size for a Radio Measure Report (0x%08x)",
4206 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 }
4208
4209 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
4210
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304211 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 cds_packet_alloc((uint16_t) nBytes, (void **)&pFrame,
4213 (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304214 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004215 pe_err("Failed to allocate %d bytes for a Radio Measure "
4216 "Report", nBytes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304217 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004218 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 }
4220 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004221 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222
4223 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004224 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004225 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226
4227 /* Update A3 with the BSSID */
4228 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4229
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004230 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004232 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233
4234 /* Now, we're ready to "pack" the frames */
Jeff Johnson99f25042018-11-21 22:49:06 -08004235 nStatus = dot11f_pack_radio_measurement_report(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236 frm,
4237 pFrame +
4238 sizeof(tSirMacMgmtHdr),
4239 nPayload, &nPayload);
4240
4241 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004242 pe_err("Failed to pack an Radio Measure Report (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 nStatus);
4244
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004245 /* FIXME - Need to convert to QDF_STATUS */
4246 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 goto returnAfterError;
4248 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004249 pe_warn("There were warnings while packing Radio Measure Report (0x%08x)",
4250 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 }
4252
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004253 pe_warn("Sending a Radio Measure Report to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004254 lim_print_mac_addr(mac, peer, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004256 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
4257 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
4258 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 ) {
4260 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4261 }
4262
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304263 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004264 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004265 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 pPacket,
4267 (uint16_t) nBytes,
4268 TXRX_FRM_802_11_MGMT,
4269 ANI_TXDIR_TODS,
4270 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004271 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304272 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004273 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304274 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004275 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004276 statusCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 /* Pkt will be freed up by the callback */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304278 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 return statusCode;
4280 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304281 qdf_mem_free(frm);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004282 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 }
4284
4285returnAfterError:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_free(frm);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 cds_packet_free((void *)pPacket);
4288 return statusCode;
4289}
4290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291#ifdef WLAN_FEATURE_11W
4292/**
4293 * \brief Send SA query request action frame to peer
4294 *
4295 * \sa lim_send_sa_query_request_frame
4296 *
4297 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004298 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 *
4300 * \param transId Transaction identifier
4301 *
4302 * \param peer The Mac address of the station to which this action frame is addressed
4303 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004304 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004306 * \return QDF_STATUS_SUCCESS if setup completes successfully
4307 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 */
4309
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004310QDF_STATUS lim_send_sa_query_request_frame(struct mac_context *mac, uint8_t *transId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004312 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313{
4314
4315 tDot11fSaQueryReq frm; /* SA query request action frame */
4316 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004317 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 tpSirMacMgmtHdr pMacHdr;
4319 uint32_t nBytes, nPayload, nStatus;
4320 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304321 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004322 uint8_t txFlag = 0;
4323 uint8_t smeSessionId = 0;
4324
hangtian127c9532019-01-12 13:29:07 +08004325 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4327 /* 11w action field is :
4328 action: 0 --> SA Query Request action frame
4329 action: 1 --> SA Query Response action frame */
4330 frm.Action.action = SIR_MAC_SA_QUERY_REQ;
4331 /* 11w SA Query Request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304332 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333
Jeff Johnson99f25042018-11-21 22:49:06 -08004334 nStatus = dot11f_get_packed_sa_query_req_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004336 pe_err("Failed to calculate the packed size for an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 nStatus);
4338 /* We'll fall back on the worst case scenario: */
4339 nPayload = sizeof(tDot11fSaQueryReq);
4340 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004341 pe_warn("There were warnings while calculating the packed size for an SA Query Request (0x%08x)",
4342 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004343 }
4344
4345 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304346 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004347 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304348 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004349 pe_err("Failed to allocate %d bytes for a SA Query Request "
4350 "action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004351 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 }
4353 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004354 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355
4356 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004357 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004358 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359
4360 /* Update A3 with the BSSID */
4361 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4362
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004363 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364
4365 /* Since this is a SA Query Request, set the "protect" (aka WEP) bit */
4366 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004367 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368
4369 /* Pack 11w SA Query Request frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004370 nStatus = dot11f_pack_sa_query_req(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 &frm,
4372 pFrame + sizeof(tSirMacMgmtHdr),
4373 nPayload, &nPayload);
4374
4375 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004376 pe_err("Failed to pack an SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004378 /* FIXME - Need to convert to QDF_STATUS */
4379 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 goto returnAfterError;
4381 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004382 pe_warn("There were warnings while packing SA Query Request (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383 nStatus);
4384 }
4385
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004386 pe_debug("Sending an SA Query Request to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004387 lim_print_mac_addr(mac, peer, LOGD);
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004388 pe_debug("Sending an SA Query Request from ");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004389 lim_print_mac_addr(mac, pe_session->selfMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004390
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004391 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392#ifdef WLAN_FEATURE_P2P
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004393 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
4394 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395#endif
4396 ) {
4397 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4398 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004399 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400
Jeff Johnson99f25042018-11-21 22:49:06 -08004401 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 pPacket,
4403 (uint16_t) nBytes,
4404 TXRX_FRM_802_11_MGMT,
4405 ANI_TXDIR_TODS,
4406 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004407 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304408 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004409 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004410 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 /* Pkt will be freed up by the callback */
4412 return nSirStatus;
4413 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004414 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 }
4416
4417returnAfterError:
4418 cds_packet_free((void *)pPacket);
4419 return nSirStatus;
4420} /* End lim_send_sa_query_request_frame */
4421
4422/**
4423 * \brief Send SA query response action frame to peer
4424 *
4425 * \sa lim_send_sa_query_response_frame
4426 *
4427 *
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004428 * \param mac The global struct mac_context *object
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429 *
4430 * \param transId Transaction identifier received in SA query request action frame
4431 *
4432 * \param peer The Mac address of the AP to which this action frame is addressed
4433 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004434 * \param pe_session The PE session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004436 * \return QDF_STATUS_SUCCESS if setup completes successfully
4437 * QDF_STATUS_E_FAILURE is some problem is encountered
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004438 */
4439
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004440QDF_STATUS lim_send_sa_query_response_frame(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 uint8_t *transId, tSirMacAddr peer,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004442 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443{
4444
Jeff Johnson47d75242018-05-12 15:58:53 -07004445 tDot11fSaQueryRsp frm; /* SA query response action frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 uint8_t *pFrame;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004447 QDF_STATUS nSirStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 tpSirMacMgmtHdr pMacHdr;
4449 uint32_t nBytes, nPayload, nStatus;
4450 void *pPacket;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304451 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 uint8_t txFlag = 0;
4453 uint8_t smeSessionId = 0;
4454
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004455 smeSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456
hangtian127c9532019-01-12 13:29:07 +08004457 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 frm.Category.category = SIR_MAC_ACTION_SA_QUERY;
4459 /*11w action field is :
4460 action: 0 --> SA query request action frame
4461 action: 1 --> SA query response action frame */
4462 frm.Action.action = SIR_MAC_SA_QUERY_RSP;
4463 /*11w SA query response transId is same as
4464 SA query request transId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304465 qdf_mem_copy(&frm.TransactionId.transId[0], &transId[0], 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466
Jeff Johnson99f25042018-11-21 22:49:06 -08004467 nStatus = dot11f_get_packed_sa_query_rsp_size(mac, &frm, &nPayload);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004469 pe_err("Failed to calculate the packed size for a SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 nStatus);
4471 /* We'll fall back on the worst case scenario: */
4472 nPayload = sizeof(tDot11fSaQueryRsp);
4473 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004474 pe_warn("There were warnings while calculating the packed size for an SA Query Response (0x%08x)",
4475 nStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 }
4477
4478 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304479 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480 cds_packet_alloc(nBytes, (void **)&pFrame, (void **)&pPacket);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304481 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004482 pe_err("Failed to allocate %d bytes for a SA query response"
4483 " action frame", nBytes);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004484 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 }
4486 /* Paranoia: */
hangtian127c9532019-01-12 13:29:07 +08004487 qdf_mem_zero(pFrame, nBytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488
4489 /* Copy necessary info to BD */
Jeff Johnson99f25042018-11-21 22:49:06 -08004490 lim_populate_mac_header(mac, pFrame, SIR_MAC_MGMT_FRAME,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004491 SIR_MAC_MGMT_ACTION, peer, pe_session->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492
4493 /* Update A3 with the BSSID */
4494 pMacHdr = (tpSirMacMgmtHdr) pFrame;
4495
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004496 sir_copy_mac_addr(pMacHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497
4498 /* Since this is a SA Query Response, set the "protect" (aka WEP) bit */
4499 /* in the FC */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004500 lim_set_protected_bit(mac, pe_session, peer, pMacHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
4502 /* Pack 11w SA query response frame */
Jeff Johnson99f25042018-11-21 22:49:06 -08004503 nStatus = dot11f_pack_sa_query_rsp(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 &frm,
4505 pFrame + sizeof(tSirMacMgmtHdr),
4506 nPayload, &nPayload);
4507
4508 if (DOT11F_FAILED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004509 pe_err("Failed to pack an SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 nStatus);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004511 /* FIXME - Need to convert to QDF_STATUS */
4512 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 goto returnAfterError;
4514 } else if (DOT11F_WARNED(nStatus)) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004515 pe_warn("There were warnings while packing SA Query Response (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 nStatus);
4517 }
4518
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004519 pe_debug("Sending a SA Query Response to");
Jeff Johnson99f25042018-11-21 22:49:06 -08004520 lim_print_mac_addr(mac, peer, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004522 if ((BAND_5G == lim_get_rf_band(pe_session->currentOperChannel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523#ifdef WLAN_FEATURE_P2P
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004524 || (pe_session->pePersona == QDF_P2P_CLIENT_MODE) ||
4525 (pe_session->pePersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004526#endif
4527 ) {
4528 txFlag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4529 }
4530
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304531 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004532 pe_session->peSessionId, pMacHdr->fc.subType));
Jeff Johnson99f25042018-11-21 22:49:06 -08004533 qdf_status = wma_tx_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 pPacket,
4535 (uint16_t) nBytes,
4536 TXRX_FRM_802_11_MGMT,
4537 ANI_TXDIR_TODS,
4538 7, lim_tx_complete, pFrame, txFlag,
Naveen Rawat296a5182017-09-25 14:02:48 -07004539 smeSessionId, 0, RATEID_DEFAULT);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304540 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004541 pe_session->peSessionId, qdf_status));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304542 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda7034a8b2017-03-26 19:52:36 -07004543 pe_err("wma_tx_frame FAILED! Status [%d]", qdf_status);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004544 nSirStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 /* Pkt will be freed up by the callback */
4546 return nSirStatus;
4547 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 }
4550
4551returnAfterError:
4552 cds_packet_free((void *)pPacket);
4553 return nSirStatus;
4554} /* End lim_send_sa_query_response_frame */
4555#endif
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004556
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004557#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390)
4558#ifdef WLAN_FEATURE_11AX
4559#define IS_PE_SESSION_11N_MODE(_session) \
4560 ((_session)->htCapability && !(_session)->vhtCapability && \
4561 !(_session)->he_capable)
4562#else
4563#define IS_PE_SESSION_11N_MODE(_session) \
4564 ((_session)->htCapability && !(_session)->vhtCapability)
4565#endif /* WLAN_FEATURE_11AX */
4566#else
4567#define IS_PE_SESSION_11N_MODE(_session) false
4568#endif
4569
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004570/**
4571 * lim_send_addba_response_frame(): Send ADDBA response action frame to peer
4572 * @mac_ctx: mac context
4573 * @peer_mac: Peer MAC address
4574 * @tid: TID for which addba response is being sent
4575 * @session: PE session entry
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004576 * @addba_extn_present: ADDBA extension present flag
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004577 * @amsdu_support: amsdu in ampdu support
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004578 *
4579 * This function is called when ADDBA request is successful. ADDBA response is
4580 * setup by calling addba_response_setup API and frame is then sent out OTA.
4581 *
4582 * Return: QDF_STATUS
4583 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004584QDF_STATUS lim_send_addba_response_frame(struct mac_context *mac_ctx,
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004585 tSirMacAddr peer_mac, uint16_t tid,
Jeff Johnsona7815652018-11-18 22:58:30 -08004586 struct pe_session *session, uint8_t addba_extn_present,
Kiran Kumar Lokereaee823a2018-03-22 15:27:05 -07004587 uint8_t amsdu_support)
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004588{
4589
4590 tDot11faddba_rsp frm;
4591 uint8_t *frame_ptr;
4592 tpSirMacMgmtHdr mgmt_hdr;
4593 uint32_t num_bytes, payload_size, status;
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004594 void *pkt_ptr = NULL;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004595 QDF_STATUS qdf_status;
4596 uint8_t tx_flag = 0;
4597 uint8_t sme_sessionid = 0;
4598 uint16_t buff_size, status_code, batimeout;
4599 uint8_t peer_id, dialog_token;
4600 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4601 void *peer, *pdev;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004602 uint8_t he_frag = 0;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004603
4604 sme_sessionid = session->smeSessionId;
4605
4606 pdev = cds_get_context(QDF_MODULE_ID_TXRX);
4607 if (!pdev) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004608 pe_err("pdev is NULL");
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004609 return QDF_STATUS_E_FAILURE;
4610 }
4611
Mohit Khannac4c22252017-11-20 11:06:33 -08004612 peer = cdp_peer_get_ref_by_addr(soc, pdev, peer_mac, &peer_id,
4613 PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004614 if (!peer) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004615 pe_err("PEER [%pM] not found", peer_mac);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004616 return QDF_STATUS_E_FAILURE;
4617 }
4618
4619 cdp_addba_responsesetup(soc, peer, tid, &dialog_token,
4620 &status_code, &buff_size, &batimeout);
4621
Mohit Khannac4c22252017-11-20 11:06:33 -08004622 cdp_peer_release_ref(soc, peer, PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP);
hangtian127c9532019-01-12 13:29:07 +08004623 qdf_mem_zero((uint8_t *) &frm, sizeof(frm));
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004624 frm.Category.category = SIR_MAC_ACTION_BLKACK;
4625 frm.Action.action = SIR_MAC_ADDBA_RSP;
4626
4627 frm.DialogToken.token = dialog_token;
4628 frm.Status.status = status_code;
Kiran Kumar Lokere08195ef2018-01-17 19:25:15 -08004629 if (mac_ctx->reject_addba_req) {
4630 frm.Status.status = eSIR_MAC_REQ_DECLINED_STATUS;
4631 pe_err("refused addba req");
4632 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004633 frm.addba_param_set.tid = tid;
Kiran Kumar Lokere96180e12018-03-12 17:58:23 -07004634 frm.addba_param_set.buff_size = SIR_MAC_BA_DEFAULT_BUFF_SIZE;
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004635 if (mac_ctx->usr_cfg_ba_buff_size)
4636 frm.addba_param_set.buff_size = mac_ctx->usr_cfg_ba_buff_size;
Kiran Kumar Lokereeac7fe92018-07-24 16:56:01 -07004637
4638 if (frm.addba_param_set.buff_size > MAX_BA_BUFF_SIZE)
4639 frm.addba_param_set.buff_size = MAX_BA_BUFF_SIZE;
4640
4641 if (frm.addba_param_set.buff_size > SIR_MAC_BA_DEFAULT_BUFF_SIZE) {
4642 if (session->active_ba_64_session) {
4643 frm.addba_param_set.buff_size =
4644 SIR_MAC_BA_DEFAULT_BUFF_SIZE;
4645 }
4646 } else if (!session->active_ba_64_session) {
4647 session->active_ba_64_session = true;
4648 }
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004649
4650 /* disable 11n RX AMSDU */
4651 if (mac_ctx->is_usr_cfg_amsdu_enabled &&
4652 !IS_PE_SESSION_11N_MODE(session))
Arif Hussain0e246802018-05-01 18:13:44 -07004653 frm.addba_param_set.amsdu_supp = amsdu_support;
4654 else
4655 frm.addba_param_set.amsdu_supp = 0;
Jinwei Chen332b5cf2019-03-05 13:26:17 +08004656
Kiran Kumar Lokerebc87bec2018-02-27 20:06:42 -08004657 frm.addba_param_set.policy = SIR_MAC_BA_POLICY_IMMEDIATE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004658 frm.ba_timeout.timeout = batimeout;
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004659 if (addba_extn_present) {
4660 frm.addba_extn_element.present = 1;
4661 frm.addba_extn_element.no_fragmentation = 1;
4662 if (lim_is_session_he_capable(session)) {
4663 he_frag = lim_get_session_he_frag_cap(session);
4664 if (he_frag != 0) {
4665 frm.addba_extn_element.no_fragmentation = 0;
4666 frm.addba_extn_element.he_frag_operation =
4667 he_frag;
4668 }
4669 }
4670 }
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004671
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004672 pe_debug("Sending a ADDBA Response from %pM to %pM",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004673 session->selfMacAddr, peer_mac);
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004674 pe_debug("tid: %d, dialog_token: %d, status: %d, buff_size: %d",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004675 tid, frm.DialogToken.token, frm.Status.status,
4676 frm.addba_param_set.buff_size);
Kiran Kumar Lokere40875852018-01-15 12:36:19 -08004677 pe_debug("addba_extn %d he_capable %d no_frag %d he_frag %d",
4678 addba_extn_present,
4679 lim_is_session_he_capable(session),
4680 frm.addba_extn_element.no_fragmentation,
4681 frm.addba_extn_element.he_frag_operation);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004682
4683 status = dot11f_get_packed_addba_rsp_size(mac_ctx, &frm, &payload_size);
4684 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004685 pe_err("Failed to calculate the packed size for a ADDBA Response (0x%08x).",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004686 status);
4687 /* We'll fall back on the worst case scenario: */
4688 payload_size = sizeof(tDot11faddba_rsp);
4689 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004690 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 -08004691 }
4692
4693 num_bytes = payload_size + sizeof(*mgmt_hdr);
4694 qdf_status = cds_packet_alloc(num_bytes, (void **)&frame_ptr,
4695 (void **)&pkt_ptr);
Sandeep Puligilla39cec082018-04-30 15:18:45 -07004696 if (!QDF_IS_STATUS_SUCCESS(qdf_status) || (!pkt_ptr)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004697 pe_err("Failed to allocate %d bytes for a ADDBA response action frame",
4698 num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004699 return QDF_STATUS_E_FAILURE;
4700 }
hangtian127c9532019-01-12 13:29:07 +08004701 qdf_mem_zero(frame_ptr, num_bytes);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004702
4703 lim_populate_mac_header(mac_ctx, frame_ptr, SIR_MAC_MGMT_FRAME,
4704 SIR_MAC_MGMT_ACTION, peer_mac, session->selfMacAddr);
4705
4706 /* Update A3 with the BSSID */
4707 mgmt_hdr = (tpSirMacMgmtHdr) frame_ptr;
4708 sir_copy_mac_addr(mgmt_hdr->bssId, session->bssId);
4709
4710 /* ADDBA Response is a robust mgmt action frame,
4711 * set the "protect" (aka WEP) bit in the FC
4712 */
4713 lim_set_protected_bit(mac_ctx, session, peer_mac, mgmt_hdr);
4714
4715 status = dot11f_pack_addba_rsp(mac_ctx, &frm,
4716 frame_ptr + sizeof(tSirMacMgmtHdr), payload_size,
4717 &payload_size);
4718
4719 if (DOT11F_FAILED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004720 pe_err("Failed to pack a ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004721 status);
4722 qdf_status = QDF_STATUS_E_FAILURE;
4723 goto error_addba_rsp;
4724 } else if (DOT11F_WARNED(status)) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004725 pe_warn("There were warnings while packing ADDBA Response (0x%08x)",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004726 status);
4727 }
4728
4729
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004730 if ((BAND_5G == lim_get_rf_band(session->currentOperChannel))
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004731#ifdef WLAN_FEATURE_P2P
4732 || (session->pePersona == QDF_P2P_CLIENT_MODE) ||
4733 (session->pePersona == QDF_P2P_GO_MODE)
4734#endif
4735 ) {
4736 tx_flag |= HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME;
4737 }
4738
4739 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
4740 session->peSessionId, mgmt_hdr->fc.subType));
Krunal Sonid2136c72018-06-01 17:26:39 -07004741 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, pkt_ptr,
4742 (uint16_t)num_bytes,
4743 TXRX_FRM_802_11_MGMT,
4744 ANI_TXDIR_TODS, 7,
4745 NULL, frame_ptr,
4746 lim_addba_rsp_tx_complete_cnf,
4747 tx_flag, sme_sessionid,
4748 false, 0, RATEID_DEFAULT);
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004749 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4750 session->peSessionId, qdf_status));
4751 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07004752 pe_err("wma_tx_frame FAILED! Status [%d]",
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004753 qdf_status);
chenguo90c68462019-01-24 18:27:01 +08004754 return QDF_STATUS_E_FAILURE;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004755 } else {
Tushnim Bhattacharyyad58e4c92018-03-27 13:40:12 -07004756 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajan48a6b4c2017-01-06 16:30:55 -08004757 }
4758
4759error_addba_rsp:
4760 cds_packet_free((void *)pkt_ptr);
4761 return qdf_status;
4762}
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304763
4764/**
4765 * lim_tx_mgmt_frame() - Transmits Auth mgmt frame
4766 * @mac_ctx Pointer to Global MAC structure
4767 * @mb_msg: Received message info
4768 * @msg_len: Received message length
4769 * @packet: Packet to be transmitted
4770 * @frame: Received frame
4771 *
4772 * Return: None
4773 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004774static void lim_tx_mgmt_frame(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304775 struct sir_mgmt_msg *mb_msg, uint32_t msg_len,
4776 void *packet, uint8_t *frame)
4777{
4778 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4779 QDF_STATUS qdf_status;
4780 uint8_t sme_session_id = 0;
Jeff Johnsona7815652018-11-18 22:58:30 -08004781 struct pe_session *session;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304782 uint16_t auth_ack_status;
4783 enum rateid min_rid = RATEID_DEFAULT;
4784
4785 sme_session_id = mb_msg->session_id;
4786 session = pe_find_session_by_sme_session_id(mac_ctx, sme_session_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07004787 if (!session) {
Wu Gao7c0a23f2019-03-12 14:16:37 +08004788 cds_packet_free((void *)packet);
4789 pe_err("session not found for given sme session %d",
4790 sme_session_id);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304791 return;
4792 }
4793
Ashish Kumar Dhanotiya9f72df02018-07-23 19:20:04 +05304794 qdf_mtrace(QDF_MODULE_ID_PE, QDF_MODULE_ID_WMA, TRACE_CODE_TX_MGMT,
4795 session->peSessionId, 0);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304796
4797 mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
4798 min_rid = lim_get_min_session_txrate(session);
4799
4800 qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
4801 (uint16_t)msg_len,
4802 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
4803 7, lim_tx_complete, frame,
4804 lim_auth_tx_complete_cnf,
4805 0, sme_session_id, false, 0, min_rid);
4806 MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_COMPLETE,
4807 session->peSessionId, qdf_status));
4808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Rachit Kankane0baf6e72018-01-19 15:01:50 +05304809 pe_err("*** Could not send Auth frame (subType: %d), retCode=%X ***",
4810 fc->subType, qdf_status);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304811 mac_ctx->auth_ack_status = LIM_AUTH_ACK_RCD_FAILURE;
4812 auth_ack_status = SENT_FAIL;
4813 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_AUTH_ACK_EVENT,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004814 session, auth_ack_status, QDF_STATUS_E_FAILURE);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304815 /* Pkt will be freed up by the callback */
4816 }
4817}
4818
Jeff Johnson9320c1e2018-12-02 13:09:20 -08004819void lim_send_mgmt_frame_tx(struct mac_context *mac_ctx,
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304820 struct scheduler_msg *msg)
4821{
4822 struct sir_mgmt_msg *mb_msg = (struct sir_mgmt_msg *)msg->bodyptr;
4823 uint32_t msg_len;
4824 tpSirMacFrameCtl fc = (tpSirMacFrameCtl) mb_msg->data;
4825 uint8_t sme_session_id;
4826 QDF_STATUS qdf_status;
4827 uint8_t *frame;
4828 void *packet;
Srinivas Dasari76218492019-01-22 15:08:20 +05304829 tpSirMacMgmtHdr mac_hdr;
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304830
4831 msg_len = mb_msg->msg_len - sizeof(*mb_msg);
4832 pe_debug("sending fc->type: %d fc->subType: %d",
4833 fc->type, fc->subType);
4834
4835 sme_session_id = mb_msg->session_id;
Srinivas Dasari76218492019-01-22 15:08:20 +05304836 mac_hdr = (tpSirMacMgmtHdr)mb_msg->data;
4837
4838 lim_add_mgmt_seq_num(mac_ctx, mac_hdr);
Padma, Santhosh Kumar22c462c2018-01-16 17:56:44 +05304839
4840 qdf_status = cds_packet_alloc((uint16_t) msg_len, (void **)&frame,
4841 (void **)&packet);
4842 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
4843 pe_err("call to bufAlloc failed for AUTH frame");
4844 return;
4845 }
4846
4847 qdf_mem_copy(frame, mb_msg->data, msg_len);
4848
4849 lim_tx_mgmt_frame(mac_ctx, mb_msg, msg_len, packet, frame);
4850}