blob: 0f315a6a81dc9e7e0e1d729b383f642e91586cee [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05302 * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**=========================================================================
20
21 \file rrm_api.c
22
23 \brief implementation for PE RRM APIs
24
25 ========================================================================*/
26
27/* $Header$ */
28
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080029
30/*--------------------------------------------------------------------------
31 Include Files
32 ------------------------------------------------------------------------*/
33#include "cds_api.h"
34#include "wni_api.h"
35#include "sir_api.h"
36#include "ani_global.h"
37#include "wni_cfg.h"
38#include "lim_types.h"
39#include "lim_utils.h"
40#include "lim_send_sme_rsp_messages.h"
41#include "parser_api.h"
42#include "lim_send_messages.h"
43#include "rrm_global.h"
44#include "rrm_api.h"
45
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046/* -------------------------------------------------------------------- */
47/**
48 * rrm_cache_mgmt_tx_power
49 **
50 * FUNCTION: Store Tx power for management frames.
51 *
52 * LOGIC:
53 *
54 * ASSUMPTIONS:
55 *
56 * NOTE:
57 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -080058 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059 * @return None
60 */
61void
Jeff Johnsonb228e0a2018-12-02 12:27:26 -080062rrm_cache_mgmt_tx_power(struct mac_context *mac, int8_t txPower,
Jeff Johnsonb5c13332018-12-03 09:54:51 -080063 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064{
Srinivas Girigowda19b944f2017-03-26 16:22:22 -070065 pe_debug("Cache Mgmt Tx Power: %d", txPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Jeff Johnson8e9530b2019-03-18 13:41:42 -070067 if (!pe_session)
Jeff Johnson86a9a352018-11-22 14:08:32 -080068 mac->rrm.rrmPEContext.txMgmtPower = txPower;
Srinivas Girigowda19b944f2017-03-26 16:22:22 -070069 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -080070 pe_session->txMgmtPower = txPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071}
72
73/* -------------------------------------------------------------------- */
74/**
75 * rrm_get_mgmt_tx_power
76 *
77 * FUNCTION: Get the Tx power for management frames.
78 *
79 * LOGIC:
80 *
81 * ASSUMPTIONS:
82 *
83 * NOTE:
84 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -080085 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 * @return txPower
87 */
Jeff Johnsonb228e0a2018-12-02 12:27:26 -080088int8_t rrm_get_mgmt_tx_power(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080089{
Jeff Johnson8e9530b2019-03-18 13:41:42 -070090 if (!pe_session)
Jeff Johnson86a9a352018-11-22 14:08:32 -080091 return mac->rrm.rrmPEContext.txMgmtPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092
Jeff Johnsonb5c13332018-12-03 09:54:51 -080093 pe_debug("tx mgmt pwr %d", pe_session->txMgmtPower);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +053094
Jeff Johnsonb5c13332018-12-03 09:54:51 -080095 return pe_session->txMgmtPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096}
97
98/* -------------------------------------------------------------------- */
99/**
100 * rrm_send_set_max_tx_power_req
101 *
102 * FUNCTION: Send WMA_SET_MAX_TX_POWER_REQ message to change the max tx power.
103 *
104 * LOGIC:
105 *
106 * ASSUMPTIONS:
107 *
108 * NOTE:
109 *
110 * @param txPower txPower to be set.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800111 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112 * @return None
113 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700114QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800115rrm_send_set_max_tx_power_req(struct mac_context *mac, int8_t txPower,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800116 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117{
118 tpMaxTxPowerParams pMaxTxParams;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700119 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700120 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700122 if (!pe_session) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700123 pe_err("Invalid parameters");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700124 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530126 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700127 if (!pMaxTxParams)
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700128 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129 /* Allocated memory for pMaxTxParams...will be freed in other module */
130 pMaxTxParams->power = txPower;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800131 qdf_mem_copy(pMaxTxParams->bssId.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530132 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530133 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Pragaspathi Thilagaraj7fb14222019-06-17 23:26:58 +0530134 pe_session->self_mac_addr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530135 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136
137 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
138 msgQ.reserved = 0;
139 msgQ.bodyptr = pMaxTxParams;
140 msgQ.bodyval = 0;
141
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700142 pe_debug("Sending WMA_SET_MAX_TX_POWER_REQ with power(%d) to HAL",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 txPower);
144
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800145 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, msgQ.type));
Jeff Johnson86a9a352018-11-22 14:08:32 -0800146 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700147 if (QDF_STATUS_SUCCESS != retCode) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700148 pe_err("Posting WMA_SET_MAX_TX_POWER_REQ to HAL failed, reason=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530150 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 return retCode;
152 }
153 return retCode;
154}
155
156/* -------------------------------------------------------------------- */
157/**
158 * rrm_set_max_tx_power_rsp
159 *
160 * FUNCTION: Process WMA_SET_MAX_TX_POWER_RSP message.
161 *
162 * LOGIC:
163 *
164 * ASSUMPTIONS:
165 *
166 * NOTE:
167 *
168 * @param txPower txPower to be set.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800169 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 * @return None
171 */
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800172QDF_STATUS rrm_set_max_tx_power_rsp(struct mac_context *mac,
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700173 struct scheduler_msg *limMsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174{
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700175 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 tpMaxTxPowerParams pMaxTxParams = (tpMaxTxPowerParams) limMsgQ->bodyptr;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800177 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 uint8_t sessionId, i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179
Anurag Chouhanc5548422016-02-24 18:33:27 +0530180 if (qdf_is_macaddr_broadcast(&pMaxTxParams->bssId)) {
Jeff Johnson86a9a352018-11-22 14:08:32 -0800181 for (i = 0; i < mac->lim.maxBssId; i++) {
182 if (mac->lim.gpSession[i].valid == true) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800183 pe_session = &mac->lim.gpSession[i];
Jeff Johnson86a9a352018-11-22 14:08:32 -0800184 rrm_cache_mgmt_tx_power(mac, pMaxTxParams->power,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800185 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 }
187 }
188 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800189 pe_session = pe_find_session_by_bssid(mac,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530190 pMaxTxParams->bssId.bytes,
191 &sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700192 if (!pe_session) {
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700193 retCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194 } else {
Jeff Johnson86a9a352018-11-22 14:08:32 -0800195 rrm_cache_mgmt_tx_power(mac, pMaxTxParams->power,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800196 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 }
198 }
199
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530200 qdf_mem_free(limMsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 limMsgQ->bodyptr = NULL;
202 return retCode;
203}
204
205/* -------------------------------------------------------------------- */
206/**
207 * rrm_process_link_measurement_request
208 *
209 * FUNCTION: Processes the Link measurement request and send the report.
210 *
211 * LOGIC:
212 *
213 * ASSUMPTIONS:
214 *
215 * NOTE:
216 *
217 * @param pBd pointer to BD to extract RSSI and SNR
218 * @param pLinkReq pointer to the Link request frame structure.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800219 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 * @return None
221 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700222QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800223rrm_process_link_measurement_request(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 uint8_t *pRxPacketInfo,
225 tDot11fLinkMeasurementRequest *pLinkReq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800226 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227{
228 tSirMacLinkReport LinkReport;
229 tpSirMacMgmtHdr pHdr;
230 int8_t currentRSSI = 0;
Rajeev Kumar Sirasanagandla1a21bf62019-04-08 15:28:57 +0530231 struct lim_max_tx_pwr_attr tx_pwr_attr = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700233 pe_debug("Received Link measurement request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700235 if (!pRxPacketInfo || !pLinkReq || !pe_session) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700236 pe_err("Invalid parameters - Ignoring the request");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700237 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 }
239 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
240
Rajeev Kumar Sirasanagandla1a21bf62019-04-08 15:28:57 +0530241 tx_pwr_attr.reg_max = pe_session->def_max_tx_pwr;
242 tx_pwr_attr.ap_tx_power = pLinkReq->MaxTxPower.maxTxPower;
243 tx_pwr_attr.ini_tx_power = mac->mlme_cfg->power.max_tx_power;
244
245 LinkReport.txPower = lim_get_max_tx_power(mac, &tx_pwr_attr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800247 if ((LinkReport.txPower != (uint8_t) (pe_session->maxTxPower)) &&
Jeff Johnson86a9a352018-11-22 14:08:32 -0800248 (QDF_STATUS_SUCCESS == rrm_send_set_max_tx_power_req(mac,
Amar Singhala297bfa2015-10-15 15:07:29 -0700249 LinkReport.txPower,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800250 pe_session))) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700251 pe_warn("maxTx power in link report is not same as local..."
252 " Local: %d Link Request TxPower: %d"
253 " Link Report TxPower: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800254 pe_session->maxTxPower, LinkReport.txPower,
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700255 pLinkReq->MaxTxPower.maxTxPower);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800256 pe_session->maxTxPower =
Amar Singhala297bfa2015-10-15 15:07:29 -0700257 LinkReport.txPower;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 }
259
260 LinkReport.dialogToken = pLinkReq->DialogToken.token;
261 LinkReport.rxAntenna = 0;
262 LinkReport.txAntenna = 0;
Deepak Dhamdhere68929ec2015-08-05 15:16:35 -0700263 currentRSSI = WMA_GET_RX_RSSI_RAW(pRxPacketInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700265 pe_info("Received Link report frame with %d", currentRSSI);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266
267 /* 2008 11k spec reference: 18.4.8.5 RCPI Measurement */
268 if ((currentRSSI) <= RCPI_LOW_RSSI_VALUE)
269 LinkReport.rcpi = 0;
270 else if ((currentRSSI > RCPI_LOW_RSSI_VALUE) && (currentRSSI <= 0))
271 LinkReport.rcpi = CALCULATE_RCPI(currentRSSI);
272 else
273 LinkReport.rcpi = RCPI_MAX_VALUE;
274
275 LinkReport.rsni = WMA_GET_RX_SNR(pRxPacketInfo);
276
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700277 pe_debug("Sending Link report frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278
Jeff Johnson86a9a352018-11-22 14:08:32 -0800279 return lim_send_link_report_action_frame(mac, &LinkReport, pHdr->sa,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800280 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281}
282
283/* -------------------------------------------------------------------- */
284/**
285 * rrm_process_neighbor_report_response
286 *
287 * FUNCTION: Processes the Neighbor Report response from the peer AP.
288 *
289 * LOGIC:
290 *
291 * ASSUMPTIONS:
292 *
293 * NOTE:
294 *
295 * @param pNeighborRep pointer to the Neighbor report frame structure.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800296 * @param pe_session session entry.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 * @return None
298 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700299QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800300rrm_process_neighbor_report_response(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 tDot11fNeighborReportResponse *pNeighborRep,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800302 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303{
Harprit Chhabadae20b5562019-03-11 14:13:42 -0700304 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 tpSirNeighborReportInd pSmeNeighborRpt = NULL;
306 uint16_t length;
307 uint8_t i;
Rajeev Kumarcf7bd802017-04-18 11:11:42 -0700308 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700310 if (!pNeighborRep || !pe_session) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700311 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 return status;
313 }
314
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700315 pe_debug("Neighbor report response received");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316
317 /* Dialog token */
Jeff Johnson86a9a352018-11-22 14:08:32 -0800318 if (mac->rrm.rrmPEContext.DialogToken !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 pNeighborRep->DialogToken.token) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700320 pe_err("Dialog token mismatch in the received Neighbor report");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700321 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 }
323 if (pNeighborRep->num_NeighborReport == 0) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700324 pe_err("No neighbor report in the frame...Dropping it");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700325 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 }
Varun Reddy Yeturu151376c2017-08-30 14:19:10 -0700327 pe_debug("RRM:received num neighbor reports: %d",
328 pNeighborRep->num_NeighborReport);
329 if (pNeighborRep->num_NeighborReport > MAX_SUPPORTED_NEIGHBOR_RPT)
330 pNeighborRep->num_NeighborReport = MAX_SUPPORTED_NEIGHBOR_RPT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 length = (sizeof(tSirNeighborReportInd)) +
332 (sizeof(tSirNeighborBssDescription) *
333 (pNeighborRep->num_NeighborReport - 1));
334
335 /* Prepare the request to send to SME. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530336 pSmeNeighborRpt = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700337 if (!pSmeNeighborRpt)
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700338 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339
340 /* Allocated memory for pSmeNeighborRpt...will be freed by other module */
341
342 for (i = 0; i < pNeighborRep->num_NeighborReport; i++) {
343 pSmeNeighborRpt->sNeighborBssDescription[i].length = sizeof(tSirNeighborBssDescription); /*+ any optional ies */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530344 qdf_mem_copy(pSmeNeighborRpt->sNeighborBssDescription[i].bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 pNeighborRep->NeighborReport[i].bssid,
346 sizeof(tSirMacAddr));
347 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
348 fApPreauthReachable =
349 pNeighborRep->NeighborReport[i].APReachability;
350 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
351 fSameSecurityMode =
352 pNeighborRep->NeighborReport[i].Security;
353 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
354 fSameAuthenticator =
355 pNeighborRep->NeighborReport[i].KeyScope;
356 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
357 fCapSpectrumMeasurement =
358 pNeighborRep->NeighborReport[i].SpecMgmtCap;
359 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
360 fCapQos = pNeighborRep->NeighborReport[i].QosCap;
361 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
362 fCapApsd = pNeighborRep->NeighborReport[i].apsd;
363 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
364 fCapRadioMeasurement = pNeighborRep->NeighborReport[i].rrm;
365 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
366 fCapDelayedBlockAck =
367 pNeighborRep->NeighborReport[i].DelayedBA;
368 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
369 fCapImmediateBlockAck =
370 pNeighborRep->NeighborReport[i].ImmBA;
371 pSmeNeighborRpt->sNeighborBssDescription[i].bssidInfo.rrmInfo.
372 fMobilityDomain =
373 pNeighborRep->NeighborReport[i].MobilityDomain;
374
Amar Singhal999bd8a2019-10-25 12:04:33 -0700375 if (!wlan_reg_is_6ghz_supported(mac->pdev) &&
376 (wlan_reg_is_6ghz_op_class(mac->pdev,
377 pNeighborRep->NeighborReport[i].
378 regulatoryClass))) {
379 pe_err("channel belongs to 6 ghz spectrum, abort");
380 qdf_mem_free(pSmeNeighborRpt);
381 return QDF_STATUS_E_FAILURE;
382 }
383
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 pSmeNeighborRpt->sNeighborBssDescription[i].regClass =
385 pNeighborRep->NeighborReport[i].regulatoryClass;
386 pSmeNeighborRpt->sNeighborBssDescription[i].channel =
387 pNeighborRep->NeighborReport[i].channel;
388 pSmeNeighborRpt->sNeighborBssDescription[i].phyType =
389 pNeighborRep->NeighborReport[i].PhyType;
390 }
391
392 pSmeNeighborRpt->messageType = eWNI_SME_NEIGHBOR_REPORT_IND;
393 pSmeNeighborRpt->length = length;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800394 pSmeNeighborRpt->sessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 pSmeNeighborRpt->numNeighborReports = pNeighborRep->num_NeighborReport;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800396 qdf_mem_copy(pSmeNeighborRpt->bssId, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 sizeof(tSirMacAddr));
398
399 /* Send request to SME. */
400 mmhMsg.type = pSmeNeighborRpt->messageType;
401 mmhMsg.bodyptr = pSmeNeighborRpt;
Jeff Johnson86a9a352018-11-22 14:08:32 -0800402 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800403 pe_session->peSessionId, mmhMsg.type));
Harprit Chhabadae20b5562019-03-11 14:13:42 -0700404 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405
406 return status;
407
408}
409
410/* -------------------------------------------------------------------- */
411/**
412 * rrm_process_neighbor_report_req
413 *
414 * FUNCTION:
415 *
416 * LOGIC: Create a Neighbor report request and send it to peer.
417 *
418 * ASSUMPTIONS:
419 *
420 * NOTE:
421 *
422 * @param pNeighborReq Neighbor report request params .
423 * @return None
424 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700425QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800426rrm_process_neighbor_report_req(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 tpSirNeighborReportReqInd pNeighborReq)
428{
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700429 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 tSirMacNeighborReportReq NeighborReportReq;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800431 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 uint8_t sessionId;
433
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700434 if (!pNeighborReq) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700435 pe_err("NeighborReq is NULL");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700436 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800438 pe_session = pe_find_session_by_bssid(mac, pNeighborReq->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530439 &sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700440 if (!pe_session) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700441 pe_err("session does not exist for given bssId");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700442 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 }
444
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700445 pe_debug("SSID present: %d", pNeighborReq->noSSID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446
hangtian127c9532019-01-12 13:29:07 +0800447 qdf_mem_zero(&NeighborReportReq, sizeof(tSirMacNeighborReportReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448
Jeff Johnson86a9a352018-11-22 14:08:32 -0800449 NeighborReportReq.dialogToken = ++mac->rrm.rrmPEContext.DialogToken;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 NeighborReportReq.ssid_present = !pNeighborReq->noSSID;
451 if (NeighborReportReq.ssid_present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530452 qdf_mem_copy(&NeighborReportReq.ssid, &pNeighborReq->ucSSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 sizeof(tSirMacSSid));
Srinivas Girigowdab896a562017-03-16 17:41:26 -0700454 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE,
455 QDF_TRACE_LEVEL_DEBUG,
456 (uint8_t *) NeighborReportReq.ssid.ssId,
457 NeighborReportReq.ssid.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 }
459
460 status =
Jeff Johnson86a9a352018-11-22 14:08:32 -0800461 lim_send_neighbor_report_request_frame(mac, &NeighborReportReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 pNeighborReq->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800463 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464
465 return status;
466}
467
468#define ABS(x) ((x < 0) ? -x : x)
sheenam monga26165ab2020-02-23 05:25:01 +0530469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470/**
sheenam monga26165ab2020-02-23 05:25:01 +0530471 * rrm_process_beacon_report_req: Processes the Beacon report request
472 * from the peer AP.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 *
sheenam monga26165ab2020-02-23 05:25:01 +0530474 * @pCurrentReq: pointer to the current Req comtext.
475 * @pBeaconReq: pointer to the beacon report request IE from the peer.
476 * @pe_session: session entry.
477 * @error_code: pointer to beacon report error_code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 *
sheenam monga26165ab2020-02-23 05:25:01 +0530479 * @return : eRRM status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 */
481static tRrmRetStatus
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800482rrm_process_beacon_report_req(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 tpRRMReq pCurrentReq,
484 tDot11fIEMeasurementRequest *pBeaconReq,
sheenam monga26165ab2020-02-23 05:25:01 +0530485 struct pe_session *pe_session,
486 enum beacon_report_status_code *error_code)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487{
Will Huang2f114542019-10-31 17:35:29 +0800488 struct scheduler_msg mmh_msg = {0};
489 tpSirBeaconReportReqInd psbrr;
490 uint8_t num_rpt, idx_rpt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491 uint16_t measDuration, maxMeasduration;
492 int8_t maxDuration;
493 uint8_t sign;
Will Huang2f114542019-10-31 17:35:29 +0800494 tDot11fIEAPChannelReport *ie_ap_chan_rpt;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530495 uint8_t tmp_idx, buf_left, buf_cons;
Will Huang2f114542019-10-31 17:35:29 +0800496 uint16_t ch_ctr = 0;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530497 char req_ssid[WLAN_SSID_MAX_LEN] = {0};
498 char ch_buf[RRM_CH_BUF_LEN];
499 char *tmp_buf = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500
501 if (pBeaconReq->measurement_request.Beacon.BeaconReporting.present &&
502 (pBeaconReq->measurement_request.Beacon.BeaconReporting.
503 reportingCondition != 0)) {
504 /* Repeated measurement is not supported. This means number of repetitions should be zero.(Already checked) */
505 /* All test case in VoWifi(as of version 0.36) use zero for number of repetitions. */
506 /* Beacon reporting should not be included in request if number of repetitons is zero. */
507 /* IEEE Std 802.11k-2008 Table 7-29g and section 11.10.8.1 */
508
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530509 pe_nofl_err("RX: [802.11 BCN_RPT] Dropping req: Reporting condition included is not zero");
sheenam monga26165ab2020-02-23 05:25:01 +0530510 *error_code = BCN_RPT_ERR_NOT_SUPPORTED_PARAMETERS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 return eRRM_INCAPABLE;
512 }
513
514 /* The logic here is to check the measurement duration passed in the beacon request. Following are the cases handled.
515 Case 1: If measurement duration received in the beacon request is greater than the max measurement duration advertised
516 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 1, REFUSE the beacon request
517 Case 2: If measurement duration received in the beacon request is greater than the max measurement duration advertised
518 in the RRM capabilities(Assoc Req), and Duration Mandatory bit is set to 0, perform measurement for
519 the duration advertised in the RRM capabilities
520
521 maxMeasurementDuration = 2^(nonOperatingChanMax - 4) * BeaconInterval
522 */
523 maxDuration =
Jeff Johnson86a9a352018-11-22 14:08:32 -0800524 mac->rrm.rrmPEContext.rrmEnabledCaps.nonOperatingChanMax - 4;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 sign = (maxDuration < 0) ? 1 : 0;
526 maxDuration = (1L << ABS(maxDuration));
527 if (!sign)
528 maxMeasduration =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800529 maxDuration * pe_session->beaconParams.beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 else
531 maxMeasduration =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800532 pe_session->beaconParams.beaconInterval / maxDuration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533
534 measDuration = pBeaconReq->measurement_request.Beacon.meas_duration;
535
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530536 if (pBeaconReq->measurement_request.Beacon.SSID.present)
537 qdf_snprintf(req_ssid, WLAN_SSID_MAX_LEN, "%s",
538 pBeaconReq->measurement_request.Beacon.SSID.ssid);
539
sheenam monga724306f2020-02-08 14:59:35 +0530540 pe_nofl_info("RX: [802.11 BCN_RPT] SSID:%s BSSID:%pM Token:%d op_class:%d ch:%d meas_mode:%d meas_duration:%d max_dur: %d sign: %d max_meas_dur: %d",
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530541 req_ssid, pBeaconReq->measurement_request.Beacon.BSSID,
542 pBeaconReq->measurement_token,
543 pBeaconReq->measurement_request.Beacon.regClass,
544 pBeaconReq->measurement_request.Beacon.channel,
545 pBeaconReq->measurement_request.Beacon.meas_mode,
sheenam monga724306f2020-02-08 14:59:35 +0530546 measDuration, maxDuration, sign, maxMeasduration);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547
Manikandan Mohanf70120a2019-06-28 13:11:53 -0700548 if (measDuration == 0 &&
549 pBeaconReq->measurement_request.Beacon.meas_mode !=
550 eSIR_BEACON_TABLE) {
sheenam monga26165ab2020-02-23 05:25:01 +0530551 *error_code = BCN_RPT_ERR_VALIDATION_FAILED_IN_A_REQUEST_FRAME;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530552 pe_nofl_err("RX: [802.11 BCN_RPT] Invalid measurement duration");
Manikandan Mohanf70120a2019-06-28 13:11:53 -0700553 return eRRM_REFUSED;
554 }
555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 if (maxMeasduration < measDuration) {
557 if (pBeaconReq->durationMandatory) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530558 pe_nofl_err("RX: [802.11 BCN_RPT] Dropping the req: duration mandatory & maxduration > measduration");
sheenam monga26165ab2020-02-23 05:25:01 +0530559 *error_code =
560 BCN_RPT_ERR_MAXIMUM_MEASUREMENT_DURATION_EXCCEED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 return eRRM_REFUSED;
562 } else
563 measDuration = maxMeasduration;
564 }
565 /* Cache the data required for sending report. */
566 pCurrentReq->request.Beacon.reportingDetail =
567 pBeaconReq->measurement_request.Beacon.BcnReportingDetail.
568 present ? pBeaconReq->measurement_request.Beacon.BcnReportingDetail.
569 reportingDetail : BEACON_REPORTING_DETAIL_ALL_FF_IE;
570
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +0530571 if (pBeaconReq->measurement_request.Beacon.
572 last_beacon_report_indication.present) {
573 pCurrentReq->request.Beacon.last_beacon_report_indication =
574 pBeaconReq->measurement_request.Beacon.
575 last_beacon_report_indication.last_fragment;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530576 pe_debug("RX: [802.11 BCN_RPT] Last Bcn Report in the req: %d",
577 pCurrentReq->request.Beacon.last_beacon_report_indication);
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +0530578 } else {
579 pCurrentReq->request.Beacon.last_beacon_report_indication = 0;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530580 pe_debug("RX: [802.11 BCN_RPT] Last Bcn rpt ind not present");
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +0530581 }
582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 if (pBeaconReq->measurement_request.Beacon.RequestedInfo.present) {
Pragaspathi Thilagarajd54655f2019-11-21 18:42:30 +0530584 if (!pBeaconReq->measurement_request.Beacon.RequestedInfo.
585 num_requested_eids) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530586 pe_debug("RX: [802.11 BCN_RPT]: Requested num of EID is 0");
sheenam monga26165ab2020-02-23 05:25:01 +0530587 *error_code =
588 BCN_RPT_ERR_VALIDATION_FAILED_IN_A_REQUEST_FRAME;
Pragaspathi Thilagarajd54655f2019-11-21 18:42:30 +0530589 return eRRM_FAILURE;
590 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 pCurrentReq->request.Beacon.reqIes.pElementIds =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_malloc(sizeof(uint8_t) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 pBeaconReq->measurement_request.Beacon.
594 RequestedInfo.num_requested_eids);
sheenam monga26165ab2020-02-23 05:25:01 +0530595 if (!pCurrentReq->request.Beacon.reqIes.pElementIds) {
596 *error_code = BCN_RPT_ERR_TEMPORARILY_UNAVAILABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 return eRRM_FAILURE;
sheenam monga26165ab2020-02-23 05:25:01 +0530598 }
Pragaspathi Thilagarajd54655f2019-11-21 18:42:30 +0530599
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 pCurrentReq->request.Beacon.reqIes.num =
601 pBeaconReq->measurement_request.Beacon.RequestedInfo.
602 num_requested_eids;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530603 qdf_mem_copy(pCurrentReq->request.Beacon.reqIes.pElementIds,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 pBeaconReq->measurement_request.Beacon.
605 RequestedInfo.requested_eids,
606 pCurrentReq->request.Beacon.reqIes.num);
607 }
608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 /* Prepare the request to send to SME. */
Will Huang2f114542019-10-31 17:35:29 +0800610 psbrr = qdf_mem_malloc(sizeof(tSirBeaconReportReqInd));
sheenam monga26165ab2020-02-23 05:25:01 +0530611 if (!psbrr) {
612 *error_code = BCN_RPT_ERR_TEMPORARILY_UNAVAILABLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 return eRRM_FAILURE;
sheenam monga26165ab2020-02-23 05:25:01 +0530614 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615
Lin Bai7bae1032019-04-30 12:29:36 +0800616 /* Alloc memory for pSmeBcnReportReq, will be freed by other modules */
Will Huang2f114542019-10-31 17:35:29 +0800617 qdf_mem_copy(psbrr->bssId, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 sizeof(tSirMacAddr));
Will Huang2f114542019-10-31 17:35:29 +0800619 psbrr->messageType = eWNI_SME_BEACON_REPORT_REQ_IND;
620 psbrr->length = sizeof(tSirBeaconReportReqInd);
621 psbrr->uDialogToken = pBeaconReq->measurement_token;
622 psbrr->msgSource = eRRM_MSG_SOURCE_11K;
623 psbrr->randomizationInterval =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 SYS_TU_TO_MS(pBeaconReq->measurement_request.Beacon.randomization);
Amar Singhal999bd8a2019-10-25 12:04:33 -0700625
626 if (!wlan_reg_is_6ghz_supported(mac->pdev) &&
627 (wlan_reg_is_6ghz_op_class(mac->pdev,
628 pBeaconReq->measurement_request.Beacon.regClass))) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530629 pe_nofl_err("RX: [802.11 BCN_RPT] Ch belongs to 6 ghz spectrum, abort");
sheenam monga26165ab2020-02-23 05:25:01 +0530630 *error_code = BCN_RPT_ERR_NOT_SUPPORTED_PARAMETERS;
Amar Singhal999bd8a2019-10-25 12:04:33 -0700631 qdf_mem_free(psbrr);
632 return eRRM_FAILURE;
633 }
634
Will Huang2f114542019-10-31 17:35:29 +0800635 psbrr->channel_info.chan_num =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 pBeaconReq->measurement_request.Beacon.channel;
Amar Singhal999bd8a2019-10-25 12:04:33 -0700637 psbrr->channel_info.reg_class =
638 pBeaconReq->measurement_request.Beacon.regClass;
Will Huang2f114542019-10-31 17:35:29 +0800639 psbrr->channel_info.chan_freq =
640 wlan_reg_chan_opclass_to_freq(psbrr->channel_info.chan_num,
641 psbrr->channel_info.reg_class,
642 false);
643 psbrr->measurementDuration[0] = measDuration;
644 psbrr->fMeasurementtype[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 pBeaconReq->measurement_request.Beacon.meas_mode;
Will Huang2f114542019-10-31 17:35:29 +0800646 qdf_mem_copy(psbrr->macaddrBssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 pBeaconReq->measurement_request.Beacon.BSSID,
648 sizeof(tSirMacAddr));
649
650 if (pBeaconReq->measurement_request.Beacon.SSID.present) {
Will Huang2f114542019-10-31 17:35:29 +0800651 psbrr->ssId.length =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 pBeaconReq->measurement_request.Beacon.SSID.num_ssid;
Will Huang2f114542019-10-31 17:35:29 +0800653 qdf_mem_copy(psbrr->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 pBeaconReq->measurement_request.Beacon.SSID.ssid,
Will Huang2f114542019-10-31 17:35:29 +0800655 psbrr->ssId.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 }
657
658 pCurrentReq->token = pBeaconReq->measurement_token;
659
Will Huang2f114542019-10-31 17:35:29 +0800660 num_rpt = pBeaconReq->measurement_request.Beacon.num_APChannelReport;
Will Huang2f114542019-10-31 17:35:29 +0800661 for (idx_rpt = 0; idx_rpt < num_rpt; idx_rpt++) {
662 ie_ap_chan_rpt =
663 &pBeaconReq->measurement_request.Beacon.APChannelReport[idx_rpt];
664 for (tmp_idx = 0;
665 tmp_idx < ie_ap_chan_rpt->num_channelList;
666 tmp_idx++) {
Amar Singhal999bd8a2019-10-25 12:04:33 -0700667 if (!wlan_reg_is_6ghz_supported(mac->pdev) &&
668 (wlan_reg_is_6ghz_op_class(mac->pdev,
669 ie_ap_chan_rpt->regulatoryClass))) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530670 pe_nofl_err("RX: [802.11 BCN_RPT] Ch belongs to 6 ghz spectrum, abort");
sheenam monga26165ab2020-02-23 05:25:01 +0530671 *error_code =
672 BCN_RPT_ERR_NOT_SUPPORTED_PARAMETERS;
Amar Singhal999bd8a2019-10-25 12:04:33 -0700673 qdf_mem_free(psbrr);
674 return eRRM_FAILURE;
675 }
676
Will Huang2f114542019-10-31 17:35:29 +0800677 psbrr->channel_list.chan_freq_lst[ch_ctr++] =
678 wlan_reg_chan_opclass_to_freq(
679 ie_ap_chan_rpt->channelList[tmp_idx],
680 ie_ap_chan_rpt->regulatoryClass,
681 false);
682 if (ch_ctr >= QDF_ARRAY_SIZE(psbrr->channel_list.chan_freq_lst))
Naveen Rawatd85a3902017-06-19 11:57:31 -0700683 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 }
Will Huang2f114542019-10-31 17:35:29 +0800685 if (ch_ctr >= QDF_ARRAY_SIZE(psbrr->channel_list.chan_freq_lst))
686 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 }
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530688
Will Huang2f114542019-10-31 17:35:29 +0800689 psbrr->channel_list.num_channels = ch_ctr;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530690 buf_left = sizeof(ch_buf);
691 tmp_buf = ch_buf;
692 for (idx_rpt = 0; idx_rpt < ch_ctr; idx_rpt++) {
693 buf_cons = qdf_snprint(tmp_buf, buf_left, "%d ",
694 psbrr->channel_list.chan_freq_lst[idx_rpt]);
695 buf_left -= buf_cons;
696 tmp_buf += buf_cons;
697 }
698
699 if (ch_ctr)
700 pe_nofl_info("RX: [802.11 BCN_RPT] Ch-list:%s", ch_buf);
Will Huang2f114542019-10-31 17:35:29 +0800701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 /* Send request to SME. */
Will Huang2f114542019-10-31 17:35:29 +0800703 mmh_msg.type = eWNI_SME_BEACON_REPORT_REQ_IND;
704 mmh_msg.bodyptr = psbrr;
Jeff Johnson86a9a352018-11-22 14:08:32 -0800705 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Will Huang2f114542019-10-31 17:35:29 +0800706 pe_session->peSessionId, mmh_msg.type));
707 lim_sys_process_mmh_msg_api(mac, &mmh_msg);
sheenam monga26165ab2020-02-23 05:25:01 +0530708 *error_code = BCN_RPT_SUCCESS;
Yingying Tang76caff92016-09-29 14:32:30 +0800709 return eRRM_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710}
711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712/**
Pragaspathi Thilagaraj3548a662019-09-30 12:32:52 +0530713 * rrm_fill_beacon_ies() - Fills fixed fields and Ies in bss description to an
714 * array of uint8_t.
715 * @pIes - pointer to the buffer that should be populated with ies.
716 * @pNumIes - returns the num of ies filled in this param.
717 * @pIesMaxSize - Max size of the buffer pIes.
718 * @eids - pointer to array of eids. If NULL, all ies will be populated.
719 * @numEids - number of elements in array eids.
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530720 * @start_offset: Offset from where the IEs in the bss_desc should be parsed
Pragaspathi Thilagaraj3548a662019-09-30 12:32:52 +0530721 * @bss_desc - pointer to Bss Description.
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530722 *
Pragaspathi Thilagaraj3548a662019-09-30 12:32:52 +0530723 * Return: Remaining length of IEs in current bss_desc which are not included
724 * in pIes.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 */
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530726static uint8_t
Pragaspathi Thilagaraj3548a662019-09-30 12:32:52 +0530727rrm_fill_beacon_ies(struct mac_context *mac, uint8_t *pIes,
728 uint8_t *pNumIes, uint8_t pIesMaxSize, uint8_t *eids,
729 uint8_t numEids, uint8_t start_offset,
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530730 struct bss_description *bss_desc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731{
Pragaspathi Thilagaraj3548a662019-09-30 12:32:52 +0530732 uint8_t *pBcnIes, count = 0, i;
733 uint16_t BcnNumIes, total_ies_len, len;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530734 uint8_t rem_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530736 if ((!pIes) || (!pNumIes) || (!bss_desc)) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700737 pe_err("Invalid parameters");
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530738 return 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 }
740 /* Make sure that if eid is null, numEids is set to zero. */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700741 numEids = (!eids) ? 0 : numEids;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530743 total_ies_len = GET_IE_LEN_IN_BSS(bss_desc->length);
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530744 BcnNumIes = total_ies_len;
745 if (start_offset > BcnNumIes) {
746 pe_err("Invalid start offset %d Bcn IE len %d",
747 start_offset, total_ies_len);
748 return 0;
749 }
750
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530751 pBcnIes = (uint8_t *)&bss_desc->ieFields[0];
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530752 pBcnIes += start_offset;
753 BcnNumIes = BcnNumIes - start_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754
755 *pNumIes = 0;
756
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530757 /*
758 * If start_offset is 0, this is the first fragment of the current
759 * beacon. Include the Beacon Fixed Fields of length 12 bytes
760 * (BEACON_FRAME_IES_OFFSET) in the first fragment.
761 */
762 if (start_offset == 0) {
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530763 *((uint32_t *)pIes) = bss_desc->timeStamp[0];
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530764 *pNumIes += sizeof(uint32_t);
765 pIes += sizeof(uint32_t);
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530766 *((uint32_t *)pIes) = bss_desc->timeStamp[1];
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530767 *pNumIes += sizeof(uint32_t);
768 pIes += sizeof(uint32_t);
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530769 *((uint16_t *)pIes) = bss_desc->beaconInterval;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530770 *pNumIes += sizeof(uint16_t);
771 pIes += sizeof(uint16_t);
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530772 *((uint16_t *)pIes) = bss_desc->capabilityInfo;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530773 *pNumIes += sizeof(uint16_t);
774 pIes += sizeof(uint16_t);
775 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776
777 while (BcnNumIes > 0) {
Pragaspathi Thilagaraj77a8a132019-12-05 19:55:28 +0530778 len = *(pBcnIes + 1);
779 len += 2; /* element id + length. */
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700780 pe_debug("EID = %d, len = %d total = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781 *pBcnIes, *(pBcnIes + 1), len);
782
sheenam monga724306f2020-02-08 14:59:35 +0530783 if (BcnNumIes < len || len <= 2) {
Pragaspathi Thilagaraj77a8a132019-12-05 19:55:28 +0530784 pe_err("RRM: Invalid IE len:%d exp_len:%d",
785 len, BcnNumIes);
786 break;
787 }
788
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 i = 0;
790 do {
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530791 if ((!eids) || (*pBcnIes == eids[i])) {
792 if (((*pNumIes) + len) < pIesMaxSize) {
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530793 qdf_mem_copy(pIes, pBcnIes, len);
794 pIes += len;
795 *pNumIes += len;
796 count++;
797 } else {
798 /*
799 * If max size of fragment is reached,
800 * calculate the remaining length and
801 * break. For first fragment, account
802 * for the fixed fields also.
803 */
804 rem_len = total_ies_len - *pNumIes;
805 if (start_offset == 0)
806 rem_len = rem_len +
807 BEACON_FRAME_IES_OFFSET;
808 pe_debug("rem_len %d ies added %d",
809 rem_len, *pNumIes);
810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 break;
812 }
813 i++;
814 } while (i < numEids);
815
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530816 if (rem_len)
817 break;
818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 pBcnIes += len;
820 BcnNumIes -= len;
821 }
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530822 pe_debug("Total length of Ies added = %d rem_len %d",
823 *pNumIes, rem_len);
824
825 return rem_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826}
827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828/**
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530829 * rrm_process_beacon_report_xmit() - create a rrm action frame
830 * @mac_ctx: Global pointer to MAC context
831 * @beacon_xmit_ind: Data for beacon report IE from SME.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 *
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530833 * Create a Radio measurement report action frame and send it to peer.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 *
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700835 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700837QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -0800838rrm_process_beacon_report_xmit(struct mac_context *mac_ctx,
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530839 tpSirBeaconReportXmitInd beacon_xmit_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840{
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700841 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530842 tSirMacRadioMeasureReport *report = NULL;
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700843 tSirMacBeaconReport *beacon_report;
Pragaspathi Thilagaraj1d8e2ab2019-03-04 23:59:21 +0530844 struct bss_description *bss_desc;
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530845 tpRRMReq curr_req = mac_ctx->rrm.rrmPEContext.pCurrentReq;
Jeff Johnson66845ca2018-11-18 21:44:10 -0800846 struct pe_session *session_entry;
Krunal Sonif05a6702017-05-01 10:54:23 -0700847 uint8_t session_id, counter;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530848 uint8_t i, j, offset = 0;
Arif Hussaina86aa432016-07-18 17:05:57 -0700849 uint8_t bss_desc_count = 0;
Deepak Dhamdhere1e4298f2017-06-24 11:46:00 -0700850 uint8_t report_index = 0;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530851 uint8_t rem_len = 0;
852 uint8_t frag_id = 0;
853 uint8_t num_frames, num_reports_in_frame;
sheenam monga26165ab2020-02-23 05:25:01 +0530854 enum beacon_report_status_code error_code =
855 BCN_RPT_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700857 pe_debug("Received beacon report xmit indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700859 if (!beacon_xmit_ind) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700860 pe_err("Received beacon_xmit_ind is NULL in PE");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700861 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 }
863
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700864 if (!curr_req) {
Srinivas Girigowda19b944f2017-03-26 16:22:22 -0700865 pe_err("Received report xmit while there is no request pending in PE");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700866 status = QDF_STATUS_E_FAILURE;
Krunal Sonif05a6702017-05-01 10:54:23 -0700867 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 }
869
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530870 if ((beacon_xmit_ind->numBssDesc) || curr_req->sendEmptyBcnRpt) {
871 beacon_xmit_ind->numBssDesc = (beacon_xmit_ind->numBssDesc ==
872 RRM_BCN_RPT_NO_BSS_INFO) ? RRM_BCN_RPT_MIN_RPT :
873 beacon_xmit_ind->numBssDesc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530875 session_entry = pe_find_session_by_bssid(mac_ctx,
876 beacon_xmit_ind->bssId, &session_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700877 if (!session_entry) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530878 pe_err("TX: [802.11 BCN_RPT] Session does not exist for bssId:%pM",
879 beacon_xmit_ind->bssId);
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700880 status = QDF_STATUS_E_FAILURE;
Krunal Sonif05a6702017-05-01 10:54:23 -0700881 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 }
883
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530884 report = qdf_mem_malloc(MAX_BEACON_REPORTS * sizeof(*report));
885
Arif Hussainf5b6c412018-10-10 19:41:09 -0700886 if (!report) {
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530887 pe_err("RRM Report is NULL, allocation failed");
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -0700888 status = QDF_STATUS_E_NOMEM;
Krunal Sonif05a6702017-05-01 10:54:23 -0700889 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 }
891
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530892 for (i = 0; i < MAX_BEACON_REPORTS &&
893 bss_desc_count < beacon_xmit_ind->numBssDesc; i++) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530894 beacon_report = &report[i].report.beaconReport;
Arif Hussaina86aa432016-07-18 17:05:57 -0700895 /*
896 * If the scan result is NULL then send report request
897 * with option subelement as NULL.
898 */
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530899 pe_debug("TX: [802.11 BCN_RPT] report %d bss %d", i,
900 bss_desc_count);
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530901 bss_desc = beacon_xmit_ind->
902 pBssDescription[bss_desc_count];
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530903
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530904 /* Prepare the beacon report and send it to the peer.*/
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530905 report[i].token = beacon_xmit_ind->uDialogToken;
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530906 report[i].refused = 0;
907 report[i].incapable = 0;
908 report[i].type = SIR_MAC_RRM_BEACON_TYPE;
Arif Hussaina86aa432016-07-18 17:05:57 -0700909
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530910 /*
911 * Valid response is included if the size of
912 * becon xmit is == size of beacon xmit ind + ies
913 */
914 if (beacon_xmit_ind->length < sizeof(*beacon_xmit_ind))
915 continue;
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700916 beacon_report->regClass = beacon_xmit_ind->regClass;
Arif Hussaina86aa432016-07-18 17:05:57 -0700917 if (bss_desc) {
Will Huang65d64252019-07-16 17:57:42 +0800918 beacon_report->channel =
919 wlan_reg_freq_to_chan(
920 mac_ctx->pdev,
921 bss_desc->chan_freq);
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700922 qdf_mem_copy(beacon_report->measStartTime,
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530923 bss_desc->startTSF,
924 sizeof(bss_desc->startTSF));
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700925 beacon_report->measDuration =
Bala Venkatesh40f20fd2019-04-12 20:54:17 +0530926 beacon_xmit_ind->duration;
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700927 beacon_report->phyType = bss_desc->nwType;
928 beacon_report->bcnProbeRsp = 1;
929 beacon_report->rsni = bss_desc->sinr;
930 beacon_report->rcpi = bss_desc->rssi;
931 beacon_report->antennaId = 0;
932 beacon_report->parentTSF = bss_desc->parentTSF;
933 qdf_mem_copy(beacon_report->bssid,
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530934 bss_desc->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
sheenam monga724306f2020-02-08 14:59:35 +0530937 pe_debug("TX: [802.11 BCN_RPT] reporting detail requested %d",
938 curr_req->request.Beacon.reportingDetail);
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530939 switch (curr_req->request.Beacon.reportingDetail) {
940 case BEACON_REPORTING_DETAIL_NO_FF_IE:
941 /* 0: No need to include any elements. */
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530942 break;
943 case BEACON_REPORTING_DETAIL_ALL_FF_REQ_IE:
944 /* 1: Include all FFs and Requested Ies. */
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530945 if (!bss_desc)
946 break;
947
948 rem_len = rrm_fill_beacon_ies(mac_ctx,
949 (uint8_t *)&beacon_report->Ies[0],
950 (uint8_t *)&beacon_report->numIes,
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530951 BEACON_REPORT_MAX_IES,
952 curr_req->request.Beacon.reqIes.
953 pElementIds,
954 curr_req->request.Beacon.reqIes.num,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530955 offset, bss_desc);
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530956 break;
957 case BEACON_REPORTING_DETAIL_ALL_FF_IE:
958 /* 2: default - Include all FFs and all Ies. */
959 default:
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530960 if (!bss_desc)
961 break;
962
963 rem_len = rrm_fill_beacon_ies(mac_ctx,
Deepak Dhamdhere6aa33ba2016-08-23 14:29:45 -0700964 (uint8_t *) &beacon_report->Ies[0],
965 (uint8_t *) &beacon_report->numIes,
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530966 BEACON_REPORT_MAX_IES,
967 NULL,
968 0,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530969 offset, bss_desc);
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +0530970 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 }
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530972 beacon_report->frame_body_frag_id.id = bss_desc_count;
973 beacon_report->frame_body_frag_id.frag_id = frag_id;
974 /*
975 * If remaining length is non-zero, the beacon needs to
976 * be fragmented only if the current request supports
977 * last beacon report indication.
978 * If last beacon report indication is not supported,
979 * truncate and move on to the next beacon.
980 */
981 if (rem_len &&
982 curr_req->request.Beacon.
983 last_beacon_report_indication) {
984 offset = GET_IE_LEN_IN_BSS(
985 bss_desc->length) - rem_len;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530986 pe_debug("TX: [802.11 BCN_RPT] offset %d ie_len %lu rem_len %d frag_id %d",
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +0530987 offset,
988 GET_IE_LEN_IN_BSS(bss_desc->length),
989 rem_len, frag_id);
990 frag_id++;
991 beacon_report->frame_body_frag_id.more_frags =
992 true;
993 } else {
994 offset = 0;
995 beacon_report->frame_body_frag_id.more_frags =
996 false;
997 frag_id = 0;
998 bss_desc_count++;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +0530999 pe_debug("TX: [802.11 BCN_RPT] No remaining IEs");
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301000 }
Vignesh Viswanathan23bec982018-09-28 08:46:41 +05301001
1002 if (curr_req->request.Beacon.
1003 last_beacon_report_indication) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05301004 pe_debug("TX: [802.11 BCN_RPT] Setting last beacon report support");
Vignesh Viswanathan23bec982018-09-28 08:46:41 +05301005 beacon_report->last_bcn_report_ind_support = 1;
1006 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 }
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05301008
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05301009 pe_debug("TX: [802.11 BCN_RPT] Total reports filled %d", i);
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301010 num_frames = i / RADIO_REPORTS_MAX_IN_A_FRAME;
1011 if (i % RADIO_REPORTS_MAX_IN_A_FRAME)
1012 num_frames++;
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05301013
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301014 for (j = 0; j < num_frames; j++) {
1015 num_reports_in_frame = QDF_MIN((i - report_index),
1016 RADIO_REPORTS_MAX_IN_A_FRAME);
Deepak Dhamdhere1e4298f2017-06-24 11:46:00 -07001017 lim_send_radio_measure_report_action_frame(mac_ctx,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301018 curr_req->dialog_token, num_reports_in_frame,
1019 (j == num_frames - 1) ? true : false,
Deepak Dhamdhere1e4298f2017-06-24 11:46:00 -07001020 &report[report_index],
sheenam monga26165ab2020-02-23 05:25:01 +05301021 beacon_xmit_ind->bssId, session_entry,
1022 error_code);
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301023 report_index += num_reports_in_frame;
Deepak Dhamdhere1e4298f2017-06-24 11:46:00 -07001024 }
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +05301025 curr_req->sendEmptyBcnRpt = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 }
1027
Krunal Sonif05a6702017-05-01 10:54:23 -07001028end:
1029 for (counter = 0; counter < beacon_xmit_ind->numBssDesc; counter++)
1030 qdf_mem_free(beacon_xmit_ind->pBssDescription[counter]);
1031
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +05301032 if (beacon_xmit_ind->fMeasureDone) {
sheenam monga724306f2020-02-08 14:59:35 +05301033 pe_debug("Measurement done.");
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +05301034 rrm_cleanup(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 }
1036
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001037 if (report)
Sreelakshmi Konamki20ee4d62016-03-07 16:10:25 +05301038 qdf_mem_free(report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039
1040 return status;
1041}
1042
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001043static void rrm_process_beacon_request_failure(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001044 struct pe_session *pe_session,
Jeff Johnson16281882016-10-07 07:35:40 -07001045 tSirMacAddr peer,
sheenam monga26165ab2020-02-23 05:25:01 +05301046 tRrmRetStatus status,
1047 enum beacon_report_status_code
1048 error_code)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049{
1050 tpSirMacRadioMeasureReport pReport = NULL;
Jeff Johnson86a9a352018-11-22 14:08:32 -08001051 tpRRMReq pCurrentReq = mac->rrm.rrmPEContext.pCurrentReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301053 pReport = qdf_mem_malloc(sizeof(tSirMacRadioMeasureReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001054 if (!pReport)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 pReport->token = pCurrentReq->token;
1057 pReport->type = SIR_MAC_RRM_BEACON_TYPE;
1058
Srinivas Girigowda19b944f2017-03-26 16:22:22 -07001059 pe_debug("status %d token %d", status, pReport->token);
Padma, Santhosh Kumar93ec7d22016-12-26 15:58:37 +05301060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 switch (status) {
1062 case eRRM_REFUSED:
1063 pReport->refused = 1;
1064 break;
1065 case eRRM_INCAPABLE:
1066 pReport->incapable = 1;
1067 break;
1068 default:
sheenam monga724306f2020-02-08 14:59:35 +05301069 pe_err("RX [802.11 BCN_RPT] Beacon request processing failed no report sent");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301070 qdf_mem_free(pReport);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 return;
1072 }
1073
Jeff Johnson86a9a352018-11-22 14:08:32 -08001074 lim_send_radio_measure_report_action_frame(mac,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05301075 pCurrentReq->dialog_token,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301076 1, true,
Vignesh Viswanathan3b4bf982018-06-05 15:04:23 +05301077 pReport, peer,
sheenam monga26165ab2020-02-23 05:25:01 +05301078 pe_session, error_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301080 qdf_mem_free(pReport);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 return;
1082}
1083
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301084/**
1085 * rrm_process_beacon_req() - Update curr_req and report
1086 * @mac_ctx: Global pointer to MAC context
1087 * @peer: Macaddress of the peer requesting the radio measurement
1088 * @session_entry: session entry
1089 * @curr_req: Pointer to RRM request
Sandeep Puligilla63633f62017-11-15 16:51:51 -08001090 * @radiomes_report: Pointer to radio measurement report
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301091 * @rrm_req: Array of Measurement request IEs
1092 * @num_report: No.of reports
1093 * @index: Index for Measurement request
sheenam monga26165ab2020-02-23 05:25:01 +05301094 * @error_code: pointer beacon report resp error code
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301095 *
1096 * Update structure sRRMReq and sSirMacRadioMeasureReport and pass it to
1097 * rrm_process_beacon_report_req().
1098 *
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001099 * Return: QDF_STATUS
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301100 */
Jeff Johnson16281882016-10-07 07:35:40 -07001101static
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001102QDF_STATUS rrm_process_beacon_req(struct mac_context *mac_ctx, tSirMacAddr peer,
Jeff Johnson66845ca2018-11-18 21:44:10 -08001103 struct pe_session *session_entry, tpRRMReq curr_req,
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001104 tpSirMacRadioMeasureReport *radiomes_report,
1105 tDot11fRadioMeasurementRequest *rrm_req,
sheenam monga26165ab2020-02-23 05:25:01 +05301106 uint8_t *num_report, int index,
1107 enum beacon_report_status_code
1108 *error_code)
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301109{
1110 tRrmRetStatus rrm_status = eRRM_SUCCESS;
Sandeep Puligilla63633f62017-11-15 16:51:51 -08001111 tpSirMacRadioMeasureReport report;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301112 if (curr_req) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001113 if (!*radiomes_report) {
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301114 /*
1115 * Allocate memory to send reports for
1116 * any subsequent requests.
1117 */
Sandeep Puligilla63633f62017-11-15 16:51:51 -08001118 *radiomes_report = qdf_mem_malloc(sizeof(*report) *
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301119 (rrm_req->num_MeasurementRequest - index));
sheenam monga26165ab2020-02-23 05:25:01 +05301120 if (!*radiomes_report) {
1121 *error_code =
1122 BCN_RPT_ERR_TEMPORARILY_UNAVAILABLE;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001123 return QDF_STATUS_E_NOMEM;
sheenam monga26165ab2020-02-23 05:25:01 +05301124 }
Srinivas Girigowda19b944f2017-03-26 16:22:22 -07001125 pe_debug("rrm beacon type refused of %d report in beacon table",
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301126 *num_report);
1127 }
Sandeep Puligilla63633f62017-11-15 16:51:51 -08001128 report = *radiomes_report;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301129 report[*num_report].refused = 1;
1130 report[*num_report].type = SIR_MAC_RRM_BEACON_TYPE;
1131 report[*num_report].token =
1132 rrm_req->MeasurementRequest[index].measurement_token;
1133 (*num_report)++;
sheenam monga26165ab2020-02-23 05:25:01 +05301134 *error_code = BCN_RPT_SUCCESS;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001135 return QDF_STATUS_SUCCESS;
sheenam monga26165ab2020-02-23 05:25:01 +05301136 }
1137 curr_req = qdf_mem_malloc(sizeof(*curr_req));
1138 if (!curr_req) {
1139 qdf_mem_free(*radiomes_report);
1140 return QDF_STATUS_E_NOMEM;
1141 }
1142 pe_debug("Processing Beacon Report request");
1143 curr_req->dialog_token = rrm_req->DialogToken.token;
1144 curr_req->token =
1145 rrm_req->MeasurementRequest[index].measurement_token;
1146 curr_req->sendEmptyBcnRpt = true;
1147 mac_ctx->rrm.rrmPEContext.pCurrentReq = curr_req;
1148 rrm_status =
1149 rrm_process_beacon_report_req(mac_ctx, curr_req,
1150 &rrm_req->MeasurementRequest[index],
1151 session_entry, error_code);
1152 if (eRRM_SUCCESS != rrm_status) {
1153 rrm_process_beacon_request_failure(mac_ctx, session_entry, peer,
1154 rrm_status, *error_code);
1155 rrm_cleanup(mac_ctx);
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301156 }
sheenam monga724306f2020-02-08 14:59:35 +05301157
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001158 return QDF_STATUS_SUCCESS;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301159}
1160
1161/**
1162 * update_rrm_report() - Set incapable bit
1163 * @mac_ctx: Global pointer to MAC context
1164 * @report: Pointer to radio measurement report
1165 * @rrm_req: Array of Measurement request IEs
1166 * @num_report: No.of reports
1167 * @index: Index for Measurement request
1168 *
1169 * Send a report with incapabale bit set
1170 *
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001171 * Return: QDF_STATUS
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301172 */
Jeff Johnson16281882016-10-07 07:35:40 -07001173static
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001174QDF_STATUS update_rrm_report(struct mac_context *mac_ctx,
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301175 tpSirMacRadioMeasureReport *report,
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001176 tDot11fRadioMeasurementRequest *rrm_req,
1177 uint8_t *num_report, int index)
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301178{
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301179 tpSirMacRadioMeasureReport rrm_report;
1180
1181 if (!*report) {
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301182 /*
1183 * Allocate memory to send reports for
1184 * any subsequent requests.
1185 */
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301186 *report = qdf_mem_malloc(sizeof(tSirMacRadioMeasureReport) *
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301187 (rrm_req->num_MeasurementRequest - index));
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301188 if (!*report)
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001189 return QDF_STATUS_E_NOMEM;
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301190 pe_debug("rrm beacon type incapable of %d report", *num_report);
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301191 }
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301192 rrm_report = *report;
1193 rrm_report[*num_report].incapable = 1;
1194 rrm_report[*num_report].type =
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301195 rrm_req->MeasurementRequest[index].measurement_type;
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301196 rrm_report[*num_report].token =
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301197 rrm_req->MeasurementRequest[index].measurement_token;
1198 (*num_report)++;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001199 return QDF_STATUS_SUCCESS;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301200}
1201
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202/**
sheenam monga26165ab2020-02-23 05:25:01 +05301203 * rrm_process_radio_measurement_request - Processes the Radio Resource
1204 * Measurement request
1205 *
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301206 * @mac_ctx: Global pointer to MAC context
1207 * @peer: Macaddress of the peer requesting the radio measurement.
1208 * @rrm_req: Array of Measurement request IEs
1209 * @session_entry: session entry.
sheenam monga26165ab2020-02-23 05:25:01 +05301210 * @error_code: beacon report resp error code
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 *
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001212 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 */
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001214QDF_STATUS
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001215rrm_process_radio_measurement_request(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 tSirMacAddr peer,
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301217 tDot11fRadioMeasurementRequest *rrm_req,
sheenam monga26165ab2020-02-23 05:25:01 +05301218 struct pe_session *session_entry,
1219 enum beacon_report_status_code
1220 error_code)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221{
1222 uint8_t i;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001223 QDF_STATUS status = QDF_STATUS_SUCCESS;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301224 tpSirMacRadioMeasureReport report = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 uint8_t num_report = 0;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301226 tpRRMReq curr_req = mac_ctx->rrm.rrmPEContext.pCurrentReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301228 if (!rrm_req->num_MeasurementRequest) {
1229 report = qdf_mem_malloc(sizeof(tSirMacRadioMeasureReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001230 if (!report)
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001231 return QDF_STATUS_E_NOMEM;
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05301232 pe_err("RX: [802.11 RRM] No requestIes in the measurement request, sending incapable report");
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301233 report->incapable = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 num_report = 1;
sheenam monga26165ab2020-02-23 05:25:01 +05301235 error_code = BCN_RPT_ERR_VALIDATION_FAILED_IN_A_REQUEST_FRAME;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301236 lim_send_radio_measure_report_action_frame(mac_ctx,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301237 rrm_req->DialogToken.token, num_report, true,
sheenam monga26165ab2020-02-23 05:25:01 +05301238 report, peer, session_entry, error_code);
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301239 qdf_mem_free(report);
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001240 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 }
1242 /* PF Fix */
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301243 if (rrm_req->NumOfRepetitions.repetitions > 0) {
Pragaspathi Thilagarajacdf3402020-01-27 16:52:50 +05301244 pe_info("RX: [802.11 RRM] number of repetitions %d, sending incapable report",
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301245 rrm_req->NumOfRepetitions.repetitions);
1246 /*
1247 * Send a report with incapable bit set.
1248 * Not supporting repetitions.
1249 */
1250 report = qdf_mem_malloc(sizeof(tSirMacRadioMeasureReport));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001251 if (!report)
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001252 return QDF_STATUS_E_NOMEM;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301253 report->incapable = 1;
sheenam monga26165ab2020-02-23 05:25:01 +05301254 error_code = BCN_RPT_ERR_PREVIOUS_REQUEST_PROGRESS;
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301255 report->type = rrm_req->MeasurementRequest[0].measurement_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 num_report = 1;
1257 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 }
1259
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301260 for (i = 0; i < rrm_req->num_MeasurementRequest; i++) {
1261 switch (rrm_req->MeasurementRequest[i].measurement_type) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 case SIR_MAC_RRM_BEACON_TYPE:
1263 /* Process beacon request. */
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301264 status = rrm_process_beacon_req(mac_ctx, peer,
Sandeep Puligilla63633f62017-11-15 16:51:51 -08001265 session_entry, curr_req, &report, rrm_req,
sheenam monga26165ab2020-02-23 05:25:01 +05301266 &num_report, i, &error_code);
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001267 if (QDF_STATUS_SUCCESS != status)
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301268 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 break;
1270 case SIR_MAC_RRM_LCI_TYPE:
1271 case SIR_MAC_RRM_LOCATION_CIVIC_TYPE:
1272 case SIR_MAC_RRM_FINE_TIME_MEAS_TYPE:
Srinivas Girigowda19b944f2017-03-26 16:22:22 -07001273 pe_debug("RRM with type: %d sent to userspace",
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301274 rrm_req->MeasurementRequest[i].measurement_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 break;
1276 default:
1277 /* Send a report with incapabale bit set. */
sheenam monga26165ab2020-02-23 05:25:01 +05301278 error_code = BCN_RPT_ERR_UNSPECIFIED;
Abhinav Kumar18c78a32019-11-14 14:19:44 +05301279 status = update_rrm_report(mac_ctx, &report, rrm_req,
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301280 &num_report, i);
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001281 if (QDF_STATUS_SUCCESS != status)
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301282 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 break;
1284 }
1285 }
1286
1287end:
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301288 if (report) {
1289 lim_send_radio_measure_report_action_frame(mac_ctx,
Vignesh Viswanathan09bd8f42018-08-14 22:04:36 +05301290 rrm_req->DialogToken.token, num_report, true,
sheenam monga26165ab2020-02-23 05:25:01 +05301291 report, peer, session_entry, error_code);
Sreelakshmi Konamkid178ca82016-03-15 10:26:04 +05301292 qdf_mem_free(report);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 }
1294 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295}
1296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297/**
1298 * rrm_get_start_tsf
1299 *
1300 * FUNCTION: Get the Start TSF.
1301 *
1302 * LOGIC:
1303 *
1304 * ASSUMPTIONS:
1305 *
1306 * NOTE:
1307 *
1308 * @param startTSF - store star TSF in this buffer.
1309 * @return txPower
1310 */
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001311void rrm_get_start_tsf(struct mac_context *mac, uint32_t *pStartTSF)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312{
Jeff Johnson86a9a352018-11-22 14:08:32 -08001313 pStartTSF[0] = mac->rrm.rrmPEContext.startTSF[0];
1314 pStartTSF[1] = mac->rrm.rrmPEContext.startTSF[1];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
1316}
1317
1318/* -------------------------------------------------------------------- */
1319/**
1320 * rrm_get_capabilities
1321 *
1322 * FUNCTION:
1323 * Returns a pointer to tpRRMCaps with all the caps enabled in RRM
1324 *
1325 * LOGIC:
1326 *
1327 * ASSUMPTIONS:
1328 *
1329 * NOTE:
1330 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001331 * @param pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 * @return pointer to tRRMCaps
1333 */
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001334tpRRMCaps rrm_get_capabilities(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335{
Jeff Johnson86a9a352018-11-22 14:08:32 -08001336 return &mac->rrm.rrmPEContext.rrmEnabledCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337}
1338
1339/* -------------------------------------------------------------------- */
1340/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 * rrm_initialize
1342 *
1343 * FUNCTION:
1344 * Initialize RRM module
1345 *
1346 * LOGIC:
1347 *
1348 * ASSUMPTIONS:
1349 *
1350 * NOTE:
1351 *
1352 * @return None
1353 */
1354
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001355QDF_STATUS rrm_initialize(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356{
Jeff Johnson86a9a352018-11-22 14:08:32 -08001357 tpRRMCaps pRRMCaps = &mac->rrm.rrmPEContext.rrmEnabledCaps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358
Jeff Johnson86a9a352018-11-22 14:08:32 -08001359 mac->rrm.rrmPEContext.pCurrentReq = NULL;
1360 mac->rrm.rrmPEContext.txMgmtPower = 0;
1361 mac->rrm.rrmPEContext.DialogToken = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362
Jeff Johnson86a9a352018-11-22 14:08:32 -08001363 mac->rrm.rrmPEContext.rrmEnable = 0;
1364 mac->rrm.rrmPEContext.prev_rrm_report_seq_num = 0xFFFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
hangtian127c9532019-01-12 13:29:07 +08001366 qdf_mem_zero(pRRMCaps, sizeof(tRRMCaps));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 pRRMCaps->LinkMeasurement = 1;
1368 pRRMCaps->NeighborRpt = 1;
1369 pRRMCaps->BeaconPassive = 1;
1370 pRRMCaps->BeaconActive = 1;
1371 pRRMCaps->BeaconTable = 1;
1372 pRRMCaps->APChanReport = 1;
1373 pRRMCaps->fine_time_meas_rpt = 1;
1374 pRRMCaps->lci_capability = 1;
1375
Jeff Johnson1c171732016-09-08 14:35:36 -07001376 pRRMCaps->operatingChanMax = 3;
1377 pRRMCaps->nonOperatingChanMax = 3;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001379 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380}
1381
1382/* -------------------------------------------------------------------- */
1383/**
1384 * rrm_cleanup
1385 *
1386 * FUNCTION:
1387 * cleanup RRM module
1388 *
1389 * LOGIC:
1390 *
1391 * ASSUMPTIONS:
1392 *
1393 * NOTE:
1394 *
1395 * @param mode
1396 * @param rate
1397 * @return None
1398 */
1399
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001400QDF_STATUS rrm_cleanup(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401{
Jeff Johnson86a9a352018-11-22 14:08:32 -08001402 if (mac->rrm.rrmPEContext.pCurrentReq) {
1403 if (mac->rrm.rrmPEContext.pCurrentReq->request.Beacon.reqIes.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 pElementIds) {
Jeff Johnson86a9a352018-11-22 14:08:32 -08001405 qdf_mem_free(mac->rrm.rrmPEContext.pCurrentReq->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 request.Beacon.reqIes.pElementIds);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 }
1408
Jeff Johnson86a9a352018-11-22 14:08:32 -08001409 qdf_mem_free(mac->rrm.rrmPEContext.pCurrentReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 }
1411
Jeff Johnson86a9a352018-11-22 14:08:32 -08001412 mac->rrm.rrmPEContext.pCurrentReq = NULL;
Jeff Johnsonceb4e9b2018-06-22 14:44:24 -07001413 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414}
1415
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001416/**
1417 * lim_update_rrm_capability() - Update PE context's rrm capability
1418 * @mac_ctx: Global pointer to MAC context
1419 * @join_req: Pointer to SME join request.
1420 *
1421 * Update PE context's rrm capability based on SME join request.
1422 *
1423 * Return: None
1424 */
Jeff Johnsonb228e0a2018-12-02 12:27:26 -08001425void lim_update_rrm_capability(struct mac_context *mac_ctx,
Jeff Johnson701444f2019-02-02 22:35:13 -08001426 struct join_req *join_req)
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001427{
1428 mac_ctx->rrm.rrmPEContext.rrmEnable = join_req->rrm_config.rrm_enabled;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301429 qdf_mem_copy(&mac_ctx->rrm.rrmPEContext.rrmEnabledCaps,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001430 &join_req->rrm_config.rm_capability,
1431 RMENABLEDCAP_MAX_LEN);
1432
1433 return;
1434}