blob: 87b9ba030b6a637b815b4e2e1922ee5088ee64c6 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Naveen Rawatada5fac2016-01-28 16:24:32 -080020 * This file lim_process_assoc_req_frame.c contains the code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021 * for processing Re/Association Request Frame.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080022 */
23#include "cds_api.h"
24#include "ani_global.h"
25#include "wni_cfg.h"
26#include "sir_api.h"
27#include "cfg_api.h"
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +053028#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080029
30#include "sch_api.h"
31#include "utils_api.h"
32#include "lim_types.h"
33#include "lim_utils.h"
34#include "lim_assoc_utils.h"
35#include "lim_security_utils.h"
36#include "lim_ser_des_utils.h"
37#include "lim_sta_hash_api.h"
38#include "lim_admit_control.h"
39#include "cds_packet.h"
40#include "lim_session_utils.h"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070041#include "utils_parser.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042
Anurag Chouhan6d760662016-02-20 16:05:43 +053043#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "cds_utils.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070045#include "wlan_utility.h"
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -070046#include "wlan_crypto_global_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047
48/**
49 * lim_convert_supported_channels - Parses channel support IE
Krunal Soni99752a12016-04-12 17:44:45 -070050 * @mac_ctx: A pointer to Global MAC structure
51 * @assoc_ind: A pointer to SME ASSOC/REASSOC IND
52 * @assoc_req: A pointer to ASSOC/REASSOC Request frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053 *
54 * This function is called by lim_process_assoc_req_frame() to
55 * parse the channel support IE in the Assoc/Reassoc Request
56 * frame, and send relevant information in the SME_ASSOC_IND
57 *
Krunal Soni99752a12016-04-12 17:44:45 -070058 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -080060static void lim_convert_supported_channels(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -070061 tpLimMlmAssocInd assoc_ind,
62 tSirAssocReq *assoc_req)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063{
64 uint16_t i, j, index = 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -080065 uint8_t first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 uint8_t chn_count;
Naveen Rawatada5fac2016-01-28 16:24:32 -080067 uint8_t next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 uint8_t channel_offset = 0;
69
70 if (assoc_req->supportedChannels.length >=
71 SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053072 pe_err("Number of supported channels: %d is more than MAX",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 assoc_req->supportedChannels.length);
74 assoc_ind->supportedChannels.numChnl = 0;
75 return;
76 }
77
78 for (i = 0; i < (assoc_req->supportedChannels.length); i++) {
79 /* Get First Channel Number */
Naveen Rawatada5fac2016-01-28 16:24:32 -080080 first_ch_no = assoc_req->supportedChannels.supportedChannels[i];
81 assoc_ind->supportedChannels.channelList[index] = first_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 i++;
83 index++;
84
85 /* Get Number of Channels in a Subband */
Naveen Rawatada5fac2016-01-28 16:24:32 -080086 chn_count = assoc_req->supportedChannels.supportedChannels[i];
Nishank Aggarwal8935e442017-03-23 19:11:08 +053087 pe_debug("Rcv assoc_req: chnl: %d numOfChnl: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -080088 first_ch_no, chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +053090 pe_warn("Ch count > max supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 assoc_ind->supportedChannels.numChnl = 0;
92 return;
93 }
94 if (chn_count <= 1)
95 continue;
Naveen Rawatada5fac2016-01-28 16:24:32 -080096 next_ch_no = first_ch_no;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080097 if (BAND_5G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 channel_offset = SIR_11A_FREQUENCY_OFFSET;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080099 else if (BAND_2G == lim_get_rf_band(first_ch_no))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 channel_offset = SIR_11B_FREQUENCY_OFFSET;
101 else
102 continue;
103
104 for (j = 1; j < chn_count; j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800105 next_ch_no += channel_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106 assoc_ind->supportedChannels.channelList[index]
Naveen Rawatada5fac2016-01-28 16:24:32 -0800107 = next_ch_no;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108 index++;
109 if (index >= SIR_MAX_SUPPORTED_CHANNEL_LIST) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530110 pe_warn("Ch count > supported: %d", chn_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 assoc_ind->supportedChannels.numChnl = 0;
112 return;
113 }
114 }
115 }
116
117 assoc_ind->supportedChannels.numChnl = (uint8_t) index;
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530118 pe_debug("Send AssocInd to WSM: minPwr: %d maxPwr: %d numChnl: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 assoc_ind->powerCap.minTxPower,
120 assoc_ind->powerCap.maxTxPower,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800121 assoc_ind->supportedChannels.numChnl);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122}
123
Naveen Rawatada5fac2016-01-28 16:24:32 -0800124/**
125 * lim_check_sta_in_pe_entries() - checks if sta exists in any dph tables.
Krunal Soni99752a12016-04-12 17:44:45 -0700126 * @mac_ctx: Pointer to Global MAC structure
127 * @hdr: A pointer to the MAC header
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530128 * @sessionid - session id for which session is initiated
Naveen Rawatada5fac2016-01-28 16:24:32 -0800129 *
130 * This function is called by lim_process_assoc_req_frame() to check if STA
131 * entry already exists in any of the PE entries of the AP. If it exists, deauth
132 * will be sent on that session and the STA deletion will happen. After this,
133 * the ASSOC request will be processed
134 *
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700135 * Return: True if duplicate entry found; FALSE otherwise.
Naveen Rawatada5fac2016-01-28 16:24:32 -0800136 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800137static bool lim_check_sta_in_pe_entries(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530138 uint16_t sessionid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139{
140 uint8_t i;
Naveen Rawatada5fac2016-01-28 16:24:32 -0800141 uint16_t assoc_id = 0;
142 tpDphHashNode sta_ds = NULL;
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800143 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700144 bool dup_entry = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145
Naveen Rawatada5fac2016-01-28 16:24:32 -0800146 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
147 if ((&mac_ctx->lim.gpSession[i] != NULL) &&
148 (mac_ctx->lim.gpSession[i].valid) &&
149 (mac_ctx->lim.gpSession[i].pePersona == QDF_SAP_MODE)) {
150 session = &mac_ctx->lim.gpSession[i];
151 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa,
152 &assoc_id, &session->dph.dphHashTable);
153 if (sta_ds
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154#ifdef WLAN_FEATURE_11W
Poddar, Siddarth7ca1e082016-08-09 19:06:48 +0530155 && (!sta_ds->rmfEnabled ||
156 (sessionid != session->peSessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157#endif
158 ) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530159 pe_err("Sending Disassoc and Deleting existing STA entry:"
160 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800161 MAC_ADDR_ARRAY(session->selfMacAddr));
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700162 lim_send_disassoc_mgmt_frame(mac_ctx,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800163 eSIR_MAC_UNSPEC_FAILURE_REASON,
164 (uint8_t *) hdr->sa, session, false);
Sandeep Puligilla2eeaf6a2016-07-22 20:02:02 -0700165 /*
166 * Cleanup Rx path posts eWNI_SME_DISASSOC_RSP
167 * msg to SME after delete sta which will update
168 * the userspace with disconnect
169 */
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700170 sta_ds->mlmStaContext.cleanupTrigger =
171 eLIM_DUPLICATE_ENTRY;
172 sta_ds->mlmStaContext.disassocReason =
173 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON;
174 lim_send_sme_disassoc_ind(mac_ctx, sta_ds,
175 session);
176 dup_entry = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 break;
178 }
179 }
180 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700181 return dup_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182}
183
Naveen Rawatada5fac2016-01-28 16:24:32 -0800184/**
Krunal Soni99752a12016-04-12 17:44:45 -0700185 * lim_chk_sa_da() - checks source addr to destination addr of assoc req frame
186 * @mac_ctx: pointer to Global MAC structure
187 * @hdr: pointer to the MAC head
188 * @session: pointer to pe session entry
189 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
Naveen Rawatada5fac2016-01-28 16:24:32 -0800190 *
Krunal Soni99752a12016-04-12 17:44:45 -0700191 * Checks source addr to destination addr of assoc req frame
Naveen Rawatada5fac2016-01-28 16:24:32 -0800192 *
Ankit Guptaa5076012016-09-14 11:32:19 -0700193 * Return: true if source and destination address are different
Naveen Rawatada5fac2016-01-28 16:24:32 -0800194 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800195static bool lim_chk_sa_da(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800196 struct pe_session *session, uint8_t sub_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197{
Ankit Guptaa5076012016-09-14 11:32:19 -0700198 if (qdf_mem_cmp((uint8_t *) hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -0700199 (uint8_t *) hdr->da,
Ankit Guptaa5076012016-09-14 11:32:19 -0700200 (uint8_t) (sizeof(tSirMacAddr))))
Krunal Soni99752a12016-04-12 17:44:45 -0700201 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530203 pe_err("Assoc Req rejected: wlan.sa = wlan.da");
Krunal Soni99752a12016-04-12 17:44:45 -0700204 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
205 1, hdr->sa, sub_type, 0, session);
206 return false;
207}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208
Krunal Soni99752a12016-04-12 17:44:45 -0700209/**
210 * lim_chk_tkip() - checks TKIP counter measure is active
211 * @mac_ctx: pointer to Global MAC structure
212 * @hdr: pointer to the MAC head
213 * @session: pointer to pe session entry
214 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
215 *
216 * Checks TKIP counter measure is active
217 *
218 * Return: true of no error, false otherwise
219 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800220static bool lim_chk_tkip(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800221 struct pe_session *session, uint8_t sub_type)
Krunal Soni99752a12016-04-12 17:44:45 -0700222{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 /*
Krunal Soni99752a12016-04-12 17:44:45 -0700224 * If TKIP counter measures active send Assoc Rsp frame to station
225 * with eSIR_MAC_MIC_FAILURE_REASON
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 */
Krunal Soni99752a12016-04-12 17:44:45 -0700227 if (!(session->bTkipCntrMeasActive && LIM_IS_AP_ROLE(session)))
228 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530230 pe_err("Assoc Req rejected: TKIP counter measure is active");
Krunal Soni99752a12016-04-12 17:44:45 -0700231 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_MIC_FAILURE_REASON, 1,
232 hdr->sa, sub_type, 0, session);
233 return false;
234}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235
Krunal Soni99752a12016-04-12 17:44:45 -0700236/**
237 * lim_chk_assoc_req_parse_error() - checks for error in frame parsing
238 * @mac_ctx: pointer to Global MAC structure
239 * @hdr: pointer to the MAC head
240 * @session: pointer to pe session entry
241 * @assoc_req: pointer to ASSOC/REASSOC Request frame
242 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
243 * @frm_body: frame body
244 * @frame_len: frame len
245 *
246 * Checks for error in frame parsing
247 *
248 * Return: true of no error, false otherwise
249 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800250static bool lim_chk_assoc_req_parse_error(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700251 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800252 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700253 tpSirAssocReq assoc_req,
254 uint8_t sub_type, uint8_t *frm_body,
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -0800255 uint32_t frame_len)
Krunal Soni99752a12016-04-12 17:44:45 -0700256{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700257 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258
Naveen Rawatada5fac2016-01-28 16:24:32 -0800259 if (sub_type == LIM_ASSOC)
Krunal Soni99752a12016-04-12 17:44:45 -0700260 status = sir_convert_assoc_req_frame2_struct(mac_ctx, frm_body,
261 frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 else
Krunal Soni99752a12016-04-12 17:44:45 -0700263 status = sir_convert_reassoc_req_frame2_struct(mac_ctx,
264 frm_body, frame_len, assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700266 if (status == QDF_STATUS_SUCCESS)
Krunal Soni99752a12016-04-12 17:44:45 -0700267 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530269 pe_warn("Assoc Req rejected: frame parsing error. source addr:"
270 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700271 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
272 1, hdr->sa, sub_type, 0, session);
273 return false;
274}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275
Krunal Soni99752a12016-04-12 17:44:45 -0700276/**
277 * lim_chk_capab() - checks for capab match
278 * @mac_ctx: pointer to Global MAC structure
279 * @hdr: pointer to the MAC head
280 * @session: pointer to pe session entry
281 * @assoc_req: pointer to ASSOC/REASSOC Request frame
282 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
283 * @local_cap: local capabilities of SAP
284 *
285 * Checks for capab match
286 *
287 * Return: true of no error, false otherwise
288 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800289static bool lim_chk_capab(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800290 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700291 uint8_t sub_type, tSirMacCapabilityInfo *local_cap)
292{
293 uint16_t temp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700295 if (cfg_get_capability_info(mac_ctx, &temp, session) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530296 pe_err("could not retrieve Capabilities");
Krunal Soni99752a12016-04-12 17:44:45 -0700297 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298 }
Krunal Soni99752a12016-04-12 17:44:45 -0700299
300 lim_copy_u16((uint8_t *) local_cap, temp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301
Naveen Rawatada5fac2016-01-28 16:24:32 -0800302 if (lim_compare_capabilities(mac_ctx, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700303 local_cap, session) == false) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530304 pe_warn("Rcvd %s Req with unsupported capab from"
305 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800306 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
307 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700308 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 * Capabilities of requesting STA does not match with
310 * local capabilities. Respond with 'unsupported capabilities'
311 * status code.
312 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800313 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700314 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
315 1, hdr->sa, sub_type, 0, session);
316 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 }
Krunal Soni99752a12016-04-12 17:44:45 -0700318 return true;
319}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320
Krunal Soni99752a12016-04-12 17:44:45 -0700321/**
322 * lim_chk_ssid() - checks for SSID match
323 * @mac_ctx: pointer to Global MAC structure
324 * @hdr: pointer to the MAC head
325 * @session: pointer to pe session entry
326 * @assoc_req: pointer to ASSOC/REASSOC Request frame
327 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
328 *
329 * Checks for SSID match
330 *
331 * Return: true of no error, false otherwise
332 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800333static bool lim_chk_ssid(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800334 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700335 uint8_t sub_type)
336{
337 if (lim_cmp_ssid(&assoc_req->ssId, session) != true)
338 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530340 pe_err("%s Req with ssid wrong(Rcvd: %.*s self: %.*s) from "
341 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700342 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
343 assoc_req->ssId.length, assoc_req->ssId.ssId,
344 session->ssId.length, session->ssId.ssId,
345 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346
Krunal Soni99752a12016-04-12 17:44:45 -0700347 /*
348 * Received Re/Association Request with either Broadcast SSID OR with
349 * SSID that does not match with local one. Respond with unspecified
350 * status code.
351 */
352 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_MAC_UNSPEC_FAILURE_STATUS,
353 1, hdr->sa, sub_type, 0, session);
354 return false;
355}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356
Krunal Soni99752a12016-04-12 17:44:45 -0700357/**
358 * lim_chk_rates() - checks for supported rates
359 * @mac_ctx: pointer to Global MAC structure
360 * @hdr: pointer to the MAC head
361 * @session: pointer to pe session entry
362 * @assoc_req: pointer to ASSOC/REASSOC Request frame
363 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
364 *
365 * Checks for supported rates
366 *
367 * Return: true of no error, false otherwise
368 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800369static bool lim_chk_rates(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800370 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700371 uint8_t sub_type)
372{
373 uint8_t i = 0, j = 0;
374 tSirMacRateSet basic_rates;
375 /*
376 * Verify if the requested rates are available in supported rate
377 * set or Extended rate set. Some APs are adding basic rates in
378 * Extended rateset IE
379 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800380 basic_rates.numRates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381
Krunal Soni99752a12016-04-12 17:44:45 -0700382 for (i = 0; i < assoc_req->supportedRates.numRates
383 && (i < SIR_MAC_RATESET_EID_MAX); i++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800384 basic_rates.rate[i] = assoc_req->supportedRates.rate[i];
385 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 }
387
Krunal Soni99752a12016-04-12 17:44:45 -0700388 for (j = 0; (j < assoc_req->extendedRates.numRates)
389 && (i < SIR_MAC_RATESET_EID_MAX); i++, j++) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800390 basic_rates.rate[i] = assoc_req->extendedRates.rate[j];
391 basic_rates.numRates++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393
Krunal Soni99752a12016-04-12 17:44:45 -0700394 if (lim_check_rx_basic_rates(mac_ctx, basic_rates, session) == true)
395 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530397 pe_warn("Assoc Req rejected: unsupported rates, soruce addr: %s"
398 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700399 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
400 MAC_ADDR_ARRAY(hdr->sa));
401 /*
402 * Requesting STA does not support ALL BSS basic rates. Respond with
403 * 'basic rates not supported' status code.
404 */
405 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
406 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS, 1,
407 hdr->sa, sub_type, 0, session);
408 return false;
409}
410
411/**
412 * lim_chk_11g_only() - checks for non 11g STA
413 * @mac_ctx: pointer to Global MAC structure
414 * @hdr: pointer to the MAC head
415 * @session: pointer to pe session entry
416 * @assoc_req: pointer to ASSOC/REASSOC Request frame
417 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
418 *
419 * Checks for non 11g STA
420 *
421 * Return: true of no error, false otherwise
422 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800423static bool lim_chk_11g_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800424 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700425 uint8_t sub_type)
426{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800427 if (LIM_IS_AP_ROLE(session) &&
428 (session->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY) &&
429 (assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530430 pe_err("SOFTAP was in 11G only mode, rejecting legacy STA: "
431 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700432 MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800433 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700434 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
435 1, hdr->sa, sub_type, 0, session);
436 return false;
437 }
438 return true;
439}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440
Krunal Soni99752a12016-04-12 17:44:45 -0700441/**
442 * lim_chk_11n_only() - checks for non 11n STA
443 * @mac_ctx: pointer to Global MAC structure
444 * @hdr: pointer to the MAC head
445 * @session: pointer to pe session entry
446 * @assoc_req: pointer to ASSOC/REASSOC Request frame
447 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
448 *
449 * Checks for non 11n STA
450 *
451 * Return: true of no error, false otherwise
452 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800453static bool lim_chk_11n_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800454 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700455 uint8_t sub_type)
456{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800457 if (LIM_IS_AP_ROLE(session) &&
458 (session->dot11mode == WNI_CFG_DOT11_MODE_11N_ONLY) &&
459 (!assoc_req->HTCaps.present)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530460 pe_err("SOFTAP was in 11N only mode, rejecting legacy STA: "
461 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700462 MAC_ADDR_ARRAY(hdr->sa));
Naveen Rawatada5fac2016-01-28 16:24:32 -0800463 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700464 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
465 1, hdr->sa, sub_type, 0, session);
466 return false;
467 }
468 return true;
469}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470
Krunal Soni99752a12016-04-12 17:44:45 -0700471/**
472 * lim_chk_11ac_only() - checks for non 11ac STA
473 * @mac_ctx: pointer to Global MAC structure
474 * @hdr: pointer to the MAC head
475 * @session: pointer to pe session entry
476 * @assoc_req: pointer to ASSOC/REASSOC Request frame
477 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
478 *
479 * Checks for non 11ac STA
480 *
481 * Return: true of no error, false otherwise
482 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800483static bool lim_chk_11ac_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800484 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700485 uint8_t sub_type)
486{
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530487 tDot11fIEVHTCaps *vht_caps;
488
489 if (assoc_req->VHTCaps.present)
490 vht_caps = &assoc_req->VHTCaps;
491 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
492 session->vendor_vht_sap)
493 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
494 else
495 vht_caps = NULL;
496
Naveen Rawatada5fac2016-01-28 16:24:32 -0800497 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -0700498 (session->dot11mode == WNI_CFG_DOT11_MODE_11AC_ONLY) &&
wadesong3e727f62016-11-07 17:51:57 +0800499 ((vht_caps == NULL) || ((vht_caps != NULL) && (!vht_caps->present)))) {
Naveen Rawatada5fac2016-01-28 16:24:32 -0800500 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700501 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
502 1, hdr->sa, sub_type, 0, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530503 pe_err("SOFTAP was in 11AC only mode, reject");
Krunal Soni99752a12016-04-12 17:44:45 -0700504 return false;
505 }
506 return true;
507}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508
Krunal Soni99752a12016-04-12 17:44:45 -0700509/**
Naveen Rawat441bc872017-12-11 17:25:27 -0800510 * lim_chk_11ax_only() - checks for non 11ax STA
511 * @mac_ctx: pointer to Global MAC structure
512 * @hdr: pointer to the MAC head
513 * @session: pointer to pe session entry
514 * @assoc_req: pointer to ASSOC/REASSOC Request frame
515 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
516 *
517 * Checks for non 11ax STA
518 *
519 * Return: true of no error, false otherwise
520 */
521#ifdef WLAN_FEATURE_11AX
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800522static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800523 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800524 uint8_t sub_type)
525{
526 if (LIM_IS_AP_ROLE(session) &&
527 (session->dot11mode == WNI_CFG_DOT11_MODE_11AX_ONLY) &&
528 !assoc_req->he_cap.present) {
529 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
530 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
531 1, hdr->sa, sub_type, 0, session);
532 pe_err("SOFTAP was in 11AX only mode, reject");
533 return false;
534 }
535 return true;
536}
537
538/**
539 * lim_check_11ax_basic_mcs() - checks for 11ax basic MCS rates
540 * @mac_ctx: pointer to Global MAC structure
541 * @hdr: pointer to the MAC head
542 * @session: pointer to pe session entry
543 * @assoc_req: pointer to ASSOC/REASSOC Request frame
544 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
545 *
546 * Checks for non 11ax STA
547 *
548 * Return: true of no error, false otherwise
549 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800550static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800551 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800552 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800553 tpSirAssocReq assoc_req,
554 uint8_t sub_type)
555{
Naveen Rawat441bc872017-12-11 17:25:27 -0800556 uint16_t basic_mcs, sta_mcs, rx_mcs, tx_mcs, final_mcs;
557
558 if (LIM_IS_AP_ROLE(session) &&
559 assoc_req->he_cap.present) {
560 rx_mcs = assoc_req->he_cap.rx_he_mcs_map_lt_80;
561 tx_mcs = assoc_req->he_cap.tx_he_mcs_map_lt_80;
562 sta_mcs = HE_INTERSECT_MCS(rx_mcs, tx_mcs);
Bala Venkatesh6d537092018-09-25 10:38:36 +0530563 basic_mcs =
564 (uint16_t)mac_ctx->mlme_cfg->he_caps.he_ops_basic_mcs_nss;
Naveen Rawat441bc872017-12-11 17:25:27 -0800565 final_mcs = HE_INTERSECT_MCS(sta_mcs, basic_mcs);
566 if (final_mcs != basic_mcs) {
567 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
568 eSIR_MAC_CAPABILITIES_NOT_SUPPORTED_STATUS,
569 1, hdr->sa, sub_type, 0, session);
Jeff Johnsona642ead2018-05-11 09:26:13 -0700570 pe_err("STA did not support basic MCS required by SAP");
Naveen Rawat441bc872017-12-11 17:25:27 -0800571 return false;
572 }
573 }
574 return true;
575}
Bala Venkatesh6d537092018-09-25 10:38:36 +0530576
Naveen Rawat441bc872017-12-11 17:25:27 -0800577#else
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800578static bool lim_chk_11ax_only(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800579 struct pe_session *session, tpSirAssocReq assoc_req,
Naveen Rawat441bc872017-12-11 17:25:27 -0800580 uint8_t sub_type)
581{
582 return true;
583}
584
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800585static bool lim_check_11ax_basic_mcs(struct mac_context *mac_ctx,
Naveen Rawat441bc872017-12-11 17:25:27 -0800586 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800587 struct pe_session *session,
Naveen Rawat441bc872017-12-11 17:25:27 -0800588 tpSirAssocReq assoc_req,
589 uint8_t sub_type)
590{
591 return true;
592}
593#endif
594
595/**
Krunal Soni99752a12016-04-12 17:44:45 -0700596 * lim_process_for_spectrum_mgmt() - process assoc req for spectrum mgmt
597 * @mac_ctx: pointer to Global MAC structure
598 * @hdr: pointer to the MAC head
599 * @session: pointer to pe session entry
600 * @assoc_req: pointer to ASSOC/REASSOC Request frame
601 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
602 * @local_cap: local capabilities of SAP
603 *
604 * Checks for SSID match
605 *
606 * process assoc req for spectrum mgmt
607 */
608static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800609lim_process_for_spectrum_mgmt(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800610 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700611 uint8_t sub_type, tSirMacCapabilityInfo local_cap)
612{
Naveen Rawatada5fac2016-01-28 16:24:32 -0800613 if (local_cap.spectrumMgt) {
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700614 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krunal Soni99752a12016-04-12 17:44:45 -0700615 /*
616 * If station is 11h capable, then it SHOULD send all mandatory
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 * IEs in assoc request frame. Let us verify that
618 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800619 if (assoc_req->capabilityInfo.spectrumMgt) {
Krunal Soni99752a12016-04-12 17:44:45 -0700620 if (!((assoc_req->powerCapabilityPresent)
Naveen Rawatada5fac2016-01-28 16:24:32 -0800621 && (assoc_req->supportedChannelsPresent))) {
Krunal Soni99752a12016-04-12 17:44:45 -0700622 /*
623 * One or more required information elements are
624 * missing, log the peers error
625 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800626 if (!assoc_req->powerCapabilityPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530627 pe_warn("LIM Info: Missing Power capability IE in %s Req from "
628 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700629 (LIM_ASSOC == sub_type) ?
630 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800631 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 }
Naveen Rawatada5fac2016-01-28 16:24:32 -0800633 if (!assoc_req->supportedChannelsPresent) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530634 pe_warn("LIM Info: Missing Supported channel IE in %s Req from "
635 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700636 (LIM_ASSOC == sub_type) ?
637 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800638 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 }
640 } else {
641 /* Assoc request has mandatory fields */
642 status =
Krunal Soni99752a12016-04-12 17:44:45 -0700643 lim_is_dot11h_power_capabilities_in_range(
644 mac_ctx, assoc_req, session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700645 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530646 pe_warn("LIM Info: MinTxPower(STA) > MaxTxPower(AP) in %s Req from "
647 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700648 (LIM_ASSOC == sub_type) ?
649 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800650 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 }
Krunal Soni99752a12016-04-12 17:44:45 -0700652 status = lim_is_dot11h_supported_channels_valid(
653 mac_ctx, assoc_req);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700654 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530655 pe_warn("LIM Info: wrong supported channels (STA) in %s Req from "
656 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -0700657 (LIM_ASSOC == sub_type) ?
658 "Assoc" : "ReAssoc",
Naveen Rawatada5fac2016-01-28 16:24:32 -0800659 MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 }
661 /* IEs are valid, use them if needed */
662 }
663 } /* if(assoc.capabilityInfo.spectrumMgt) */
664 else {
Krunal Soni99752a12016-04-12 17:44:45 -0700665 /*
666 * As per the capabiities, the spectrum management is
667 * not enabled on the station. The AP may allow the
668 * associations to happen even if spectrum management
669 * is not allowed, if the transmit power of station is
670 * below the regulatory maximum
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 */
672
Krunal Soni99752a12016-04-12 17:44:45 -0700673 /*
674 * TODO: presently, this is not handled. In the current
Jeff Johnson47d75242018-05-12 15:58:53 -0700675 * implementation, the AP would allow the station to
Krunal Soni99752a12016-04-12 17:44:45 -0700676 * associate even if it doesn't support spectrum
677 * management.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 */
679 }
680 } /* end of spectrum management related processing */
Krunal Soni99752a12016-04-12 17:44:45 -0700681}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682
Krunal Soni99752a12016-04-12 17:44:45 -0700683/**
684 * lim_chk_mcs() - checks for supported MCS
685 * @mac_ctx: pointer to Global MAC structure
686 * @hdr: pointer to the MAC head
687 * @session: pointer to pe session entry
688 * @assoc_req: pointer to ASSOC/REASSOC Request frame
689 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
690 *
691 * Checks for supported MCS
692 *
693 * Return: true of no error, false otherwise
694 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800695static bool lim_chk_mcs(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800696 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -0700697 uint8_t sub_type)
698{
699 if ((assoc_req->HTCaps.present) && (lim_check_mcs_set(mac_ctx,
700 assoc_req->HTCaps.supportedMCSSet) == false)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530701 pe_warn("rcvd %s req with unsupported MCS Rate Set from "
702 MAC_ADDRESS_STR,
Naveen Rawatada5fac2016-01-28 16:24:32 -0800703 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
704 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -0700705 /*
706 * Requesting STA does not support ALL BSS MCS basic Rate set
707 * rates. Spec does not define any status code for this
708 * scenario.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800710 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700711 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
712 1, hdr->sa, sub_type, 0, session);
713 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 }
Krunal Soni99752a12016-04-12 17:44:45 -0700715 return true;
716}
717
718/**
719 * lim_chk_is_11b_sta_supported() - checks if STA is 11b
720 * @mac_ctx: pointer to Global MAC structure
721 * @hdr: pointer to the MAC head
722 * @session: pointer to pe session entry
723 * @assoc_req: pointer to ASSOC/REASSOC Request frame
724 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
725 * @phy_mode: phy mode
726 *
727 * Checks if STA is 11b
728 *
729 * Return: true of no error, false otherwise
730 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800731static bool lim_chk_is_11b_sta_supported(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700732 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800733 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700734 tpSirAssocReq assoc_req,
735 uint8_t sub_type, uint32_t phy_mode)
736{
737 uint32_t cfg_11g_only;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
Naveen Rawatada5fac2016-01-28 16:24:32 -0800739 if (phy_mode == WNI_CFG_PHY_MODE_11G) {
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530740 cfg_11g_only = mac_ctx->mlme_cfg->sap_cfg.sap_11g_policy;
Krunal Soni99752a12016-04-12 17:44:45 -0700741 if (!assoc_req->extendedRatesPresent && cfg_11g_only) {
742 /*
743 * Received Re/Association Request from 11b STA when 11g
744 * only policy option is set. Reject with unspecified
745 * status code.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 */
Naveen Rawatada5fac2016-01-28 16:24:32 -0800747 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -0700748 eSIR_MAC_BASIC_RATES_NOT_SUPPORTED_STATUS,
749 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530751 pe_warn("Rejecting Re/Assoc req from 11b STA:");
Naveen Rawatada5fac2016-01-28 16:24:32 -0800752 lim_print_mac_addr(mac_ctx, hdr->sa, LOGW);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
754#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -0800755 mac_ctx->lim.gLim11bStaAssocRejectCount++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756#endif
Krunal Soni99752a12016-04-12 17:44:45 -0700757 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 }
759 }
Krunal Soni99752a12016-04-12 17:44:45 -0700760 return true;
761}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762
Krunal Soni99752a12016-04-12 17:44:45 -0700763/**
764 * lim_print_ht_cap() - prints HT caps
765 * @mac_ctx: pointer to Global MAC structure
766 * @session: pointer to pe session entry
767 * @assoc_req: pointer to ASSOC/REASSOC Request frame
768 *
769 * Prints HT caps
770 *
771 * Return: void
772 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800773static void lim_print_ht_cap(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -0700774 tpSirAssocReq assoc_req)
775{
776 if (!session->htCapability)
777 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
Krunal Soni99752a12016-04-12 17:44:45 -0700779 if (assoc_req->HTCaps.present) {
780 /* The station *does* support 802.11n HT capability... */
Nishank Aggarwal8935e442017-03-23 19:11:08 +0530781 pe_debug("AdvCodingCap:%d ChaWidthSet:%d PowerSave:%d greenField:%d shortGI20:%d shortGI40:%d txSTBC:%d rxSTBC:%d delayBA:%d maxAMSDUsize:%d DSSS/CCK:%d PSMP:%d stbcCntl:%d lsigTXProt:%d",
Krunal Soni99752a12016-04-12 17:44:45 -0700782 assoc_req->HTCaps.advCodingCap,
783 assoc_req->HTCaps.supportedChannelWidthSet,
784 assoc_req->HTCaps.mimoPowerSave,
785 assoc_req->HTCaps.greenField,
786 assoc_req->HTCaps.shortGI20MHz,
787 assoc_req->HTCaps.shortGI40MHz,
788 assoc_req->HTCaps.txSTBC,
789 assoc_req->HTCaps.rxSTBC,
790 assoc_req->HTCaps.delayedBA,
791 assoc_req->HTCaps.maximalAMSDUsize,
792 assoc_req->HTCaps.dsssCckMode40MHz,
793 assoc_req->HTCaps.psmp,
794 assoc_req->HTCaps.stbcControlFrame,
795 assoc_req->HTCaps.lsigTXOPProtection);
796 /*
797 * Make sure the STA's caps are compatible with our own:
798 * 11.15.2 Support of DSSS/CCK in 40 MHz the AP shall refuse
799 * association requests from an HT STA that has the DSSS/CCK
800 * Mode in 40 MHz subfield set to 1;
801 */
802 }
803}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700805#ifdef WLAN_CONV_CRYPTO_IE_SUPPORT
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800806static tSirMacStatusCodes lim_check_rsn_ie(struct pe_session *session,
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700807 struct mac_context *mac_ctx,
808 tpSirAssocReq assoc_req,
809 tDot11fIERSN *rsn,
810 bool *pmf_connection)
811{
812 struct wlan_objmgr_vdev *vdev;
813
814 uint8_t buffer[SIR_MAC_MAX_IE_LENGTH];
815 uint32_t dot11f_status, written = 0, nbuffer = SIR_MAC_MAX_IE_LENGTH;
816 tSirMacRsnInfo rsn_ie;
817
818 dot11f_status = dot11f_pack_ie_rsn(mac_ctx, rsn, buffer,
819 nbuffer, &written);
820 if (DOT11F_FAILED(dot11f_status)) {
821 pe_err("Failed to re-pack the RSN IE (0x%0x8)", dot11f_status);
822 return eSIR_MAC_INVALID_IE_STATUS;
823 }
824
825 rsn_ie.length = (uint8_t) written;
826 qdf_mem_copy(&rsn_ie.info[0], buffer, rsn_ie.length);
827 if (wlan_crypto_check_rsn_match(mac_ctx->psoc, session->smeSessionId,
828 &rsn_ie.info[0], rsn_ie.length)) {
829 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
830 session->smeSessionId,
831 WLAN_LEGACY_MAC_ID);
832 if (!vdev) {
833 pe_err("vdev is NULL");
834 return eSIR_MAC_UNSPEC_FAILURE_STATUS;
835 }
836
837 *pmf_connection = wlan_crypto_vdev_is_pmf_enabled(vdev);
838 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
839 } else {
840 return eSIR_MAC_INVALID_IE_STATUS;
841 }
842
843 return eSIR_MAC_SUCCESS_STATUS;
844}
845
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800846static tSirMacStatusCodes lim_check_wpa_ie(struct pe_session *session,
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700847 struct mac_context *mac_ctx,
848 tpSirAssocReq assoc_req,
849 tDot11fIEWPA *wpa)
850{
851 uint8_t buffer[SIR_MAC_MAX_IE_LENGTH];
852 uint32_t dot11f_status, written = 0, nbuffer = SIR_MAC_MAX_IE_LENGTH;
853 tSirMacRsnInfo wpa_ie = {0};
854
855 dot11f_status = dot11f_pack_ie_wpa(mac_ctx, wpa, buffer,
856 nbuffer, &written);
857 if (DOT11F_FAILED(dot11f_status)) {
858 pe_err("Failed to re-pack the RSN IE (0x%0x8)", dot11f_status);
859 return eSIR_MAC_INVALID_IE_STATUS;
860 }
861
862 wpa_ie.length = (uint8_t) written;
863 qdf_mem_copy(&wpa_ie.info[0], buffer, wpa_ie.length);
864 if (wlan_crypto_check_wpa_match(mac_ctx->psoc, session->smeSessionId,
865 &wpa_ie.info[0], wpa_ie.length))
866 return eSIR_MAC_SUCCESS_STATUS;
867
868 return eSIR_MAC_INVALID_IE_STATUS;
869}
870#else
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800871static tSirMacStatusCodes lim_check_rsn_ie(struct pe_session *session,
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700872 struct mac_context *mac_ctx,
873 tpSirAssocReq assoc_req,
874 tDot11fIERSN *rsn,
875 bool *pmf_connection)
876{
877 return lim_check_rx_rsn_ie_match(mac_ctx, rsn, session,
878 assoc_req->HTCaps.present,
879 pmf_connection);
880}
881
Jeff Johnson5b574dd2018-11-19 06:49:34 -0800882static tSirMacStatusCodes lim_check_wpa_ie(struct pe_session *session,
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700883 struct mac_context *mac_ctx,
884 tpSirAssocReq assoc_req,
885 tDot11fIEWPA *wpa)
886{
887 return lim_check_rx_wpa_ie_match(mac_ctx, wpa, session,
888 assoc_req->HTCaps.present);
889}
890#endif
Krunal Soni99752a12016-04-12 17:44:45 -0700891/**
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530892 * lim_check_wpa_rsn_ie() - wpa and rsn ie related checks
893 * @session: pointer to pe session entry
894 * @mac_ctx: pointer to Global MAC structure
895 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
896 * @hdr: pointer to the MAC head
897 * @assoc_req: pointer to ASSOC/REASSOC Request frame
898 * @pmf_connection: flag indicating pmf connection
899 *
900 * This function checks if wpa/rsn IE is present and validates
901 * ie version, length and mismatch.
902 *
903 * Return: true if no error, false otherwise
904 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800905static bool lim_check_wpa_rsn_ie(struct pe_session *session, struct mac_context *mac_ctx,
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530906 uint8_t sub_type, tpSirMacMgmtHdr hdr,
907 tpSirAssocReq assoc_req, bool *pmf_connection)
908{
909 uint32_t ret;
910 tDot11fIEWPA dot11f_ie_wpa = {0};
911 tDot11fIERSN dot11f_ie_rsn = {0};
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700912 tSirMacStatusCodes status = eSIR_MAC_SUCCESS_STATUS;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530913
914 /*
915 * Clear the buffers so that frame parser knows that there isn't a
916 * previously decoded IE in these buffers
917 */
918 qdf_mem_set((uint8_t *) &dot11f_ie_rsn, sizeof(dot11f_ie_rsn), 0);
919 qdf_mem_set((uint8_t *) &dot11f_ie_wpa, sizeof(dot11f_ie_wpa), 0);
920 pe_err("RSN enabled auth, Re/Assoc req from STA: "
921 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(hdr->sa));
922
923 if (assoc_req->rsnPresent) {
924 if (!(assoc_req->rsn.length)) {
925 pe_warn("Re/Assoc rejected from: "
926 MAC_ADDRESS_STR,
927 MAC_ADDR_ARRAY(hdr->sa));
928 /*
929 * rcvd Assoc req frame with RSN IE but
930 * length is zero
931 */
932 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
933 eSIR_MAC_INVALID_IE_STATUS, 1,
934 hdr->sa, sub_type, 0, session);
935 return false;
936 }
937
938 /* Unpack the RSN IE */
939 ret = dot11f_unpack_ie_rsn(mac_ctx,
940 &assoc_req->rsn.info[0],
941 assoc_req->rsn.length,
942 &dot11f_ie_rsn, false);
943 if (!DOT11F_SUCCEEDED(ret)) {
944 pe_err("Invalid RSN IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -0400945 lim_send_assoc_rsp_mgmt_frame(
946 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
947 hdr->sa, sub_type, 0, session);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530948 return false;
949 }
950
951 /* Check if the RSN version is supported */
952 if (SIR_MAC_OUI_VERSION_1 == dot11f_ie_rsn.version) {
953 /* check the groupwise and pairwise cipher suites */
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -0700954 status = lim_check_rsn_ie(session, mac_ctx, assoc_req,
955 &dot11f_ie_rsn,
956 pmf_connection);
957 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530958 pe_warn("Re/Assoc rejected from: "
959 MAC_ADDRESS_STR,
960 MAC_ADDR_ARRAY(hdr->sa));
961
962 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status,
963 1, hdr->sa, sub_type,
964 0, session);
965 return false;
966 }
967 } else {
968 pe_warn("Re/Assoc rejected from: " MAC_ADDRESS_STR,
969 MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +0530970 /*
971 * rcvd Assoc req frame with RSN IE but
972 * IE version is wrong
973 */
974 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
975 eSIR_MAC_UNSUPPORTED_RSN_IE_VERSION_STATUS,
976 1, hdr->sa, sub_type, 0, session);
977 return false;
978 }
979 } else if (assoc_req->wpaPresent) {
980 if (!(assoc_req->wpa.length)) {
981 pe_warn("Re/Assoc rejected from: "
982 MAC_ADDRESS_STR,
983 MAC_ADDR_ARRAY(hdr->sa));
984
985 /* rcvd Assoc req frame with invalid WPA IE length */
986 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
987 eSIR_MAC_INVALID_IE_STATUS, 1,
988 hdr->sa, sub_type, 0, session);
989 return false;
990 }
991 /* Unpack the WPA IE */
992 ret = dot11f_unpack_ie_wpa(mac_ctx,
993 &assoc_req->wpa.info[4],
994 (assoc_req->wpa.length - 4),
995 &dot11f_ie_wpa, false);
996 if (!DOT11F_SUCCEEDED(ret)) {
997 pe_err("Invalid WPA IE");
Liangwei Dong433a8db2018-08-14 01:43:23 -0400998 lim_send_assoc_rsp_mgmt_frame(
999 mac_ctx, eSIR_MAC_INVALID_IE_STATUS, 1,
1000 hdr->sa, sub_type, 0, session);
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301001 return false;
1002 }
1003
1004 /* check the groupwise and pairwise cipher suites*/
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001005 status = lim_check_wpa_ie(session, mac_ctx, assoc_req,
1006 &dot11f_ie_wpa);
1007 if (eSIR_MAC_SUCCESS_STATUS != status) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301008 pe_warn("Re/Assoc rejected from: "
1009 MAC_ADDRESS_STR,
1010 MAC_ADDR_ARRAY(hdr->sa));
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301011 /*
1012 * rcvd Assoc req frame with WPA IE
1013 * but there is mismatch
1014 */
1015 lim_send_assoc_rsp_mgmt_frame(mac_ctx, status, 1,
1016 hdr->sa, sub_type, 0, session);
1017 return false;
1018 }
1019
1020 }
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301021
Kiran Kumar Lokere4ce40482018-08-30 16:31:00 -07001022 return true;
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301023}
1024
1025/**
Krunal Soni99752a12016-04-12 17:44:45 -07001026 * lim_chk_n_process_wpa_rsn_ie() - wpa ie related checks
1027 * @mac_ctx: pointer to Global MAC structure
1028 * @hdr: pointer to the MAC head
1029 * @session: pointer to pe session entry
1030 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1031 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1032 * @pmf_connection: flag indicating pmf connection
1033 *
1034 * wpa ie related checks
1035 *
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301036 * Return: true if no error, false otherwise
Krunal Soni99752a12016-04-12 17:44:45 -07001037 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001038static bool lim_chk_n_process_wpa_rsn_ie(struct mac_context *mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001039 tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001040 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001041 tpSirAssocReq assoc_req,
1042 uint8_t sub_type, bool *pmf_connection)
1043{
Naveen Rawat08db88f2017-09-08 15:07:48 -07001044 const uint8_t *wps_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045
1046 /* if additional IE is present, check if it has WscIE */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001047 if (assoc_req->addIEPresent && assoc_req->addIE.length)
Krunal Soni99752a12016-04-12 17:44:45 -07001048 wps_ie = limGetWscIEPtr(mac_ctx, assoc_req->addIE.addIEdata,
1049 assoc_req->addIE.length);
1050 else
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301051 pe_debug("Assoc req addIEPresent: %d addIE length: %d",
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301052 assoc_req->addIEPresent, assoc_req->addIE.length);
Krunal Soni99752a12016-04-12 17:44:45 -07001053
Naveen Rawatada5fac2016-01-28 16:24:32 -08001054 /* when wps_ie is present, RSN/WPA IE is ignored */
1055 if (wps_ie == NULL) {
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301056 /* check whether RSN IE is present */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001057 if (LIM_IS_AP_ROLE(session) &&
1058 session->pLimStartBssReq->privacy &&
Pragaspathi Thilagaraj2d1b3112018-07-06 15:54:42 +05301059 session->pLimStartBssReq->rsnIE.length)
1060 return lim_check_wpa_rsn_ie(session, mac_ctx, sub_type,
1061 hdr, assoc_req, pmf_connection);
1062 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301063 pe_debug("Assoc req WSE IE is present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 }
Krunal Soni99752a12016-04-12 17:44:45 -07001065 return true;
1066}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
Krunal Soni99752a12016-04-12 17:44:45 -07001068/**
1069 * lim_process_assoc_req_no_sta_ctx() - process assoc req for no sta ctx present
1070 * @mac_ctx: pointer to Global MAC structure
1071 * @hdr: pointer to the MAC head
1072 * @session: pointer to pe session entry
1073 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1074 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1075 * @sta_pre_auth_ctx: sta pre auth context
1076 * @sta_ds: station dph entry
1077 * @auth_type: indicates security type
1078 *
1079 * Process assoc req for no sta ctx present
1080 *
1081 * Return: true of no error, false otherwise
1082 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001083static bool lim_process_assoc_req_no_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001084 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001085 tpSirAssocReq assoc_req, uint8_t sub_type,
1086 struct tLimPreAuthNode *sta_pre_auth_ctx,
1087 tpDphHashNode sta_ds, tAniAuthType *auth_type)
1088{
1089 /* Requesting STA is not currently associated */
1090 if (pe_get_current_stas_count(mac_ctx) ==
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05301091 mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit) {
Krunal Soni99752a12016-04-12 17:44:45 -07001092 /*
1093 * Maximum number of STAs that AP can handle reached.
1094 * Send Association response to peer MAC entity
1095 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301096 pe_err("Max Sta count reached : %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001097 mac_ctx->lim.maxStation);
1098 lim_reject_association(mac_ctx, hdr->sa, sub_type, false,
1099 (tAniAuthType) 0, 0, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001100 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001101 session);
1102 return false;
1103 }
1104 /* Check if STA is pre-authenticated. */
1105 if ((sta_pre_auth_ctx == NULL) || (sta_pre_auth_ctx &&
1106 (sta_pre_auth_ctx->mlmState != eLIM_MLM_AUTHENTICATED_STATE))) {
1107 /*
1108 * STA is not pre-authenticated yet requesting Re/Association
1109 * before Authentication. OR STA is in the process of getting
1110 * authenticated and sent Re/Association request. Send
1111 * Deauthentication frame with 'prior authentication required'
1112 * reason code.
1113 */
1114 lim_send_deauth_mgmt_frame(mac_ctx,
1115 eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON,
1116 hdr->sa, session, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301118 pe_warn("rcvd %s req, sessionid: %d, without pre-auth ctx"
1119 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001120 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1121 session->peSessionId, MAC_ADDR_ARRAY(hdr->sa));
1122 return false;
1123 }
1124 /* Delete 'pre-auth' context of STA */
1125 *auth_type = sta_pre_auth_ctx->authType;
1126 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
1127 /* All is well. Assign AID (after else part) */
1128 return true;
1129}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130
Krunal Soni99752a12016-04-12 17:44:45 -07001131/**
1132 * lim_process_assoc_req_sta_ctx() - process assoc req for sta context present
1133 * @mac_ctx: pointer to Global MAC structure
1134 * @hdr: pointer to the MAC head
1135 * @session: pointer to pe session entry
1136 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1137 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1138 * @sta_pre_auth_ctx: sta pre auth context
1139 * @sta_ds: station dph entry
1140 * @peer_idx: peer index
1141 * @auth_type: indicates security type
1142 * @update_ctx: indicates if STA context already exist
1143 *
1144 * Process assoc req for sta context present
1145 *
1146 * Return: true of no error, false otherwise
1147 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001148static bool lim_process_assoc_req_sta_ctx(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001149 tpSirMacMgmtHdr hdr, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001150 tpSirAssocReq assoc_req, uint8_t sub_type,
1151 struct tLimPreAuthNode *sta_pre_auth_ctx,
1152 tpDphHashNode sta_ds, uint16_t peer_idx,
1153 tAniAuthType *auth_type, uint8_t *update_ctx)
1154{
1155 /* STA context does exist for this STA */
1156 if (sta_ds->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE) {
1157 /*
1158 * Requesting STA is in some 'transient' state? Ignore the
1159 * Re/Assoc Req frame by incrementing debug counter & logging
1160 * error.
1161 */
1162 if (sub_type == LIM_ASSOC) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001164 mac_ctx->lim.gLimNumAssocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301166 pe_debug("received Assoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001167 sta_ds->mlmStaContext.mlmState);
1168 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169#ifdef WLAN_DEBUG
Krunal Soni99752a12016-04-12 17:44:45 -07001170 mac_ctx->lim.gLimNumReassocReqDropInvldState++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171#endif
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301172 pe_debug("received ReAssoc req in state: %X from",
Krunal Soni99752a12016-04-12 17:44:45 -07001173 sta_ds->mlmStaContext.mlmState);
1174 }
Nishank Aggarwaled4c1c52017-03-11 14:17:49 +05301175 lim_print_mac_addr(mac_ctx, hdr->sa, LOGD);
1176 lim_print_mlm_state(mac_ctx, LOGD,
Krunal Soni99752a12016-04-12 17:44:45 -07001177 (tLimMlmStates) sta_ds->mlmStaContext.mlmState);
1178 return false;
1179 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180
Krunal Soni99752a12016-04-12 17:44:45 -07001181 /* STA sent assoc req frame while already in 'associated' state */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182
1183#ifdef WLAN_FEATURE_11W
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301184 pe_debug("Re/Assoc request from station that is already associated");
1185 pe_debug("PMF enabled: %d, SA Query state: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001186 sta_ds->rmfEnabled, sta_ds->pmfSaQueryState);
1187 if (sta_ds->rmfEnabled) {
1188 switch (sta_ds->pmfSaQueryState) {
1189 /*
1190 * start SA Query procedure, respond to Association Request with
1191 * try again later
1192 */
1193 case DPH_SA_QUERY_NOT_IN_PROGRESS:
1194 /*
1195 * We should reset the retry counter before we start
1196 * the SA query procedure, otherwise in next set of SA
1197 * query procedure we will end up using the stale value.
1198 */
1199 sta_ds->pmfSaQueryRetryCount = 0;
1200 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1201 eSIR_MAC_TRY_AGAIN_LATER, 1, hdr->sa,
1202 sub_type, sta_ds, session);
1203 lim_send_sa_query_request_frame(mac_ctx,
1204 (uint8_t *) &(sta_ds->pmfSaQueryCurrentTransId),
1205 hdr->sa, session);
1206 sta_ds->pmfSaQueryStartTransId =
1207 sta_ds->pmfSaQueryCurrentTransId;
1208 sta_ds->pmfSaQueryCurrentTransId++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209
Krunal Soni99752a12016-04-12 17:44:45 -07001210 /* start timer for SA Query retry */
1211 if (tx_timer_activate(&sta_ds->pmfSaQueryTimer)
1212 != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301213 pe_err("PMF SA Query timer start failed!");
Krunal Soni99752a12016-04-12 17:44:45 -07001214 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 }
Krunal Soni99752a12016-04-12 17:44:45 -07001216 sta_ds->pmfSaQueryState = DPH_SA_QUERY_IN_PROGRESS;
1217 return false;
1218 /*
1219 * SA Query procedure still going, respond to Association
1220 * Request with try again later
1221 */
1222 case DPH_SA_QUERY_IN_PROGRESS:
1223 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1224 eSIR_MAC_TRY_AGAIN_LATER, 1,
1225 hdr->sa, sub_type, 0, session);
1226 return false;
1227
1228 /*
1229 * SA Query procedure timed out, accept Association
1230 * Request normally
1231 */
1232 case DPH_SA_QUERY_TIMED_OUT:
1233 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1234 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
Krunal Soni99752a12016-04-12 17:44:45 -07001236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237#endif
1238
Krunal Soni99752a12016-04-12 17:44:45 -07001239 /* no change in the capability so drop the frame */
1240 if ((sub_type == LIM_ASSOC) &&
Ankit Guptaa5076012016-09-14 11:32:19 -07001241 (!qdf_mem_cmp(&sta_ds->mlmStaContext.capabilityInfo,
Krunal Soni99752a12016-04-12 17:44:45 -07001242 &assoc_req->capabilityInfo,
1243 sizeof(tSirMacCapabilityInfo)))) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301244 pe_err("Received Assoc req in state: %X STAid: %d",
Krunal Soni99752a12016-04-12 17:44:45 -07001245 sta_ds->mlmStaContext.mlmState, peer_idx);
1246 return false;
1247 } else {
1248 /*
1249 * STA sent Re/association Request frame while already in
1250 * 'associated' state. Update STA capabilities and send
1251 * Association response frame with same AID
1252 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301253 pe_debug("Rcvd Assoc req from STA already connected");
Krunal Soni99752a12016-04-12 17:44:45 -07001254 sta_ds->mlmStaContext.capabilityInfo =
1255 assoc_req->capabilityInfo;
1256 if (sta_pre_auth_ctx && (sta_pre_auth_ctx->mlmState ==
1257 eLIM_MLM_AUTHENTICATED_STATE)) {
1258 /* STA has triggered pre-auth again */
1259 *auth_type = sta_pre_auth_ctx->authType;
1260 lim_delete_pre_auth_node(mac_ctx, hdr->sa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001262 *auth_type = sta_ds->mlmStaContext.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264
Krunal Soni99752a12016-04-12 17:44:45 -07001265 *update_ctx = true;
1266 if (dph_init_sta_state(mac_ctx, hdr->sa, peer_idx, true,
1267 &session->dph.dphHashTable) == NULL) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301268 pe_err("could not Init STAid: %d", peer_idx);
Krunal Soni99752a12016-04-12 17:44:45 -07001269 return false;
1270 }
1271 }
1272 return true;
1273}
1274
1275/**
1276 * lim_chk_wmm() - wmm related checks
1277 * @mac_ctx: pointer to Global MAC structure
1278 * @hdr: pointer to the MAC head
1279 * @session: pointer to pe session entry
1280 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1281 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1282 * @qos_mode: qos mode
1283 *
1284 * wmm related checks
1285 *
1286 * Return: true of no error, false otherwise
1287 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001288static bool lim_chk_wmm(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001289 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001290 uint8_t sub_type, tHalBitVal qos_mode)
1291{
1292 tHalBitVal wme_mode;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001293
Naveen Rawatada5fac2016-01-28 16:24:32 -08001294 limGetWmeMode(session, &wme_mode);
1295 if ((qos_mode == eHAL_SET) || (wme_mode == eHAL_SET)) {
Krunal Soni99752a12016-04-12 17:44:45 -07001296 /*
1297 * for a qsta, check if the requested Traffic spec is admissible
1298 * for a non-qsta check if the sta can be admitted
1299 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001300 if (assoc_req->addtsPresent) {
Krunal Soni99752a12016-04-12 17:44:45 -07001301 uint8_t tspecIdx = 0;
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001302
Naveen Rawatada5fac2016-01-28 16:24:32 -08001303 if (lim_admit_control_add_ts(mac_ctx, hdr->sa,
Krunal Soni99752a12016-04-12 17:44:45 -07001304 &(assoc_req->addtsReq),
1305 &(assoc_req->qosCapability),
1306 0, false, NULL, &tspecIdx, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001307 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301308 pe_warn("AdmitControl: TSPEC rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001309 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001310 eSIR_MAC_QAP_NO_BANDWIDTH_REASON,
1311 1, hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001313 mac_ctx->lim.gLimNumAssocReqDropACRejectTS++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001315 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001317 } else if (lim_admit_control_add_sta(mac_ctx, hdr->sa, false)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001318 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301319 pe_warn("AdmitControl: Sta rejected");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001320 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
Krunal Soni99752a12016-04-12 17:44:45 -07001321 eSIR_MAC_QAP_NO_BANDWIDTH_REASON, 1,
1322 hdr->sa, sub_type, 0, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323#ifdef WLAN_DEBUG
Naveen Rawatada5fac2016-01-28 16:24:32 -08001324 mac_ctx->lim.gLimNumAssocReqDropACRejectSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325#endif
Krunal Soni99752a12016-04-12 17:44:45 -07001326 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 }
1328 /* else all ok */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301329 pe_debug("AdmitControl: Sta OK!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 }
Krunal Soni99752a12016-04-12 17:44:45 -07001331 return true;
1332}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333
Krunal Soni99752a12016-04-12 17:44:45 -07001334/**
1335 * lim_update_sta_ds() - updates ds dph entry
1336 * @mac_ctx: pointer to Global MAC structure
1337 * @hdr: pointer to the MAC head
1338 * @session: pointer to pe session entry
Abhishek Singh61084982016-12-13 17:24:07 +05301339 * @assoc_req: pointer to ASSOC/REASSOC Request frame pointer
Krunal Soni99752a12016-04-12 17:44:45 -07001340 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1341 * @sta_ds: station dph entry
Krunal Soni99752a12016-04-12 17:44:45 -07001342 * @auth_type: indicates security type
1343 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1344 * @peer_idx: peer index
1345 * @qos_mode: qos mode
1346 * @pmf_connection: flag indicating pmf connection
1347 *
1348 * Updates ds dph entry
1349 *
1350 * Return: true of no error, false otherwise
1351 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001352static bool lim_update_sta_ds(struct mac_context *mac_ctx, tpSirMacMgmtHdr hdr,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001353 struct pe_session *session, tpSirAssocReq assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07001354 uint8_t sub_type, tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001355 tAniAuthType auth_type,
1356 bool *assoc_req_copied, uint16_t peer_idx,
1357 tHalBitVal qos_mode, bool pmf_connection)
1358{
Krunal Soni99752a12016-04-12 17:44:45 -07001359 tHalBitVal wme_mode, wsm_mode;
1360 uint8_t *ht_cap_ie = NULL;
1361#ifdef WLAN_FEATURE_11W
1362 tPmfSaQueryTimerId timer_id;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301363 uint16_t retry_interval;
Krunal Soni99752a12016-04-12 17:44:45 -07001364#endif
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301365 tDot11fIEVHTCaps *vht_caps;
Abhishek Singh61084982016-12-13 17:24:07 +05301366 tpSirAssocReq tmp_assoc_req;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301367
1368 if (assoc_req->VHTCaps.present)
1369 vht_caps = &assoc_req->VHTCaps;
1370 else if (assoc_req->vendor_vht_ie.VHTCaps.present &&
1371 session->vendor_vht_sap)
1372 vht_caps = &assoc_req->vendor_vht_ie.VHTCaps;
1373 else
1374 vht_caps = NULL;
1375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 /*
Krunal Soni99752a12016-04-12 17:44:45 -07001377 * check here if the parsedAssocReq already pointing to the assoc_req
1378 * and free it before assigning this new assoc_req
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001380 if (session->parsedAssocReq != NULL) {
1381 tmp_assoc_req = session->parsedAssocReq[sta_ds->assocId];
1382 if (tmp_assoc_req != NULL) {
1383 if (tmp_assoc_req->assocReqFrame) {
1384 qdf_mem_free(tmp_assoc_req->assocReqFrame);
1385 tmp_assoc_req->assocReqFrame = NULL;
1386 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001388 qdf_mem_free(tmp_assoc_req);
1389 tmp_assoc_req = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 }
1391
Naveen Rawatada5fac2016-01-28 16:24:32 -08001392 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
Krunal Soni99752a12016-04-12 17:44:45 -07001393 *assoc_req_copied = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 }
1395
Naveen Rawatada5fac2016-01-28 16:24:32 -08001396 sta_ds->mlmStaContext.htCapability = assoc_req->HTCaps.present;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301397 if ((vht_caps != NULL) && vht_caps->present)
1398 sta_ds->mlmStaContext.vhtCapability = vht_caps->present;
1399 else
1400 sta_ds->mlmStaContext.vhtCapability = false;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001401 lim_update_stads_he_capable(sta_ds, assoc_req);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001402 sta_ds->qos.addtsPresent =
1403 (assoc_req->addtsPresent == 0) ? false : true;
1404 sta_ds->qos.addts = assoc_req->addtsReq;
1405 sta_ds->qos.capability = assoc_req->qosCapability;
1406 sta_ds->versionPresent = 0;
Krunal Soni99752a12016-04-12 17:44:45 -07001407 /*
1408 * short slot and short preamble should be updated before doing
1409 * limaddsta
1410 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001411 sta_ds->shortPreambleEnabled =
1412 (uint8_t) assoc_req->capabilityInfo.shortPreamble;
1413 sta_ds->shortSlotTimeEnabled =
1414 (uint8_t) assoc_req->capabilityInfo.shortSlotTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415
Naveen Rawatada5fac2016-01-28 16:24:32 -08001416 sta_ds->valid = 0;
1417 sta_ds->mlmStaContext.authType = auth_type;
1418 sta_ds->staType = STA_ENTRY_PEER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419
Krunal Soni99752a12016-04-12 17:44:45 -07001420 /*
1421 * TODO: If listen interval is more than certain limit, reject the
1422 * association. Need to check customer requirements and then implement.
1423 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001424 sta_ds->mlmStaContext.listenInterval = assoc_req->listenInterval;
1425 sta_ds->mlmStaContext.capabilityInfo = assoc_req->capabilityInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426
Krunal Soni99752a12016-04-12 17:44:45 -07001427 /*
1428 * The following count will be used to knock-off the station if it
1429 * doesn't come back to receive the buffered data. The AP will wait
1430 * for numTimSent number of beacons after sending TIM information for
1431 * the station, before assuming that the station is no more associated
1432 * and disassociates it
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 */
1434
Krunal Soni99752a12016-04-12 17:44:45 -07001435 /* timWaitCount used by PMM for monitoring the STA's in PS for LINK */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001436 sta_ds->timWaitCount =
1437 (uint8_t) GET_TIM_WAIT_COUNT(assoc_req->listenInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
Krunal Soni99752a12016-04-12 17:44:45 -07001439 /* Init the Current successful MPDU's tranfered to this STA count = 0 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001440 sta_ds->curTxMpduCnt = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
Naveen Rawatada5fac2016-01-28 16:24:32 -08001442 if (IS_DOT11_MODE_HT(session->dot11mode) &&
1443 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
1444 sta_ds->htGreenfield = (uint8_t) assoc_req->HTCaps.greenField;
1445 sta_ds->htAMpduDensity = assoc_req->HTCaps.mpduDensity;
1446 sta_ds->htDsssCckRate40MHzSupport =
1447 (uint8_t) assoc_req->HTCaps.dsssCckMode40MHz;
1448 sta_ds->htLsigTXOPProtection =
1449 (uint8_t) assoc_req->HTCaps.lsigTXOPProtection;
1450 sta_ds->htMaxAmsduLength =
1451 (uint8_t) assoc_req->HTCaps.maximalAMSDUsize;
1452 sta_ds->htMaxRxAMpduFactor = assoc_req->HTCaps.maxRxAMPDUFactor;
1453 sta_ds->htMIMOPSState = assoc_req->HTCaps.mimoPowerSave;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454
Krunal Soni99752a12016-04-12 17:44:45 -07001455 /* assoc_req will be copied to session->parsedAssocReq later */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001456 ht_cap_ie = ((uint8_t *) &assoc_req->HTCaps) + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07001458 if (session->htConfig.ht_sgi20) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001459 sta_ds->htShortGI20Mhz =
Krunal Soni99752a12016-04-12 17:44:45 -07001460 (uint8_t)assoc_req->HTCaps.shortGI20MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 } else {
1462 /* Unset htShortGI20Mhz in ht_caps*/
1463 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI20MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001464 sta_ds->htShortGI20Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 }
1466
Sandeep Puligilla607f34a2016-05-25 14:37:47 -07001467 if (session->htConfig.ht_sgi40) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001468 sta_ds->htShortGI40Mhz =
1469 (uint8_t)assoc_req->HTCaps.shortGI40MHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 } else {
1471 /* Unset htShortGI40Mhz in ht_caps */
1472 *ht_cap_ie &= ~(1 << SIR_MAC_HT_CAP_SHORTGI40MHZ_S);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001473 sta_ds->htShortGI40Mhz = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 }
1475
Naveen Rawatada5fac2016-01-28 16:24:32 -08001476 sta_ds->htSupportedChannelWidthSet =
1477 (uint8_t) assoc_req->HTCaps.supportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 /*
1479 * peer just follows AP; so when we are softAP/GO,
1480 * we just store our session entry's secondary channel offset
1481 * here in peer INFRA STA. However, if peer's 40MHz channel
1482 * width support is disabled then secondary channel will be zero
1483 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001484 sta_ds->htSecondaryChannelOffset =
Krunal Soni99752a12016-04-12 17:44:45 -07001485 (sta_ds->htSupportedChannelWidthSet) ?
1486 session->htSecondaryChannelOffset : 0;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001487 if (assoc_req->operMode.present) {
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301488 enum phy_ch_width ch_width;
1489
1490 ch_width = assoc_req->operMode.chanWidth;
1491 if (session->ch_width < ch_width)
1492 ch_width = session->ch_width;
1493
Naveen Rawatada5fac2016-01-28 16:24:32 -08001494 sta_ds->vhtSupportedChannelWidthSet =
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301495 (uint8_t) ((ch_width == CH_WIDTH_80MHZ) ?
Krunal Soni99752a12016-04-12 17:44:45 -07001496 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ :
1497 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001498 sta_ds->htSupportedChannelWidthSet =
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301499 (uint8_t) (ch_width ?
Krunal Soni99752a12016-04-12 17:44:45 -07001500 eHT_CHANNEL_WIDTH_40MHZ :
1501 eHT_CHANNEL_WIDTH_20MHZ);
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301502 } else if ((vht_caps != NULL) && vht_caps->present) {
Krunal Soni99752a12016-04-12 17:44:45 -07001503 /*
1504 * Check if STA has enabled it's channel bonding mode.
1505 * If channel bonding mode is enabled, we decide based
1506 * on SAP's current configuration. else, we set it to
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001507 * VHT20.
1508 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001509 sta_ds->vhtSupportedChannelWidthSet =
Krunal Soni99752a12016-04-12 17:44:45 -07001510 (uint8_t) ((sta_ds->htSupportedChannelWidthSet
1511 == eHT_CHANNEL_WIDTH_20MHZ) ?
1512 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ :
1513 session->ch_width - 1);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001514 sta_ds->htMaxRxAMpduFactor =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301515 vht_caps->maxAMPDULenExp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 }
1517 /* Lesser among the AP and STA bandwidth of operation. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001518 sta_ds->htSupportedChannelWidthSet =
1519 (sta_ds->htSupportedChannelWidthSet <
Krunal Soni99752a12016-04-12 17:44:45 -07001520 session->htSupportedChannelWidthSet) ?
1521 sta_ds->htSupportedChannelWidthSet :
1522 session->htSupportedChannelWidthSet;
Abhishek Singh1d8bd622018-11-13 11:43:55 +05301523
1524 if (!sta_ds->htSupportedChannelWidthSet)
1525 sta_ds->vhtSupportedChannelWidthSet =
1526 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
1527
Naveen Rawatada5fac2016-01-28 16:24:32 -08001528 sta_ds->baPolicyFlag = 0xFF;
1529 sta_ds->htLdpcCapable =
1530 (uint8_t) assoc_req->HTCaps.advCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 }
1532
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301533 if ((vht_caps != NULL) && vht_caps->present &&
1534 assoc_req->wmeInfoPresent) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001535 sta_ds->vhtLdpcCapable =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05301536 (uint8_t) vht_caps->ldpcCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 }
1538
gaolez7bb1e742017-03-21 16:37:38 +08001539 if (assoc_req->ExtCap.present)
1540 sta_ds->non_ecsa_capable =
1541 !((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
1542 ext_chan_switch;
1543 else
1544 sta_ds->non_ecsa_capable = 1;
1545
Naveen Rawatada5fac2016-01-28 16:24:32 -08001546 if (!assoc_req->wmeInfoPresent) {
1547 sta_ds->mlmStaContext.htCapability = 0;
1548 sta_ds->mlmStaContext.vhtCapability = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 }
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001550
1551 if (sta_ds->mlmStaContext.vhtCapability && vht_caps) {
Krunal Soni53993f72016-07-08 18:20:03 -07001552 if (session->vht_config.su_beam_formee &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001553 vht_caps->suBeamFormerCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001554 sta_ds->vhtBeamFormerCapable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001556 sta_ds->vhtBeamFormerCapable = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001557 if (session->vht_config.su_beam_former &&
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001558 vht_caps->suBeamformeeCap)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001559 sta_ds->vht_su_bfee_capable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 else
Naveen Rawatada5fac2016-01-28 16:24:32 -08001561 sta_ds->vht_su_bfee_capable = 0;
Naveen Rawat2eb4c832018-02-15 10:47:38 -08001562
1563 pe_debug("peer_caps: suBformer: %d, suBformee: %d",
1564 vht_caps->suBeamFormerCap,
1565 vht_caps->suBeamformeeCap);
1566 pe_debug("self_cap: suBformer: %d, suBformee: %d",
1567 session->vht_config.su_beam_former,
1568 session->vht_config.su_beam_formee);
1569 pe_debug("connection's final cap: suBformer: %d, suBformee: %d",
1570 sta_ds->vhtBeamFormerCapable,
1571 sta_ds->vht_su_bfee_capable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001573
1574 lim_intersect_sta_he_caps(assoc_req, session, sta_ds);
1575
Krunal Soni99752a12016-04-12 17:44:45 -07001576 if (lim_populate_matching_rate_set(mac_ctx, sta_ds,
1577 &(assoc_req->supportedRates),
1578 &(assoc_req->extendedRates),
1579 assoc_req->HTCaps.supportedMCSSet,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07001580 session, vht_caps,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001581 &assoc_req->he_cap) != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 /* Could not update hash table entry at DPH with rateset */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301583 pe_err("Couldn't update hash entry for aid: %d MacAddr: "
Jeff Johnsonc742d8d2017-10-10 16:36:54 -07001584 MAC_ADDRESS_STR,
1585 peer_idx, MAC_ADDR_ARRAY(hdr->sa));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586
1587 /* Release AID */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001588 lim_release_peer_idx(mac_ctx, peer_idx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589
Naveen Rawatada5fac2016-01-28 16:24:32 -08001590 lim_reject_association(mac_ctx, hdr->sa,
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301591 sub_type, true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001592 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001593 session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301594 pe_err("Delete dph hash entry");
Abhishek Singh0bc46d12017-01-09 13:05:54 +05301595 if (dph_delete_hash_entry(mac_ctx, hdr->sa, sta_ds->assocId,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001596 &session->dph.dphHashTable) != QDF_STATUS_SUCCESS)
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301597 pe_err("error deleting hash entry");
Krunal Soni99752a12016-04-12 17:44:45 -07001598 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001600 if (assoc_req->operMode.present) {
1601 sta_ds->vhtSupportedRxNss = assoc_req->operMode.rxNSS + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001603 sta_ds->vhtSupportedRxNss =
1604 ((sta_ds->supportedRates.vhtRxMCSMap & MCSMAPMASK2x2)
Krunal Soni99752a12016-04-12 17:44:45 -07001605 == MCSMAPMASK2x2) ? 1 : 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
Krunal Soni99752a12016-04-12 17:44:45 -07001608 /* Add STA context at MAC HW (BMU, RHP & TFP) */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001609 sta_ds->qosMode = false;
1610 sta_ds->lleEnabled = false;
1611 if (assoc_req->capabilityInfo.qos && (qos_mode == eHAL_SET)) {
1612 sta_ds->lleEnabled = true;
1613 sta_ds->qosMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 }
1615
Naveen Rawatada5fac2016-01-28 16:24:32 -08001616 sta_ds->wmeEnabled = false;
1617 sta_ds->wsmEnabled = false;
1618 limGetWmeMode(session, &wme_mode);
1619 if ((!sta_ds->lleEnabled) && assoc_req->wmeInfoPresent
1620 && (wme_mode == eHAL_SET)) {
1621 sta_ds->wmeEnabled = true;
1622 sta_ds->qosMode = true;
1623 limGetWsmMode(session, &wsm_mode);
Krunal Soni99752a12016-04-12 17:44:45 -07001624 /*
1625 * WMM_APSD - WMM_SA related processing should be separate;
1626 * WMM_SA and WMM_APSD can coexist
1627 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001628 if (assoc_req->WMMInfoStation.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 /* check whether AP supports or not */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001630 if (LIM_IS_AP_ROLE(session) &&
Krunal Soni99752a12016-04-12 17:44:45 -07001631 (session->apUapsdEnable == 0) &&
1632 (assoc_req->WMMInfoStation.acbe_uapsd ||
1633 assoc_req->WMMInfoStation.acbk_uapsd ||
1634 assoc_req->WMMInfoStation.acvo_uapsd ||
1635 assoc_req->WMMInfoStation.acvi_uapsd)) {
1636 /*
1637 * Rcvd Re/Assoc Req from STA when UPASD is
1638 * not supported.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301640 pe_err("UAPSD not supported, reply accordingly");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001642 sta_ds->qos.capability.qosInfo.acbe_uapsd = 0;
1643 sta_ds->qos.capability.qosInfo.acbk_uapsd = 0;
1644 sta_ds->qos.capability.qosInfo.acvo_uapsd = 0;
1645 sta_ds->qos.capability.qosInfo.acvi_uapsd = 0;
1646 sta_ds->qos.capability.qosInfo.maxSpLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 } else {
1648 /* update UAPSD and send it to LIM to add STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001649 sta_ds->qos.capability.qosInfo.acbe_uapsd =
1650 assoc_req->WMMInfoStation.acbe_uapsd;
1651 sta_ds->qos.capability.qosInfo.acbk_uapsd =
1652 assoc_req->WMMInfoStation.acbk_uapsd;
1653 sta_ds->qos.capability.qosInfo.acvo_uapsd =
1654 assoc_req->WMMInfoStation.acvo_uapsd;
1655 sta_ds->qos.capability.qosInfo.acvi_uapsd =
1656 assoc_req->WMMInfoStation.acvi_uapsd;
1657 sta_ds->qos.capability.qosInfo.maxSpLen =
1658 assoc_req->WMMInfoStation.max_sp_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 }
1660 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001661 if (assoc_req->wsmCapablePresent && (wsm_mode == eHAL_SET))
1662 sta_ds->wsmEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 }
1664 /* Re/Assoc Response frame to requesting STA */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001665 sta_ds->mlmStaContext.subType = sub_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666
1667#ifdef WLAN_FEATURE_11W
Naveen Rawatada5fac2016-01-28 16:24:32 -08001668 sta_ds->rmfEnabled = (pmf_connection) ? 1 : 0;
1669 sta_ds->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
1670 timer_id.fields.sessionId = session->peSessionId;
1671 timer_id.fields.peerIdx = peer_idx;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05301672 retry_interval = mac_ctx->mlme_cfg->gen.pmf_sa_query_retry_interval;
1673 if (cfg_min(CFG_PMF_SA_QUERY_RETRY_INTERVAL) > retry_interval) {
1674 retry_interval = cfg_default(CFG_PMF_SA_QUERY_RETRY_INTERVAL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001676 if (sta_ds->rmfEnabled &&
1677 tx_timer_create(mac_ctx, &sta_ds->pmfSaQueryTimer,
Krunal Soni99752a12016-04-12 17:44:45 -07001678 "PMF SA Query timer", lim_pmf_sa_query_timer_handler,
1679 timer_id.value,
1680 SYS_MS_TO_TICKS((retry_interval * 1024) / 1000),
1681 0, TX_NO_ACTIVATE) != TX_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301682 pe_err("could not create PMF SA Query timer");
Krunal Soni99752a12016-04-12 17:44:45 -07001683 lim_reject_association(mac_ctx, hdr->sa, sub_type,
1684 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001685 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001686 session);
1687 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 }
Krunal Sonia59e8a42017-11-19 09:00:56 -08001689 if (sta_ds->rmfEnabled)
1690 pe_debug("Created pmf timer sta-idx:%d assoc-id:%d",
1691 sta_ds->staIndex, sta_ds->assocId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692#endif
1693
Naveen Rawatada5fac2016-01-28 16:24:32 -08001694 if (assoc_req->ExtCap.present) {
1695 lim_set_stads_rtt_cap(sta_ds,
1696 (struct s_ext_cap *) assoc_req->ExtCap.bytes, mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001698 sta_ds->timingMeasCap = 0;
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301699 pe_debug("ExtCap not present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 }
Krunal Soni99752a12016-04-12 17:44:45 -07001701 return true;
1702}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703
Krunal Soni99752a12016-04-12 17:44:45 -07001704/**
1705 * lim_update_sta_ctx() - add/del sta depending on connection state machine
1706 * @mac_ctx: pointer to Global MAC structure
1707 * @session: pointer to pe session entry
1708 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1709 * @sub_type: Assoc(=0) or Reassoc(=1) Requestframe
1710 * @sta_ds: station dph entry
1711 * @update_ctx: indicates if STA context already exist
1712 *
1713 * Checks for SSID match
1714 *
1715 * Return: true of no error, false otherwise
1716 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001717static bool lim_update_sta_ctx(struct mac_context *mac_ctx, struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001718 tpSirAssocReq assoc_req, uint8_t sub_type,
1719 tpDphHashNode sta_ds, uint8_t update_ctx)
1720{
1721 tLimMlmStates mlm_prev_state;
1722 /*
1723 * BTAMP: If STA context already exist (ie. update_ctx = 1) for this STA
1724 * then we should delete the old one, and add the new STA. This is taken
1725 * care of in the lim_del_sta() routine.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726 *
Krunal Soni99752a12016-04-12 17:44:45 -07001727 * Prior to BTAMP, we were setting this flag so that when PE receives
1728 * SME_ASSOC_CNF, and if this flag is set, then PE shall delete the old
1729 * station and then add. But now in BTAMP, we're directly adding station
1730 * before waiting for SME_ASSOC_CNF, so we can do this now.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 */
Krunal Soni99752a12016-04-12 17:44:45 -07001732 if (!(update_ctx)) {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001733 sta_ds->mlmStaContext.updateContext = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
Krunal Soni99752a12016-04-12 17:44:45 -07001735 /*
1736 * BTAMP: Add STA context at HW - issue WMA_ADD_STA_REQ to HAL
1737 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001738 if (lim_add_sta(mac_ctx, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001739 QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301740 pe_err("could not Add STA with assocId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001741 sta_ds->assocId);
1742 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001743 sta_ds->mlmStaContext.subType, true,
1744 sta_ds->mlmStaContext.authType,
1745 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001746 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001747 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748
Naveen Rawatada5fac2016-01-28 16:24:32 -08001749 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001750 assoc_req =
1751 session->parsedAssocReq[sta_ds->assocId];
1752 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 }
1754 } else {
Naveen Rawatada5fac2016-01-28 16:24:32 -08001755 sta_ds->mlmStaContext.updateContext = 1;
Naveen Rawatada5fac2016-01-28 16:24:32 -08001756 mlm_prev_state = sta_ds->mlmStaContext.mlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757
Krunal Soni99752a12016-04-12 17:44:45 -07001758 /*
1759 * As per the HAL/FW needs the reassoc req need not be calling
1760 * lim_del_sta
1761 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001762 if (sub_type != LIM_REASSOC) {
Krunal Soni99752a12016-04-12 17:44:45 -07001763 /*
1764 * we need to set the mlmState here in order
1765 * differentiate in lim_del_sta.
1766 */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001767 sta_ds->mlmStaContext.mlmState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE;
Krunal Soni99752a12016-04-12 17:44:45 -07001769 if (lim_del_sta(mac_ctx, sta_ds, true, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001770 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301771 pe_err("Couldn't DEL STA, assocId: %d staId: %d",
Naveen Rawatada5fac2016-01-28 16:24:32 -08001772 sta_ds->assocId, sta_ds->staIndex);
1773 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001774 sta_ds->mlmStaContext.subType, true,
1775 sta_ds->mlmStaContext.authType,
1776 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001777 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001778 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779
1780 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001781 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1782 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001783 assoc_req = session->parsedAssocReq[
1784 sta_ds->assocId];
1785 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 }
1787 } else {
Krunal Soni99752a12016-04-12 17:44:45 -07001788 /*
1789 * mlmState is changed in lim_add_sta context use the
1790 * same AID, already allocated
1791 */
1792 if (lim_add_sta(mac_ctx, sta_ds, false, session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001793 != QDF_STATUS_SUCCESS) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301794 pe_err("UPASD not supported, REASSOC Failed");
Naveen Rawatada5fac2016-01-28 16:24:32 -08001795 lim_reject_association(mac_ctx, sta_ds->staAddr,
Krunal Soni99752a12016-04-12 17:44:45 -07001796 sta_ds->mlmStaContext.subType, true,
1797 sta_ds->mlmStaContext.authType,
1798 sta_ds->assocId, true,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08001799 eSIR_MAC_WME_REFUSED_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07001800 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801
1802 /* Restoring the state back. */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001803 sta_ds->mlmStaContext.mlmState = mlm_prev_state;
1804 if (session->parsedAssocReq)
Krunal Soni99752a12016-04-12 17:44:45 -07001805 assoc_req = session->parsedAssocReq[
Naveen Rawatada5fac2016-01-28 16:24:32 -08001806 sta_ds->assocId];
Krunal Soni99752a12016-04-12 17:44:45 -07001807 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 }
Krunal Soni99752a12016-04-12 17:44:45 -07001811 return true;
1812}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813
Krunal Soni99752a12016-04-12 17:44:45 -07001814/**
1815 * lim_process_assoc_cleanup() - frees up resources used in function
1816 * lim_process_assoc_req_frame()
1817 * @mac_ctx: pointer to Global MAC structure
1818 * @session: pointer to pe session entry
1819 * @assoc_req: pointer to ASSOC/REASSOC Request frame
1820 * @sta_ds: station dph entry
1821 * @tmp_assoc_req: pointer to tmp ASSOC/REASSOC Request frame
1822 * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
1823 *
1824 * Frees up resources used in function lim_process_assoc_req_frame
1825 *
1826 * Return: void
1827 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001828static void lim_process_assoc_cleanup(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001829 struct pe_session *session,
Krunal Soni99752a12016-04-12 17:44:45 -07001830 tpSirAssocReq assoc_req,
1831 tpDphHashNode sta_ds,
Krunal Soni99752a12016-04-12 17:44:45 -07001832 bool *assoc_req_copied)
1833{
Abhishek Singh61084982016-12-13 17:24:07 +05301834 tpSirAssocReq tmp_assoc_req;
1835
Naveen Rawatada5fac2016-01-28 16:24:32 -08001836 if (assoc_req != NULL) {
1837 if (assoc_req->assocReqFrame) {
1838 qdf_mem_free(assoc_req->assocReqFrame);
1839 assoc_req->assocReqFrame = NULL;
1840 assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 }
1842
Naveen Rawatada5fac2016-01-28 16:24:32 -08001843 qdf_mem_free(assoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 /* to avoid double free */
Krunal Soni99752a12016-04-12 17:44:45 -07001845 if (*assoc_req_copied && session->parsedAssocReq)
Naveen Rawatada5fac2016-01-28 16:24:32 -08001846 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 }
1848
1849 /* If it is not duplicate Assoc request then only make to Null */
Naveen Rawatada5fac2016-01-28 16:24:32 -08001850 if ((sta_ds != NULL) &&
1851 (sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ADD_STA_RSP_STATE)) {
1852 if (session->parsedAssocReq != NULL) {
1853 tmp_assoc_req =
1854 session->parsedAssocReq[sta_ds->assocId];
1855 if (tmp_assoc_req != NULL) {
1856 if (tmp_assoc_req->assocReqFrame) {
Krunal Soni99752a12016-04-12 17:44:45 -07001857 qdf_mem_free(
1858 tmp_assoc_req->assocReqFrame);
Naveen Rawatada5fac2016-01-28 16:24:32 -08001859 tmp_assoc_req->assocReqFrame = NULL;
1860 tmp_assoc_req->assocReqFrameLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 }
Naveen Rawatada5fac2016-01-28 16:24:32 -08001862 qdf_mem_free(tmp_assoc_req);
Krunal Soni99752a12016-04-12 17:44:45 -07001863 session->parsedAssocReq[sta_ds->assocId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 }
1865 }
1866 }
Krunal Soni99752a12016-04-12 17:44:45 -07001867}
1868
1869/**
1870 * lim_process_assoc_req_frame() - Process RE/ASSOC Request frame.
1871 * @mac_ctx: Pointer to Global MAC structure
1872 * @rx_pkt_info: A pointer to Buffer descriptor + associated PDUs
1873 * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
1874 * Request(=1) frame
1875 * @session: pe session entry
1876 *
1877 * This function is called to process RE/ASSOC Request frame.
1878 *
1879 * @Return: void
1880 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001881void lim_process_assoc_req_frame(struct mac_context *mac_ctx, uint8_t *rx_pkt_info,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08001882 uint8_t sub_type, struct pe_session *session)
Krunal Soni99752a12016-04-12 17:44:45 -07001883{
1884 bool pmf_connection = false, assoc_req_copied = false;
1885 uint8_t update_ctx, *frm_body;
1886 uint16_t peer_idx, assoc_id = 0;
Krishna Kumaar Natarajandb582ec2016-03-08 17:37:04 -08001887 uint32_t frame_len;
Krunal Soni99752a12016-04-12 17:44:45 -07001888 uint32_t phy_mode;
1889 tHalBitVal qos_mode;
1890 tpSirMacMgmtHdr hdr;
1891 struct tLimPreAuthNode *sta_pre_auth_ctx;
1892 tAniAuthType auth_type;
1893 tSirMacCapabilityInfo local_cap;
1894 tpDphHashNode sta_ds = NULL;
Abhishek Singh61084982016-12-13 17:24:07 +05301895 tpSirAssocReq assoc_req;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07001896 bool dup_entry = false;
Krunal Soni99752a12016-04-12 17:44:45 -07001897
1898 lim_get_phy_mode(mac_ctx, &phy_mode, session);
1899
1900 limGetQosMode(session, &qos_mode);
1901
1902 hdr = WMA_GET_RX_MAC_HEADER(rx_pkt_info);
1903 frame_len = WMA_GET_RX_PAYLOAD_LEN(rx_pkt_info);
1904
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301905 pe_debug("Rcvd: %s Req Frame sessionid: %d systemrole: %d MlmState: %d from: "
1906 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001907 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1908 session->peSessionId, GET_LIM_SYSTEM_ROLE(session),
1909 session->limMlmState, MAC_ADDR_ARRAY(hdr->sa));
1910
Rajeev Kumarbe5d7fd2016-04-15 14:35:12 -07001911 if (LIM_IS_STA_ROLE(session)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301912 pe_err("Rcvd unexpected ASSOC REQ, sessionid: %d sys sub_type: %d for role: %d from: "
1913 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001914 session->peSessionId, sub_type,
1915 GET_LIM_SYSTEM_ROLE(session),
1916 MAC_ADDR_ARRAY(hdr->sa));
Srinivas Girigowdab896a562017-03-16 17:41:26 -07001917 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
1918 WMA_GET_RX_MPDU_DATA(rx_pkt_info),
1919 frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07001920 return;
1921 }
Liangwei Dong9028d752016-10-17 02:00:17 -04001922 if (session->limMlmState == eLIM_MLM_WT_DEL_BSS_RSP_STATE) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301923 pe_err("drop ASSOC REQ on sessionid: %d "
1924 "role: %d from: "MAC_ADDRESS_STR" in limMlmState: %d",
Liangwei Dong9028d752016-10-17 02:00:17 -04001925 session->peSessionId,
1926 GET_LIM_SYSTEM_ROLE(session),
1927 MAC_ADDR_ARRAY(hdr->sa),
1928 eLIM_MLM_WT_DEL_BSS_RSP_STATE);
1929 return;
1930 }
Krunal Soni99752a12016-04-12 17:44:45 -07001931
1932 /*
1933 * If a STA is already present in DPH and it is initiating a Assoc
1934 * re-transmit, do not process it. This can happen when first Assoc Req
1935 * frame is received but ACK lost at STA side. The ACK for this dropped
1936 * Assoc Req frame should be sent by HW. Host simply does not process it
1937 * once the entry for the STA is already present in DPH.
1938 */
1939 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &assoc_id,
1940 &session->dph.dphHashTable);
1941 if (NULL != sta_ds) {
1942 if (hdr->fc.retry > 0) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301943 pe_err("STA is initiating Assoc Req after ACK lost. Do not process sessionid: %d sys sub_type=%d for role=%d from: "
1944 MAC_ADDRESS_STR, session->peSessionId,
Krunal Soni99752a12016-04-12 17:44:45 -07001945 sub_type, GET_LIM_SYSTEM_ROLE(session),
1946 MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05301947 return;
Krunal Soni17184262017-06-07 16:42:38 -07001948 } else if (!sta_ds->rmfEnabled && (sub_type == LIM_REASSOC)) {
1949 /*
1950 * SAP should send reassoc response with reject code
1951 * to avoid IOT issues. as per the specification SAP
1952 * should do 4-way handshake after reassoc response and
1953 * some STA doesn't like 4way handshake after reassoc
1954 * where some STA does expect 4-way handshake.
1955 */
1956 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
1957 eSIR_MAC_OUTSIDE_SCOPE_OF_SPEC_STATUS,
1958 sta_ds->assocId, sta_ds->staAddr,
1959 sub_type, sta_ds, session);
1960 pe_err("Rejecting reassoc req from STA");
1961 return;
Krunal Soni99752a12016-04-12 17:44:45 -07001962 } else if (!sta_ds->rmfEnabled) {
1963 /*
1964 * Do this only for non PMF case.
1965 * STA might have missed the assoc response, so it is
1966 * sending assoc request frame again.
1967 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001968 lim_send_assoc_rsp_mgmt_frame(mac_ctx, QDF_STATUS_SUCCESS,
Krunal Soni99752a12016-04-12 17:44:45 -07001969 sta_ds->assocId, sta_ds->staAddr,
Krunal Soni90ba9542017-03-01 19:45:40 -08001970 sub_type,
Krunal Soni99752a12016-04-12 17:44:45 -07001971 sta_ds, session);
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301972 pe_err("DUT already received an assoc request frame and STA is sending another assoc req.So, do not Process sessionid: %d sys sub_type: %d for role: %d from: "
1973 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001974 session->peSessionId, sub_type,
1975 session->limSystemRole,
1976 MAC_ADDR_ARRAY(hdr->sa));
Abhishek Singha0b4dc12017-03-09 15:29:31 +05301977 return;
Krunal Soni99752a12016-04-12 17:44:45 -07001978 }
Krunal Soni99752a12016-04-12 17:44:45 -07001979 }
1980
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07001981 dup_entry = lim_check_sta_in_pe_entries(mac_ctx, hdr,
1982 session->peSessionId);
Krunal Soni99752a12016-04-12 17:44:45 -07001983
1984 /* Get pointer to Re/Association Request frame body */
1985 frm_body = WMA_GET_RX_MPDU_DATA(rx_pkt_info);
1986
1987 if (lim_is_group_addr(hdr->sa)) {
1988 /*
1989 * Rcvd Re/Assoc Req frame from BC/MC address Log error and
1990 * ignore it
1991 */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05301992 pe_err("Rcvd: %s Req, sessionid: %d from a BC/MC address"
1993 MAC_ADDRESS_STR,
Krunal Soni99752a12016-04-12 17:44:45 -07001994 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
1995 session->peSessionId, MAC_ADDR_ARRAY(hdr->sa));
1996 return;
1997 }
1998
Srinivas Girigowdab896a562017-03-16 17:41:26 -07001999 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
2000 (uint8_t *) frm_body, frame_len);
Krunal Soni99752a12016-04-12 17:44:45 -07002001
2002 if (false == lim_chk_sa_da(mac_ctx, hdr, session, sub_type))
2003 return;
2004
2005 if (false == lim_chk_tkip(mac_ctx, hdr, session, sub_type))
2006 return;
2007
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302008 /* check for the presence of vendor IE */
2009 if ((session->access_policy_vendor_ie) &&
2010 (session->access_policy ==
2011 LIM_ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT)) {
Abhinav Kumardb3c6f52018-06-20 15:02:00 +05302012 if (frame_len <= LIM_ASSOC_REQ_IE_OFFSET) {
2013 pe_debug("Received action frame of invalid len %d",
2014 frame_len);
2015 return;
2016 }
Naveen Rawat08db88f2017-09-08 15:07:48 -07002017 if (!wlan_get_vendor_ie_ptr_from_oui(
2018 &session->access_policy_vendor_ie[2],
2019 3, frm_body + LIM_ASSOC_REQ_IE_OFFSET,
Yeshwanth Sriram Guntuka9dea24e2018-06-14 18:44:41 +05302020 frame_len - LIM_ASSOC_REQ_IE_OFFSET)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302021 pe_err("Vendor ie not present and access policy is %x, Rejected association",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05302022 session->access_policy);
2023 lim_send_assoc_rsp_mgmt_frame(mac_ctx,
2024 eSIR_MAC_UNSPEC_FAILURE_STATUS, 1, hdr->sa,
2025 sub_type, 0, session);
2026 return;
2027 }
2028 }
Krunal Soni99752a12016-04-12 17:44:45 -07002029 /* Allocate memory for the Assoc Request frame */
2030 assoc_req = qdf_mem_malloc(sizeof(*assoc_req));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002031 if (!assoc_req)
Krunal Soni99752a12016-04-12 17:44:45 -07002032 return;
Krunal Soni99752a12016-04-12 17:44:45 -07002033
2034 /* Parse Assoc Request frame */
2035 if (false == lim_chk_assoc_req_parse_error(mac_ctx, hdr, session,
2036 assoc_req, sub_type, frm_body, frame_len))
2037 goto error;
2038
2039 assoc_req->assocReqFrame = qdf_mem_malloc(frame_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002040 if (!assoc_req->assocReqFrame)
Krunal Soni99752a12016-04-12 17:44:45 -07002041 goto error;
Krunal Soni99752a12016-04-12 17:44:45 -07002042
2043 qdf_mem_copy((uint8_t *) assoc_req->assocReqFrame,
2044 (uint8_t *) frm_body, frame_len);
2045 assoc_req->assocReqFrameLength = frame_len;
2046
2047 if (false == lim_chk_capab(mac_ctx, hdr, session, assoc_req,
2048 sub_type, &local_cap))
2049 goto error;
2050
2051 update_ctx = false;
2052
2053 if (false == lim_chk_ssid(mac_ctx, hdr, session, assoc_req, sub_type))
2054 goto error;
2055
2056 if (false == lim_chk_rates(mac_ctx, hdr, session, assoc_req, sub_type))
2057 goto error;
2058
2059 if (false == lim_chk_11g_only(mac_ctx, hdr, session, assoc_req,
2060 sub_type))
2061 goto error;
2062
2063 if (false == lim_chk_11n_only(mac_ctx, hdr, session, assoc_req,
2064 sub_type))
2065 goto error;
2066
2067 if (false == lim_chk_11ac_only(mac_ctx, hdr, session, assoc_req,
2068 sub_type))
2069 goto error;
2070
Naveen Rawat441bc872017-12-11 17:25:27 -08002071 if (false == lim_chk_11ax_only(mac_ctx, hdr, session, assoc_req,
2072 sub_type))
2073 goto error;
2074
2075 if (false == lim_check_11ax_basic_mcs(mac_ctx, hdr, session, assoc_req,
2076 sub_type))
2077 goto error;
2078
Krunal Soni99752a12016-04-12 17:44:45 -07002079 /* Spectrum Management (11h) specific checks */
2080 lim_process_for_spectrum_mgmt(mac_ctx, hdr, session,
2081 assoc_req, sub_type, local_cap);
2082
2083 if (false == lim_chk_mcs(mac_ctx, hdr, session, assoc_req, sub_type))
2084 goto error;
2085
2086 if (false == lim_chk_is_11b_sta_supported(mac_ctx, hdr, session,
2087 assoc_req, sub_type, phy_mode))
2088 goto error;
2089
2090 /*
2091 * Check for 802.11n HT caps compatibility; are HT Capabilities
2092 * turned on in lim?
2093 */
2094 lim_print_ht_cap(mac_ctx, session, assoc_req);
2095
2096 if (false == lim_chk_n_process_wpa_rsn_ie(mac_ctx, hdr, session,
2097 assoc_req, sub_type, &pmf_connection))
2098 goto error;
2099
2100 /* Extract 'associated' context for STA, if any. */
2101 sta_ds = dph_lookup_hash_entry(mac_ctx, hdr->sa, &peer_idx,
2102 &session->dph.dphHashTable);
2103
2104 /* Extract pre-auth context for the STA, if any. */
2105 sta_pre_auth_ctx = lim_search_pre_auth_list(mac_ctx, hdr->sa);
2106
2107 if (sta_ds == NULL) {
2108 if (false == lim_process_assoc_req_no_sta_ctx(mac_ctx, hdr,
2109 session, assoc_req, sub_type, sta_pre_auth_ctx,
2110 sta_ds, &auth_type))
2111 goto error;
2112 } else {
2113 if (false == lim_process_assoc_req_sta_ctx(mac_ctx, hdr,
2114 session, assoc_req, sub_type, sta_pre_auth_ctx,
2115 sta_ds, peer_idx, &auth_type, &update_ctx))
2116 goto error;
2117 goto sendIndToSme;
2118 }
2119
2120 /* check if sta is allowed per QoS AC rules */
2121 if (false == lim_chk_wmm(mac_ctx, hdr, session,
2122 assoc_req, sub_type, qos_mode))
2123 goto error;
2124
2125 /* STA is Associated ! */
Yeshwanth Sriram Guntukae7303b82018-08-10 16:45:16 +05302126 pe_debug("Received: %s Req successful from " MAC_ADDRESS_STR,
2127 (LIM_ASSOC == sub_type) ? "Assoc" : "ReAssoc",
2128 MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002129
2130 /*
2131 * AID for this association will be same as the peer Index used in DPH
2132 * table. Assign unused/least recently used peer Index from perStaDs.
2133 * NOTE: lim_assign_peer_idx() assigns AID values ranging between
2134 * 1 - cfg_item(WNI_CFG_ASSOC_STA_LIMIT)
2135 */
2136
2137 peer_idx = lim_assign_peer_idx(mac_ctx, session);
2138
2139 if (!peer_idx) {
2140 /* Could not assign AID. Reject association */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302141 pe_err("PeerIdx not avaialble. Reject associaton");
Krunal Soni99752a12016-04-12 17:44:45 -07002142 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2143 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08002144 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07002145 session);
2146 goto error;
2147 }
2148
2149 /* Add an entry to hash table maintained by DPH module */
2150
2151 sta_ds = dph_add_hash_entry(mac_ctx, hdr->sa, peer_idx,
2152 &session->dph.dphHashTable);
2153
2154 if (sta_ds == NULL) {
2155 /* Could not add hash table entry at DPH */
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302156 pe_err("couldn't add hash entry at DPH for aid: %d MacAddr:"
2157 MAC_ADDRESS_STR, peer_idx, MAC_ADDR_ARRAY(hdr->sa));
Krunal Soni99752a12016-04-12 17:44:45 -07002158
2159 /* Release AID */
2160 lim_release_peer_idx(mac_ctx, peer_idx, session);
2161
2162 lim_reject_association(mac_ctx, hdr->sa, sub_type,
2163 true, auth_type, peer_idx, false,
Varun Reddy Yeturu725185d2017-11-17 14:14:55 -08002164 eSIR_MAC_UNSPEC_FAILURE_STATUS,
Krunal Soni99752a12016-04-12 17:44:45 -07002165 session);
2166 goto error;
2167 }
2168
2169sendIndToSme:
Abhishek Singh0bc46d12017-01-09 13:05:54 +05302170 if (false == lim_update_sta_ds(mac_ctx, hdr, session, assoc_req,
Abhishek Singh61084982016-12-13 17:24:07 +05302171 sub_type, sta_ds, auth_type,
Krunal Soni99752a12016-04-12 17:44:45 -07002172 &assoc_req_copied, peer_idx, qos_mode,
2173 pmf_connection))
2174 goto error;
2175
Abhishek Singh61084982016-12-13 17:24:07 +05302176
Krunal Soni99752a12016-04-12 17:44:45 -07002177 /* BTAMP: Storing the parsed assoc request in the session array */
2178 if (session->parsedAssocReq)
2179 session->parsedAssocReq[sta_ds->assocId] = assoc_req;
2180 assoc_req_copied = true;
2181
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07002182 /* If it is duplicate entry wait till the peer is deleted */
2183 if (dup_entry != true) {
2184 if (false == lim_update_sta_ctx(mac_ctx, session, assoc_req,
Krunal Soni99752a12016-04-12 17:44:45 -07002185 sub_type, sta_ds, update_ctx))
2186 goto error;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -07002187 }
Krunal Soni99752a12016-04-12 17:44:45 -07002188
Jeff Johnson5ead5ab2018-05-06 00:11:08 -07002189 /* AddSta is success here */
Krunal Soni99752a12016-04-12 17:44:45 -07002190 if (LIM_IS_AP_ROLE(session) && IS_DOT11_MODE_HT(session->dot11mode) &&
2191 assoc_req->HTCaps.present && assoc_req->wmeInfoPresent) {
2192 /*
2193 * Update in the HAL Sta Table for the Update of the Protection
2194 * Mode
2195 */
2196 lim_post_sm_state_update(mac_ctx, sta_ds->staIndex,
2197 sta_ds->htMIMOPSState, sta_ds->staAddr,
2198 session->smeSessionId);
2199 }
2200
2201 return;
2202
2203error:
Krunal Soni99752a12016-04-12 17:44:45 -07002204 lim_process_assoc_cleanup(mac_ctx, session, assoc_req, sta_ds,
Abhishek Singh61084982016-12-13 17:24:07 +05302205 &assoc_req_copied);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 return;
Naveen Rawatada5fac2016-01-28 16:24:32 -08002207}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208
2209#ifdef FEATURE_WLAN_WAPI
2210/**
2211 * lim_fill_assoc_ind_wapi_info()- Updates WAPI data in assoc indication
2212 * @mac_ctx: Global Mac context
2213 * @assoc_req: pointer to association request
2214 * @assoc_ind: Pointer to association indication
2215 * @wpsie: WPS IE
2216 *
2217 * This function updates WAPI meta data in association indication message
2218 * sent to SME.
2219 *
2220 * Return: None
2221 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002222static void lim_fill_assoc_ind_wapi_info(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 tpSirAssocReq assoc_req, tpLimMlmAssocInd assoc_ind,
Naveen Rawat08db88f2017-09-08 15:07:48 -07002224 const uint8_t *wpsie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225{
2226 if (assoc_req->wapiPresent && (NULL == wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302227 pe_debug("Received WAPI IE length in Assoc Req is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 assoc_req->wapi.length);
2229 assoc_ind->wapiIE.wapiIEdata[0] = SIR_MAC_WAPI_EID;
2230 assoc_ind->wapiIE.wapiIEdata[1] = assoc_req->wapi.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302231 qdf_mem_copy(&assoc_ind->wapiIE.wapiIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 assoc_req->wapi.info, assoc_req->wapi.length);
2233 assoc_ind->wapiIE.length =
2234 2 + assoc_req->wapi.length;
2235 }
2236 return;
2237}
2238#endif
2239
2240/**
2241 * lim_fill_assoc_ind_vht_info() - Updates VHT information in assoc indication
2242 * @mac_ctx: Global Mac context
2243 * @assoc_req: pointer to association request
2244 * @session_entry: PE session entry
2245 * @assoc_ind: Pointer to association indication
2246 *
2247 * This function updates VHT information in association indication message
2248 * sent to SME.
2249 *
2250 * Return: None
2251 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002252static void lim_fill_assoc_ind_vht_info(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002253 struct pe_session *session_entry,
Naveen Rawat6186ff92015-10-12 14:33:53 -07002254 tpSirAssocReq assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302255 tpLimMlmAssocInd assoc_ind,
2256 tpDphHashNode sta_ds)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257{
2258 uint8_t chan;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302259 uint8_t i;
2260 bool nw_type_11b = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002262 if (session_entry->limRFBand == BAND_2G) {
Naveen Rawat6186ff92015-10-12 14:33:53 -07002263 if (session_entry->vhtCapability && assoc_req->VHTCaps.present)
Krishna Kumaar Natarajan294da812016-04-28 14:39:30 -07002264 assoc_ind->chan_info.info = MODE_11AC_VHT20_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 else if (session_entry->htCapability
Naveen Rawat6186ff92015-10-12 14:33:53 -07002266 && assoc_req->HTCaps.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 assoc_ind->chan_info.info = MODE_11NG_HT20;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302268 else {
2269 for (i = 0; i < SIR_NUM_11A_RATES; i++) {
2270 if (sirIsArate(sta_ds->
2271 supportedRates.llaRates[i]
2272 & 0x7F)) {
2273 assoc_ind->chan_info.info = MODE_11G;
2274 nw_type_11b = false;
2275 break;
2276 }
2277 }
2278 if (nw_type_11b)
2279 assoc_ind->chan_info.info = MODE_11B;
2280 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002281 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 }
Naveen Rawat6186ff92015-10-12 14:33:53 -07002283
2284 if (session_entry->vhtCapability && assoc_req->VHTCaps.present) {
2285 if ((session_entry->ch_width > CH_WIDTH_40MHZ)
2286 && assoc_req->HTCaps.supportedChannelWidthSet) {
2287 chan = session_entry->ch_center_freq_seg0;
2288 assoc_ind->chan_info.band_center_freq1 =
2289 cds_chan_to_freq(chan);
2290 assoc_ind->chan_info.info = MODE_11AC_VHT80;
2291 return;
2292 }
2293
2294 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2295 && assoc_req->HTCaps.supportedChannelWidthSet) {
2296 assoc_ind->chan_info.info = MODE_11AC_VHT40;
2297 if (session_entry->htSecondaryChannelOffset ==
2298 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2299 assoc_ind->chan_info.band_center_freq1 += 10;
2300 else
2301 assoc_ind->chan_info.band_center_freq1 -= 10;
2302 return;
2303 }
2304
2305 assoc_ind->chan_info.info = MODE_11AC_VHT20;
2306 return;
2307 }
2308
2309 if (session_entry->htCapability && assoc_req->HTCaps.present) {
2310 if ((session_entry->ch_width == CH_WIDTH_40MHZ)
2311 && assoc_req->HTCaps.supportedChannelWidthSet) {
2312 assoc_ind->chan_info.info = MODE_11NA_HT40;
2313 if (session_entry->htSecondaryChannelOffset ==
2314 PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2315 assoc_ind->chan_info.band_center_freq1 += 10;
2316 else
2317 assoc_ind->chan_info.band_center_freq1 -= 10;
2318 return;
2319 }
2320
2321 assoc_ind->chan_info.info = MODE_11NA_HT20;
2322 return;
2323 }
2324
2325 assoc_ind->chan_info.info = MODE_11A;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 return;
2327}
2328
Will Huang558f8082017-05-31 16:22:24 +08002329static uint8_t lim_get_max_rate_idx(tSirMacRateSet *rateset)
2330{
2331 uint8_t maxidx;
2332 int i;
2333
2334 maxidx = rateset->rate[0] & 0x7f;
2335 for (i = 1; i < rateset->numRates; i++) {
2336 if ((rateset->rate[i] & 0x7f) > maxidx)
2337 maxidx = rateset->rate[i] & 0x7f;
2338 }
2339
2340 return maxidx;
2341}
2342
2343static void fill_mlm_assoc_ind_vht(tpSirAssocReq assocreq,
2344 tpDphHashNode stads,
2345 tpLimMlmAssocInd assocind)
2346{
2347 if (stads->mlmStaContext.vhtCapability) {
2348 /* ampdu */
2349 assocind->ampdu = true;
2350
2351 /* sgi */
2352 if (assocreq->VHTCaps.shortGI80MHz ||
2353 assocreq->VHTCaps.shortGI160and80plus80MHz)
2354 assocind->sgi_enable = true;
2355
2356 /* stbc */
2357 assocind->tx_stbc = assocreq->VHTCaps.txSTBC;
2358 assocind->rx_stbc = assocreq->VHTCaps.rxSTBC;
2359
2360 /* ch width */
2361 assocind->ch_width = stads->vhtSupportedChannelWidthSet ?
2362 eHT_CHANNEL_WIDTH_80MHZ :
2363 stads->htSupportedChannelWidthSet ?
2364 eHT_CHANNEL_WIDTH_40MHZ : eHT_CHANNEL_WIDTH_20MHZ;
2365
2366 /* mode */
2367 assocind->mode = SIR_SME_PHY_MODE_VHT;
2368 assocind->rx_mcs_map = assocreq->VHTCaps.rxMCSMap & 0xff;
2369 assocind->tx_mcs_map = assocreq->VHTCaps.txMCSMap & 0xff;
2370 }
2371}
2372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373/**
2374 * lim_send_mlm_assoc_ind() - Sends assoc indication to SME
2375 * @mac_ctx: Global Mac context
2376 * @sta_ds: Station DPH hash entry
2377 * @session_entry: PE session entry
2378 *
2379 * This function sends either LIM_MLM_ASSOC_IND
2380 * or LIM_MLM_REASSOC_IND to SME.
2381 *
2382 * Return: None
2383 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002384void lim_send_mlm_assoc_ind(struct mac_context *mac_ctx,
Jeff Johnson5b574dd2018-11-19 06:49:34 -08002385 tpDphHashNode sta_ds, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386{
2387 tpLimMlmAssocInd assoc_ind = NULL;
2388 tpSirAssocReq assoc_req;
2389 uint16_t temp, rsn_len;
2390 uint32_t phy_mode;
2391 uint8_t sub_type;
Naveen Rawat08db88f2017-09-08 15:07:48 -07002392 const uint8_t *wpsie = NULL;
Will Huang558f8082017-05-31 16:22:24 +08002393 uint8_t maxidx, i;
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +05302394 bool wme_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302396 if (!session_entry->parsedAssocReq) {
2397 pe_err(" Parsed Assoc req is NULL");
2398 return;
2399 }
2400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401 /* Get a copy of the already parsed Assoc Request */
2402 assoc_req =
2403 (tpSirAssocReq) session_entry->parsedAssocReq[sta_ds->assocId];
2404
Pragaspathi Thilagarajaba1b5d2018-11-13 14:29:44 +05302405 if (!assoc_req) {
2406 pe_err("assoc req for assoc_id:%d is NULL", sta_ds->assocId);
2407 return;
2408 }
2409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 /* Get the phy_mode */
2411 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
2412
2413 /* Determine if its Assoc or ReAssoc Request */
2414 if (assoc_req->reassocRequest == 1)
2415 sub_type = LIM_REASSOC;
2416 else
2417 sub_type = LIM_ASSOC;
2418
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302419 pe_debug("Sessionid: %d ssid: %s sub_type: %d Associd: %d staAddr: "
2420 MAC_ADDRESS_STR, session_entry->peSessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 assoc_req->ssId.ssId, sub_type, sta_ds->assocId,
2422 MAC_ADDR_ARRAY(sta_ds->staAddr));
2423
2424 if (sub_type == LIM_ASSOC || sub_type == LIM_REASSOC) {
2425 temp = sizeof(tLimMlmAssocInd);
2426
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302427 assoc_ind = qdf_mem_malloc(temp);
Arif Hussainf5b6c412018-10-10 19:41:09 -07002428 if (!assoc_ind) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 lim_release_peer_idx(mac_ctx, sta_ds->assocId,
2430 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 return;
2432 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302433 qdf_mem_copy((uint8_t *) assoc_ind->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 (uint8_t *) sta_ds->staAddr, sizeof(tSirMacAddr));
2435 assoc_ind->aid = sta_ds->assocId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302436 qdf_mem_copy((uint8_t *) &assoc_ind->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 (uint8_t *) &(assoc_req->ssId),
2438 assoc_req->ssId.length + 1);
2439 assoc_ind->sessionId = session_entry->peSessionId;
2440 assoc_ind->authType = sta_ds->mlmStaContext.authType;
2441 assoc_ind->capabilityInfo = assoc_req->capabilityInfo;
2442
2443 /* Fill in RSN IE information */
2444 assoc_ind->rsnIE.length = 0;
2445 /* if WPS IE is present, ignore RSN IE */
2446 if (assoc_req->addIEPresent && assoc_req->addIE.length) {
2447 wpsie = limGetWscIEPtr(mac_ctx,
2448 assoc_req->addIE.addIEdata,
2449 assoc_req->addIE.length);
2450 }
2451 if (assoc_req->rsnPresent && (NULL == wpsie)) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302452 pe_debug("Assoc Req RSN IE len: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453 assoc_req->rsn.length);
2454 assoc_ind->rsnIE.length = 2 + assoc_req->rsn.length;
2455 assoc_ind->rsnIE.rsnIEdata[0] = SIR_MAC_RSN_EID;
2456 assoc_ind->rsnIE.rsnIEdata[1] =
2457 assoc_req->rsn.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302458 qdf_mem_copy(&assoc_ind->rsnIE.rsnIEdata[2],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 assoc_req->rsn.info,
2460 assoc_req->rsn.length);
2461 }
2462 /* Fill in 802.11h related info */
2463 if (assoc_req->powerCapabilityPresent
2464 && assoc_req->supportedChannelsPresent) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002465 assoc_ind->spectrumMgtIndicator = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 assoc_ind->powerCap.minTxPower =
2467 assoc_req->powerCapability.minTxPower;
2468 assoc_ind->powerCap.maxTxPower =
2469 assoc_req->powerCapability.maxTxPower;
2470 lim_convert_supported_channels(mac_ctx, assoc_ind,
2471 assoc_req);
2472 } else {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07002473 assoc_ind->spectrumMgtIndicator = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 }
2475
2476 /* This check is to avoid extra Sec IEs present incase of WPS */
2477 if (assoc_req->wpaPresent && (NULL == wpsie)) {
2478 rsn_len = assoc_ind->rsnIE.length;
2479 if ((rsn_len + assoc_req->wpa.length)
2480 >= SIR_MAC_MAX_IE_LENGTH) {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302481 pe_err("rsnIEdata index out of bounds: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 rsn_len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302483 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 return;
2485 }
2486 assoc_ind->rsnIE.rsnIEdata[rsn_len] =
2487 SIR_MAC_WPA_EID;
2488 assoc_ind->rsnIE.rsnIEdata[rsn_len + 1]
2489 = assoc_req->wpa.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302490 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 &assoc_ind->rsnIE.rsnIEdata[rsn_len + 2],
2492 assoc_req->wpa.info, assoc_req->wpa.length);
2493 assoc_ind->rsnIE.length += 2 + assoc_req->wpa.length;
2494 }
2495#ifdef FEATURE_WLAN_WAPI
2496 lim_fill_assoc_ind_wapi_info(mac_ctx, assoc_req, assoc_ind,
2497 wpsie);
2498#endif
2499
2500 assoc_ind->addIE.length = 0;
2501 if (assoc_req->addIEPresent) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302502 qdf_mem_copy(&assoc_ind->addIE.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 assoc_req->addIE.addIEdata,
2504 assoc_req->addIE.length);
2505 assoc_ind->addIE.length = assoc_req->addIE.length;
2506 }
2507 /*
2508 * Add HT Capabilities into addIE for OBSS
2509 * processing in hostapd
2510 */
2511 if (assoc_req->HTCaps.present) {
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302512 qdf_mem_copy(&assoc_ind->ht_caps, &assoc_req->HTCaps,
2513 sizeof(tDot11fIEHTCaps));
2514
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 rsn_len = assoc_ind->addIE.length;
2516 if (assoc_ind->addIE.length + DOT11F_IE_HTCAPS_MIN_LEN
2517 + 2 < SIR_MAC_MAX_IE_LENGTH) {
2518 assoc_ind->addIE.addIEdata[rsn_len] =
2519 SIR_MAC_HT_CAPABILITIES_EID;
2520 assoc_ind->addIE.addIEdata[rsn_len + 1] =
2521 DOT11F_IE_HTCAPS_MIN_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302522 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 &assoc_ind->addIE.addIEdata[rsn_len+2],
2524 ((uint8_t *)&assoc_req->HTCaps) + 1,
2525 DOT11F_IE_HTCAPS_MIN_LEN);
2526 assoc_ind->addIE.length +=
2527 2 + DOT11F_IE_HTCAPS_MIN_LEN;
2528 } else {
Nishank Aggarwal8935e442017-03-23 19:11:08 +05302529 pe_err("Fail:HT capabilities IE to addIE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 }
2531 }
2532
2533 if (assoc_req->wmeInfoPresent) {
Pragaspathi Thilagarajec7dc252018-09-06 15:38:49 +05302534 /* Set whether AP is enabled with WMM or not */
2535 wme_enable = mac_ctx->mlme_cfg->wmm_params.wme_enabled;
2536 assoc_ind->WmmStaInfoPresent = wme_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 /*
2538 * Note: we are not rejecting association here
2539 * because IOT will fail
2540 */
2541 }
2542 /* Required for indicating the frames to upper layer */
2543 assoc_ind->assocReqLength = assoc_req->assocReqFrameLength;
2544 assoc_ind->assocReqPtr = assoc_req->assocReqFrame;
2545
2546 assoc_ind->beaconPtr = session_entry->beacon;
2547 assoc_ind->beaconLength = session_entry->bcnLen;
2548
2549 assoc_ind->chan_info.chan_id =
2550 session_entry->currentOperChannel;
2551 assoc_ind->chan_info.mhz =
2552 cds_chan_to_freq(session_entry->currentOperChannel);
2553 assoc_ind->chan_info.band_center_freq1 =
2554 cds_chan_to_freq(session_entry->currentOperChannel);
2555 assoc_ind->chan_info.band_center_freq2 = 0;
2556 assoc_ind->chan_info.reg_info_1 =
2557 (session_entry->maxTxPower << 16);
2558 assoc_ind->chan_info.reg_info_2 =
2559 (session_entry->maxTxPower << 8);
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05302560 assoc_ind->chan_info.nss = sta_ds->nss;
2561 assoc_ind->chan_info.rate_flags =
2562 lim_get_max_rate_flags(mac_ctx, sta_ds);
Will Huang558f8082017-05-31 16:22:24 +08002563 assoc_ind->ampdu = false;
2564 assoc_ind->sgi_enable = false;
2565 assoc_ind->tx_stbc = false;
2566 assoc_ind->rx_stbc = false;
2567 assoc_ind->ch_width = eHT_CHANNEL_WIDTH_20MHZ;
2568 assoc_ind->mode = SIR_SME_PHY_MODE_LEGACY;
2569 assoc_ind->max_supp_idx = 0xff;
2570 assoc_ind->max_ext_idx = 0xff;
2571 assoc_ind->max_mcs_idx = 0xff;
2572 assoc_ind->rx_mcs_map = 0xff;
2573 assoc_ind->tx_mcs_map = 0xff;
2574
2575 if (assoc_req->supportedRates.numRates)
2576 assoc_ind->max_supp_idx =
2577 lim_get_max_rate_idx(
2578 &assoc_req->supportedRates);
2579 if (assoc_req->extendedRates.numRates)
2580 assoc_ind->max_ext_idx =
2581 lim_get_max_rate_idx(
2582 &assoc_req->extendedRates);
2583
2584 if (sta_ds->mlmStaContext.htCapability) {
2585 /* ampdu */
2586 assoc_ind->ampdu = true;
2587
2588 /* sgi */
2589 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
2590 assoc_ind->sgi_enable = true;
2591
2592 /* stbc */
2593 assoc_ind->tx_stbc = assoc_req->HTCaps.txSTBC;
2594 assoc_ind->rx_stbc = assoc_req->HTCaps.rxSTBC;
2595
2596 /* ch width */
2597 assoc_ind->ch_width =
2598 sta_ds->htSupportedChannelWidthSet ?
2599 eHT_CHANNEL_WIDTH_40MHZ :
2600 eHT_CHANNEL_WIDTH_20MHZ;
2601
2602 /* mode */
2603 assoc_ind->mode = SIR_SME_PHY_MODE_HT;
2604 maxidx = 0;
2605 for (i = 0; i < 8; i++) {
2606 if (assoc_req->HTCaps.supportedMCSSet[0] &
2607 (1 << i))
2608 maxidx = i;
2609 }
2610 assoc_ind->max_mcs_idx = maxidx;
2611 }
2612 fill_mlm_assoc_ind_vht(assoc_req, sta_ds, assoc_ind);
gaolez7bb1e742017-03-21 16:37:38 +08002613 if (assoc_req->ExtCap.present)
2614 assoc_ind->ecsa_capable =
2615 ((struct s_ext_cap *)assoc_req->ExtCap.bytes)->
2616 ext_chan_switch;
Will Huang558f8082017-05-31 16:22:24 +08002617
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 /* updates VHT information in assoc indication */
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302619 qdf_mem_copy(&assoc_ind->vht_caps, &assoc_req->VHTCaps,
2620 sizeof(tDot11fIEVHTCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 lim_fill_assoc_ind_vht_info(mac_ctx, session_entry, assoc_req,
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05302622 assoc_ind, sta_ds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 lim_post_sme_message(mac_ctx, LIM_MLM_ASSOC_IND,
2624 (uint32_t *) assoc_ind);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302625 qdf_mem_free(assoc_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 }
2627 return;
2628}