Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Abhinav Kumar | 5670d36 | 2018-01-16 17:31:54 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * 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 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 20 | * This file lim_scan_result_utils.cc contains the utility functions |
| 21 | * LIM uses for maintaining and accessing scan results on STA. |
| 22 | * Author: Chandra Modumudi |
| 23 | * Date: 02/13/02 |
| 24 | * History:- |
| 25 | * Date Modified by Modification Information |
| 26 | * -------------------------------------------------------------------- |
| 27 | */ |
| 28 | |
| 29 | #include "lim_types.h" |
| 30 | #include "lim_utils.h" |
| 31 | #include "lim_ser_des_utils.h" |
| 32 | #include "lim_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include "lim_ft_defs.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 34 | #include "lim_session.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 35 | #include "rrm_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | #include "cds_utils.h" |
| 37 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | /** |
| 39 | * lim_collect_bss_description() |
| 40 | * |
| 41 | ***FUNCTION: |
| 42 | * This function is called during scan upon receiving |
| 43 | * Beacon/Probe Response frame to check if the received |
| 44 | * frame matches scan criteria, collect BSS description |
| 45 | * and add it to cached scan results. |
| 46 | * |
| 47 | ***LOGIC: |
| 48 | * |
| 49 | ***ASSUMPTIONS: |
| 50 | * NA |
| 51 | * |
| 52 | ***NOTE: |
| 53 | * NA |
| 54 | * |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 55 | * @param mac - Pointer to Global MAC structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 56 | * @param pBPR - Pointer to parsed Beacon/Probe Response structure |
| 57 | * @param pRxPacketInfo - Pointer to Received frame's BD |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 58 | * @param fScanning - flag to indicate if it is during scan. |
| 59 | * --------------------------------------------- |
| 60 | * |
| 61 | * @return None |
| 62 | */ |
Ganesh Kondabattini | 53e873e | 2016-05-30 15:29:03 +0530 | [diff] [blame] | 63 | void |
Jeff Johnson | 9320c1e | 2018-12-02 13:09:20 -0800 | [diff] [blame^] | 64 | lim_collect_bss_description(struct mac_context *mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 65 | tSirBssDescription *pBssDescr, |
| 66 | tpSirProbeRespBeacon pBPR, |
| 67 | uint8_t *pRxPacketInfo, uint8_t fScanning) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 68 | { |
| 69 | uint8_t *pBody; |
| 70 | uint32_t ieLen = 0; |
| 71 | tpSirMacMgmtHdr pHdr; |
| 72 | uint8_t channelNum; |
| 73 | uint8_t rxChannel; |
| 74 | uint8_t rfBand = 0; |
| 75 | |
| 76 | pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo); |
| 77 | |
| 78 | if (SIR_MAC_B_PR_SSID_OFFSET > WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 79 | QDF_ASSERT(WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) >= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 80 | SIR_MAC_B_PR_SSID_OFFSET); |
Ganesh Kondabattini | 53e873e | 2016-05-30 15:29:03 +0530 | [diff] [blame] | 81 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | } |
| 83 | ieLen = |
| 84 | WMA_GET_RX_PAYLOAD_LEN(pRxPacketInfo) - SIR_MAC_B_PR_SSID_OFFSET; |
| 85 | rxChannel = WMA_GET_RX_CH(pRxPacketInfo); |
| 86 | pBody = WMA_GET_RX_MPDU_DATA(pRxPacketInfo); |
| 87 | rfBand = WMA_GET_RX_RFBAND(pRxPacketInfo); |
| 88 | |
| 89 | /** |
| 90 | * Length of BSS desription is without length of |
| 91 | * length itself and length of pointer that holds ieFields. |
| 92 | * |
| 93 | * tSirBssDescription |
| 94 | * +--------+---------------------------------+---------------+ |
| 95 | * | length | other fields | pointer to IEs| |
| 96 | * +--------+---------------------------------+---------------+ |
| 97 | * ^ |
| 98 | * ieFields |
| 99 | */ |
| 100 | pBssDescr->length = (uint16_t)(offsetof(tSirBssDescription, ieFields[0]) |
| 101 | - sizeof(pBssDescr->length) + ieLen); |
| 102 | |
| 103 | /* Copy BSS Id */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 104 | qdf_mem_copy((uint8_t *) &pBssDescr->bssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 105 | (uint8_t *) pHdr->bssId, sizeof(tSirMacAddr)); |
| 106 | |
| 107 | /* Copy Timestamp, Beacon Interval and Capability Info */ |
Ashish Kumar Dhanotiya | 09d22cf | 2017-06-29 14:09:16 +0530 | [diff] [blame] | 108 | pBssDescr->scansystimensec = qdf_get_bootbased_boottime_ns(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 109 | |
| 110 | pBssDescr->timeStamp[0] = pBPR->timeStamp[0]; |
| 111 | pBssDescr->timeStamp[1] = pBPR->timeStamp[1]; |
| 112 | pBssDescr->beaconInterval = pBPR->beaconInterval; |
| 113 | pBssDescr->capabilityInfo = |
| 114 | lim_get_u16((uint8_t *) &pBPR->capabilityInfo); |
| 115 | |
| 116 | if (!pBssDescr->beaconInterval) { |
Nishank Aggarwal | 8971366 | 2017-03-23 16:55:13 +0530 | [diff] [blame] | 117 | pe_warn("Beacon Interval is ZERO, making it to default 100 " |
| 118 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pHdr->bssId)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 119 | pBssDescr->beaconInterval = 100; |
| 120 | } |
| 121 | /* |
| 122 | * There is a narrow window after Channel Switch msg is sent to HAL and before the AGC is shut |
| 123 | * down and beacons/Probe Rsps can trickle in and we may report the incorrect channel in 5Ghz |
| 124 | * band, so not relying on the 'last Scanned Channel' stored in LIM. |
| 125 | * Instead use the value returned by RXP in BD. This the the same value which HAL programs into |
| 126 | * RXP before every channel switch. |
| 127 | * Right now there is a problem in 5Ghz, where we are receiving beacons from a channel different from |
| 128 | * the currently scanned channel. so incorrect channel is reported to CSR and association does not happen. |
| 129 | * So for now we keep on looking for the channel info in the beacon (DSParamSet IE OR HT Info IE), and only if it |
| 130 | * is not present in the beacon, we go for the channel info present in RXP. |
| 131 | * This fix will work for 5Ghz 11n devices, but for 11a devices, we have to rely on RXP routing flag to get the correct channel. |
| 132 | * So The problem of incorrect channel reporting in 5Ghz will still remain for 11a devices. |
| 133 | */ |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 134 | pBssDescr->channelId = lim_get_channel_from_beacon(mac, pBPR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 135 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 136 | pBssDescr->channelIdSelf = pBssDescr->channelId; |
Deepak Dhamdhere | 652d7e8 | 2015-08-06 14:16:53 -0700 | [diff] [blame] | 137 | pBssDescr->rx_channel = rxChannel; |
| 138 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 139 | /* set the network type in bss description */ |
| 140 | channelNum = pBssDescr->channelId; |
| 141 | pBssDescr->nwType = |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 142 | lim_get_nw_type(mac, channelNum, SIR_MAC_MGMT_FRAME, pBPR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 143 | |
| 144 | /* Copy RSSI & SINR from BD */ |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 145 | pBssDescr->rssi = (int8_t) WMA_GET_RX_RSSI_NORMALIZED(pRxPacketInfo); |
| 146 | pBssDescr->rssi_raw = (int8_t) WMA_GET_RX_RSSI_RAW(pRxPacketInfo); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 147 | |
| 148 | /* SINR no longer reported by HW */ |
| 149 | pBssDescr->sinr = 0; |
Nishank Aggarwal | 8971366 | 2017-03-23 16:55:13 +0530 | [diff] [blame] | 150 | pe_debug(MAC_ADDRESS_STR " rssi: normalized: %d, absolute: %d", |
Deepak Dhamdhere | 68929ec | 2015-08-05 15:16:35 -0700 | [diff] [blame] | 151 | MAC_ADDR_ARRAY(pHdr->bssId), pBssDescr->rssi, |
| 152 | pBssDescr->rssi_raw); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 153 | |
Deepthi Gowri | 6acee34 | 2016-10-28 15:00:38 +0530 | [diff] [blame] | 154 | pBssDescr->received_time = (uint64_t)qdf_mc_timer_get_system_time(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 155 | pBssDescr->tsf_delta = WMA_GET_RX_TSF_DELTA(pRxPacketInfo); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 156 | pBssDescr->seq_ctrl = pHdr->seqControl; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 157 | |
Abhinav Kumar | 5670d36 | 2018-01-16 17:31:54 +0530 | [diff] [blame] | 158 | pe_debug("Received %s from BSSID: %pM tsf_delta = %u Seq Num: %x ssid:%.*s, rssi: %d", |
| 159 | pBssDescr->fProbeRsp ? "Probe Rsp" : "Beacon", pHdr->bssId, |
| 160 | pBssDescr->tsf_delta, ((pHdr->seqControl.seqNumHi << |
| 161 | HIGH_SEQ_NUM_OFFSET) | pHdr->seqControl.seqNumLo), |
| 162 | pBPR->ssId.length, pBPR->ssId.ssId, pBssDescr->rssi_raw); |
Krishna Kumaar Natarajan | 89a99d4 | 2016-08-04 15:44:38 -0700 | [diff] [blame] | 163 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | if (fScanning) { |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 165 | rrm_get_start_tsf(mac, pBssDescr->startTSF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 166 | pBssDescr->parentTSF = WMA_GET_RX_TIMESTAMP(pRxPacketInfo); |
| 167 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | /* MobilityDomain */ |
| 170 | pBssDescr->mdie[0] = 0; |
| 171 | pBssDescr->mdie[1] = 0; |
| 172 | pBssDescr->mdie[2] = 0; |
| 173 | pBssDescr->mdiePresent = false; |
| 174 | /* If mdie is present in the probe resp we */ |
| 175 | /* fill it in the bss description */ |
| 176 | if (pBPR->mdiePresent) { |
| 177 | pBssDescr->mdiePresent = true; |
| 178 | pBssDescr->mdie[0] = pBPR->mdie[0]; |
| 179 | pBssDescr->mdie[1] = pBPR->mdie[1]; |
| 180 | pBssDescr->mdie[2] = pBPR->mdie[2]; |
| 181 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 182 | |
| 183 | #ifdef FEATURE_WLAN_ESE |
| 184 | pBssDescr->QBSSLoad_present = false; |
| 185 | pBssDescr->QBSSLoad_avail = 0; |
| 186 | if (pBPR->QBSSLoad.present) { |
| 187 | pBssDescr->QBSSLoad_present = true; |
| 188 | pBssDescr->QBSSLoad_avail = pBPR->QBSSLoad.avail; |
| 189 | } |
| 190 | #endif |
| 191 | /* Copy IE fields */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 192 | qdf_mem_copy((uint8_t *) &pBssDescr->ieFields, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 193 | pBody + SIR_MAC_B_PR_SSID_OFFSET, ieLen); |
| 194 | |
| 195 | /*set channel number in beacon in case it is not present */ |
| 196 | pBPR->channelNumber = pBssDescr->channelId; |
Jeff Johnson | 348973e | 2018-11-22 16:51:12 -0800 | [diff] [blame] | 197 | mac->lim.beacon_probe_rsp_cnt_per_scan++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 198 | |
Ganesh Kondabattini | 53e873e | 2016-05-30 15:29:03 +0530 | [diff] [blame] | 199 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 200 | } /*** end lim_collect_bss_description() ***/ |