Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wma_utis.c |
| 30 | * This file contains utilities and stats related functions. |
| 31 | */ |
| 32 | |
| 33 | /* Header files */ |
| 34 | |
| 35 | #include "wma.h" |
| 36 | #include "wma_api.h" |
| 37 | #include "cds_api.h" |
| 38 | #include "wmi_unified_api.h" |
| 39 | #include "wlan_qct_sys.h" |
| 40 | #include "wni_api.h" |
| 41 | #include "ani_global.h" |
| 42 | #include "wmi_unified.h" |
| 43 | #include "wni_cfg.h" |
| 44 | #include "cfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 46 | #include "qdf_nbuf.h" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 47 | #include "qdf_types.h" |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 48 | #include "qdf_mem.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 49 | #include "ol_txrx_peer_find.h" |
| 50 | |
| 51 | #include "wma_types.h" |
| 52 | #include "lim_api.h" |
| 53 | #include "lim_session_utils.h" |
| 54 | |
| 55 | #include "cds_utils.h" |
| 56 | |
| 57 | #if !defined(REMOVE_PKT_LOG) |
| 58 | #include "pktlog_ac.h" |
| 59 | #endif /* REMOVE_PKT_LOG */ |
| 60 | |
| 61 | #include "dbglog_host.h" |
| 62 | #include "csr_api.h" |
| 63 | #include "ol_fw.h" |
| 64 | |
| 65 | #include "dfs.h" |
| 66 | #include "wma_internal.h" |
Chandrasekaran, Manishekar | 0d814c7 | 2015-11-05 10:42:48 +0530 | [diff] [blame] | 67 | #include "cds_concurrency.h" |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 68 | #include "wmi_unified_param.h" |
Naveen Rawat | c0c91cd | 2015-11-05 14:27:37 -0800 | [diff] [blame] | 69 | #include "linux/ieee80211.h" |
| 70 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 71 | /* MCS Based rate table */ |
| 72 | /* HT MCS parameters with Nss = 1 */ |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 73 | static struct index_data_rate_type mcs_nss1[] = { |
| 74 | /* MCS L20 S20 L40 S40 */ |
| 75 | {0, {65, 72}, {135, 150 } }, |
| 76 | {1, {130, 144}, {270, 300 } }, |
| 77 | {2, {195, 217}, {405, 450 } }, |
| 78 | {3, {260, 289}, {540, 600 } }, |
| 79 | {4, {390, 433}, {815, 900 } }, |
| 80 | {5, {520, 578}, {1080, 1200} }, |
| 81 | {6, {585, 650}, {1215, 1350} }, |
| 82 | {7, {650, 722}, {1350, 1500} } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /* HT MCS parameters with Nss = 2 */ |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 86 | static struct index_data_rate_type mcs_nss2[] = { |
| 87 | /* MCS L20 S20 L40 S40 */ |
| 88 | {0, {130, 144}, {270, 300 } }, |
| 89 | {1, {260, 289}, {540, 600 } }, |
| 90 | {2, {390, 433}, {810, 900 } }, |
| 91 | {3, {520, 578}, {1080, 1200} }, |
| 92 | {4, {780, 867}, {1620, 1800} }, |
| 93 | {5, {1040, 1156}, {2160, 2400} }, |
| 94 | {6, {1170, 1300}, {2430, 2700} }, |
| 95 | {7, {1300, 1440}, {2700, 3000} } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 96 | }; |
| 97 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 98 | /* MCS Based VHT rate table */ |
| 99 | /* MCS parameters with Nss = 1*/ |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 100 | static struct index_vht_data_rate_type vht_mcs_nss1[] = { |
| 101 | /* MCS L20 S20 L40 S40 L80 S80 */ |
| 102 | {0, {65, 72 }, {135, 150}, {293, 325} }, |
| 103 | {1, {130, 144}, {270, 300}, {585, 650} }, |
| 104 | {2, {195, 217}, {405, 450}, {878, 975} }, |
| 105 | {3, {260, 289}, {540, 600}, {1170, 1300} }, |
| 106 | {4, {390, 433}, {810, 900}, {1755, 1950} }, |
| 107 | {5, {520, 578}, {1080, 1200}, {2340, 2600} }, |
| 108 | {6, {585, 650}, {1215, 1350}, {2633, 2925} }, |
| 109 | {7, {650, 722}, {1350, 1500}, {2925, 3250} }, |
| 110 | {8, {780, 867}, {1620, 1800}, {3510, 3900} }, |
| 111 | {9, {865, 960}, {1800, 2000}, {3900, 4333} } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | /*MCS parameters with Nss = 2*/ |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 115 | static struct index_vht_data_rate_type vht_mcs_nss2[] = { |
| 116 | /* MCS L20 S20 L40 S40 L80 S80 */ |
| 117 | {0, {130, 144}, {270, 300}, { 585, 650} }, |
| 118 | {1, {260, 289}, {540, 600}, {1170, 1300} }, |
| 119 | {2, {390, 433}, {810, 900}, {1755, 1950} }, |
| 120 | {3, {520, 578}, {1080, 1200}, {2340, 2600} }, |
| 121 | {4, {780, 867}, {1620, 1800}, {3510, 3900} }, |
| 122 | {5, {1040, 1156}, {2160, 2400}, {4680, 5200} }, |
| 123 | {6, {1170, 1300}, {2430, 2700}, {5265, 5850} }, |
| 124 | {7, {1300, 1444}, {2700, 3000}, {5850, 6500} }, |
| 125 | {8, {1560, 1733}, {3240, 3600}, {7020, 7800} }, |
| 126 | {9, {1730, 1920}, {3600, 4000}, {7800, 8667} } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 127 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 128 | |
| 129 | #ifdef BIG_ENDIAN_HOST |
| 130 | |
| 131 | /* ############# function definitions ############ */ |
| 132 | |
| 133 | /** |
| 134 | * wma_swap_bytes() - swap bytes |
| 135 | * @pv: buffer |
| 136 | * @n: swap bytes |
| 137 | * |
| 138 | * Return: none |
| 139 | */ |
| 140 | void wma_swap_bytes(void *pv, uint32_t n) |
| 141 | { |
| 142 | int32_t no_words; |
| 143 | int32_t i; |
| 144 | uint32_t *word_ptr; |
| 145 | |
| 146 | no_words = n / sizeof(uint32_t); |
| 147 | word_ptr = (uint32_t *) pv; |
| 148 | for (i = 0; i < no_words; i++) { |
| 149 | *(word_ptr + i) = __cpu_to_le32(*(word_ptr + i)); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | #define SWAPME(x, len) wma_swap_bytes(&x, len); |
| 154 | #endif /* BIG_ENDIAN_HOST */ |
| 155 | |
| 156 | /** |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 157 | * wma_mcs_rate_match() - find the match mcs rate |
| 158 | * @match_rate: the rate to look up |
| 159 | * @is_sgi: return if the SGI rate is found |
| 160 | * @nss: the nss in use |
| 161 | * @nss1_rate: the nss1 rate |
| 162 | * @nss1_srate: the nss1 SGI rate |
| 163 | * @nss2_rate: the nss2 rate |
| 164 | * @nss2_srate: the nss2 SGI rate |
| 165 | * |
| 166 | * This is a helper function to find the match of the tx_rate |
| 167 | * in terms of the nss1/nss2 rate with non-SGI/SGI. |
| 168 | * |
| 169 | * Return: the found rate or 0 otherwise |
| 170 | */ |
| 171 | static inline uint16_t wma_mcs_rate_match(uint16_t match_rate, bool *is_sgi, |
| 172 | uint8_t nss, uint16_t nss1_rate, |
| 173 | uint16_t nss1_srate, |
| 174 | uint16_t nss2_rate, |
| 175 | uint16_t nss2_srate) |
| 176 | { |
| 177 | WMA_LOGD("%s match_rate: %d, %d %d %d %d", |
| 178 | __func__, match_rate, nss1_rate, nss1_srate, nss2_rate, |
| 179 | nss2_srate); |
| 180 | |
| 181 | if (match_rate == nss1_rate) { |
| 182 | return nss1_rate; |
| 183 | } else if (match_rate == nss1_srate) { |
| 184 | *is_sgi = true; |
| 185 | return nss1_srate; |
| 186 | } else if (nss == 2 && match_rate == nss2_rate) |
| 187 | return nss2_rate; |
| 188 | else if (nss == 2 && match_rate == nss2_srate) { |
| 189 | *is_sgi = true; |
| 190 | return nss2_srate; |
| 191 | } else |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 196 | * wma_get_mcs_idx() - get mcs index |
| 197 | * @maxRate: max rate |
| 198 | * @rate_flags: rate flags |
| 199 | * @nss: number of nss |
| 200 | * @mcsRateFlag: mcs rate flag |
| 201 | * |
| 202 | * Return: return mcs index |
| 203 | */ |
| 204 | static uint8_t wma_get_mcs_idx(uint16_t maxRate, uint8_t rate_flags, |
| 205 | uint8_t nss, uint8_t *mcsRateFlag) |
| 206 | { |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 207 | uint8_t index = 0; |
Arif Hussain | b8fef84 | 2016-07-19 09:43:13 -0700 | [diff] [blame] | 208 | uint16_t match_rate = 0; |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 209 | bool is_sgi = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 210 | |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 211 | WMA_LOGD("%s rate:%d rate_flgs: 0x%x, nss: %d", |
| 212 | __func__, maxRate, rate_flags, nss); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 213 | |
| 214 | *mcsRateFlag = rate_flags; |
| 215 | *mcsRateFlag &= ~eHAL_TX_RATE_SGI; |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 216 | for (index = 0; index < MAX_VHT_MCS_IDX; index++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | if (rate_flags & eHAL_TX_RATE_VHT80) { |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 218 | /* check for vht80 nss1/2 rate set */ |
| 219 | match_rate = wma_mcs_rate_match(maxRate, &is_sgi, nss, |
| 220 | vht_mcs_nss1[index].ht80_rate[0], |
| 221 | vht_mcs_nss1[index].ht80_rate[1], |
| 222 | vht_mcs_nss2[index].ht80_rate[0], |
| 223 | vht_mcs_nss2[index].ht80_rate[1]); |
| 224 | if (match_rate) |
| 225 | goto rate_found; |
| 226 | } |
| 227 | if ((rate_flags & eHAL_TX_RATE_VHT40) | |
| 228 | (rate_flags & eHAL_TX_RATE_VHT80)) { |
| 229 | /* check for vht40 nss1/2 rate set */ |
| 230 | match_rate = wma_mcs_rate_match(maxRate, &is_sgi, nss, |
| 231 | vht_mcs_nss1[index].ht40_rate[0], |
| 232 | vht_mcs_nss1[index].ht40_rate[1], |
| 233 | vht_mcs_nss2[index].ht40_rate[0], |
| 234 | vht_mcs_nss2[index].ht40_rate[1]); |
| 235 | if (match_rate) { |
| 236 | *mcsRateFlag &= ~eHAL_TX_RATE_VHT80; |
| 237 | goto rate_found; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 238 | } |
| 239 | } |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 240 | if ((rate_flags & eHAL_TX_RATE_VHT20) | |
| 241 | (rate_flags & eHAL_TX_RATE_VHT40) | |
| 242 | (rate_flags & eHAL_TX_RATE_VHT80)) { |
| 243 | /* check for vht20 nss1/2 rate set */ |
| 244 | match_rate = wma_mcs_rate_match(maxRate, &is_sgi, nss, |
| 245 | vht_mcs_nss1[index].ht20_rate[0], |
| 246 | vht_mcs_nss1[index].ht20_rate[1], |
| 247 | vht_mcs_nss2[index].ht20_rate[0], |
| 248 | vht_mcs_nss2[index].ht20_rate[1]); |
| 249 | if (match_rate) { |
| 250 | *mcsRateFlag &= ~(eHAL_TX_RATE_VHT80 | |
| 251 | eHAL_TX_RATE_VHT40); |
| 252 | goto rate_found; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | } |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 256 | for (index = 0; index < MAX_HT_MCS_IDX; index++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 257 | if (rate_flags & eHAL_TX_RATE_HT40) { |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 258 | /* check for ht40 nss1/2 rate set */ |
| 259 | match_rate = wma_mcs_rate_match(maxRate, &is_sgi, nss, |
| 260 | mcs_nss1[index].ht40_rate[0], |
| 261 | mcs_nss1[index].ht40_rate[1], |
| 262 | mcs_nss2[index].ht40_rate[0], |
| 263 | mcs_nss2[index].ht40_rate[1]); |
| 264 | if (match_rate) { |
| 265 | *mcsRateFlag = eHAL_TX_RATE_HT40; |
| 266 | goto rate_found; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 267 | } |
| 268 | } |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 269 | if (rate_flags & eHAL_TX_RATE_HT20) { |
| 270 | /* check for ht20 nss1/2 rate set */ |
| 271 | match_rate = wma_mcs_rate_match(maxRate, &is_sgi, nss, |
| 272 | mcs_nss1[index].ht20_rate[0], |
| 273 | mcs_nss1[index].ht20_rate[1], |
| 274 | mcs_nss2[index].ht20_rate[0], |
| 275 | mcs_nss2[index].ht20_rate[1]); |
| 276 | if (match_rate) { |
| 277 | *mcsRateFlag = eHAL_TX_RATE_HT20; |
| 278 | goto rate_found; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 283 | rate_found: |
| 284 | /* set SGI flag only if this is SGI rate */ |
| 285 | if (match_rate && is_sgi == true) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 286 | *mcsRateFlag |= eHAL_TX_RATE_SGI; |
| 287 | |
Ryan Hsu | 6139d2d | 2015-11-04 17:29:00 -0800 | [diff] [blame] | 288 | WMA_LOGD("%s - match_rate: %d index: %d rate_flag: 0x%x is_sgi: %d", |
| 289 | __func__, match_rate, index, *mcsRateFlag, is_sgi); |
| 290 | |
| 291 | return match_rate ? index : INVALID_MCS_IDX; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | /** |
| 295 | * host_map_smps_mode() - map fw smps mode to tSmpsModeValue |
| 296 | * @fw_smps_mode: fw smps mode |
| 297 | * |
| 298 | * Return: return tSmpsModeValue |
| 299 | */ |
| 300 | tSmpsModeValue host_map_smps_mode(A_UINT32 fw_smps_mode) |
| 301 | { |
| 302 | tSmpsModeValue smps_mode = SMPS_MODE_DISABLED; |
| 303 | switch (fw_smps_mode) { |
| 304 | case WMI_SMPS_FORCED_MODE_STATIC: |
| 305 | smps_mode = STATIC_SMPS_MODE; |
| 306 | break; |
| 307 | case WMI_SMPS_FORCED_MODE_DYNAMIC: |
| 308 | smps_mode = DYNAMIC_SMPS_MODE; |
| 309 | break; |
| 310 | default: |
| 311 | smps_mode = SMPS_MODE_DISABLED; |
| 312 | } |
| 313 | |
| 314 | return smps_mode; |
| 315 | } |
| 316 | |
Archana Ramachandran | 20d2e23 | 2016-02-11 16:58:40 -0800 | [diff] [blame] | 317 | /** |
| 318 | * wma_smps_mode_to_force_mode_param() - Map smps mode to force |
| 319 | * mode commmand param |
| 320 | * @smps_mode: SMPS mode according to the protocol |
| 321 | * |
| 322 | * Return: int > 0 for success else failure |
| 323 | */ |
| 324 | int wma_smps_mode_to_force_mode_param(uint8_t smps_mode) |
| 325 | { |
| 326 | int param = -EINVAL; |
| 327 | |
| 328 | switch (smps_mode) { |
| 329 | case STATIC_SMPS_MODE: |
| 330 | param = WMI_SMPS_FORCED_MODE_STATIC; |
| 331 | break; |
| 332 | case DYNAMIC_SMPS_MODE: |
| 333 | param = WMI_SMPS_FORCED_MODE_DYNAMIC; |
| 334 | break; |
| 335 | case SMPS_MODE_DISABLED: |
| 336 | param = WMI_SMPS_FORCED_MODE_DISABLED; |
| 337 | break; |
| 338 | default: |
| 339 | WMA_LOGE(FL("smps mode cannot be mapped :%d "), |
| 340 | smps_mode); |
| 341 | } |
| 342 | return param; |
| 343 | } |
| 344 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | #ifdef WLAN_FEATURE_STATS_EXT |
| 346 | /** |
| 347 | * wma_stats_ext_event_handler() - extended stats event handler |
| 348 | * @handle: wma handle |
| 349 | * @event_buf: event buffer received from fw |
| 350 | * @len: length of data |
| 351 | * |
| 352 | * Return: 0 for success or error code |
| 353 | */ |
| 354 | int wma_stats_ext_event_handler(void *handle, uint8_t *event_buf, |
| 355 | uint32_t len) |
| 356 | { |
| 357 | WMI_STATS_EXT_EVENTID_param_tlvs *param_buf; |
| 358 | tSirStatsExtEvent *stats_ext_event; |
| 359 | wmi_stats_ext_event_fixed_param *stats_ext_info; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 360 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 361 | cds_msg_t cds_msg; |
| 362 | uint8_t *buf_ptr; |
| 363 | uint32_t alloc_len; |
| 364 | |
| 365 | WMA_LOGD("%s: Posting stats ext event to SME", __func__); |
| 366 | |
| 367 | param_buf = (WMI_STATS_EXT_EVENTID_param_tlvs *) event_buf; |
| 368 | if (!param_buf) { |
| 369 | WMA_LOGE("%s: Invalid stats ext event buf", __func__); |
| 370 | return -EINVAL; |
| 371 | } |
| 372 | |
| 373 | stats_ext_info = param_buf->fixed_param; |
| 374 | buf_ptr = (uint8_t *) stats_ext_info; |
| 375 | |
| 376 | alloc_len = sizeof(tSirStatsExtEvent); |
| 377 | alloc_len += stats_ext_info->data_len; |
| 378 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 379 | stats_ext_event = (tSirStatsExtEvent *) qdf_mem_malloc(alloc_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 380 | if (NULL == stats_ext_event) { |
| 381 | WMA_LOGE("%s: Memory allocation failure", __func__); |
| 382 | return -ENOMEM; |
| 383 | } |
| 384 | |
| 385 | buf_ptr += sizeof(wmi_stats_ext_event_fixed_param) + WMI_TLV_HDR_SIZE; |
| 386 | |
| 387 | stats_ext_event->vdev_id = stats_ext_info->vdev_id; |
| 388 | stats_ext_event->event_data_len = stats_ext_info->data_len; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 389 | qdf_mem_copy(stats_ext_event->event_data, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 390 | buf_ptr, stats_ext_event->event_data_len); |
| 391 | |
| 392 | cds_msg.type = eWNI_SME_STATS_EXT_EVENT; |
| 393 | cds_msg.bodyptr = (void *)stats_ext_event; |
| 394 | cds_msg.bodyval = 0; |
| 395 | |
| 396 | status = cds_mq_post_message(CDS_MQ_ID_SME, &cds_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 397 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 398 | WMA_LOGE("%s: Failed to post stats ext event to SME", __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 399 | qdf_mem_free(stats_ext_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 400 | return -EFAULT; |
| 401 | } |
| 402 | |
| 403 | WMA_LOGD("%s: stats ext event Posted to SME", __func__); |
| 404 | return 0; |
| 405 | } |
| 406 | #endif /* WLAN_FEATURE_STATS_EXT */ |
| 407 | |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 408 | |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 409 | /** |
| 410 | * wma_profile_data_report_event_handler() - fw profiling handler |
| 411 | * @handle: wma handle |
| 412 | * @event_buf: event buffer received from fw |
| 413 | * @len: length of data |
| 414 | * |
| 415 | * Return: 0 for success or error code |
| 416 | */ |
| 417 | int wma_profile_data_report_event_handler(void *handle, uint8_t *event_buf, |
| 418 | uint32_t len) |
| 419 | { |
| 420 | WMI_WLAN_PROFILE_DATA_EVENTID_param_tlvs *param_buf; |
| 421 | wmi_wlan_profile_ctx_t *profile_ctx; |
| 422 | wmi_wlan_profile_t *profile_data; |
| 423 | uint32_t i = 0; |
| 424 | uint32_t entries; |
| 425 | uint8_t *buf_ptr; |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 426 | char temp_str[150]; |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 427 | param_buf = (WMI_WLAN_PROFILE_DATA_EVENTID_param_tlvs *) event_buf; |
| 428 | |
| 429 | if (!param_buf) { |
| 430 | WMA_LOGE("%s: Invalid profile data event buf", __func__); |
| 431 | return -EINVAL; |
| 432 | } |
| 433 | profile_ctx = param_buf->profile_ctx; |
| 434 | buf_ptr = (uint8_t *)profile_ctx; |
| 435 | buf_ptr = buf_ptr + sizeof(wmi_wlan_profile_ctx_t) + WMI_TLV_HDR_SIZE; |
| 436 | profile_data = (wmi_wlan_profile_t *) buf_ptr; |
| 437 | entries = profile_ctx->bin_count; |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 438 | QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 439 | "Profile data stats\n"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 440 | QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR, |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 441 | "TOT: %d\n" |
| 442 | "tx_msdu_cnt: %d\n" |
| 443 | "tx_mpdu_cnt: %d\n" |
| 444 | "tx_ppdu_cnt: %d\n" |
| 445 | "rx_msdu_cnt: %d\n" |
| 446 | "rx_mpdu_cnt: %d\n" |
| 447 | "bin_count: %d\n", |
| 448 | profile_ctx->tot, |
| 449 | profile_ctx->tx_msdu_cnt, |
| 450 | profile_ctx->tx_mpdu_cnt, |
| 451 | profile_ctx->tx_ppdu_cnt, |
| 452 | profile_ctx->rx_msdu_cnt, |
| 453 | profile_ctx->rx_mpdu_cnt, |
| 454 | profile_ctx->bin_count); |
| 455 | |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 456 | QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR, |
| 457 | "Profile ID: Count: TOT: Min: Max: hist_intvl: hist[0]: hist[1]:hist[2]"); |
| 458 | |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 459 | for (i = 0; i < entries; i++) { |
| 460 | if (i == WMI_WLAN_PROFILE_MAX_BIN_CNT) |
| 461 | break; |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 462 | snprintf(temp_str, sizeof(temp_str), |
| 463 | " %d : %d : %d : %d : %d : %d : %d : %d : %d", |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 464 | profile_data[i].id, |
| 465 | profile_data[i].cnt, |
| 466 | profile_data[i].tot, |
| 467 | profile_data[i].min, |
| 468 | profile_data[i].max, |
| 469 | profile_data[i].hist_intvl, |
| 470 | profile_data[i].hist[0], |
| 471 | profile_data[i].hist[1], |
| 472 | profile_data[i].hist[2]); |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 473 | QDF_TRACE(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_ERROR, |
| 474 | "%s", temp_str); |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | return 0; |
| 478 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 479 | |
| 480 | #ifdef WLAN_FEATURE_LINK_LAYER_STATS |
| 481 | |
| 482 | /** |
| 483 | * wma_unified_link_peer_stats_event_handler() - peer stats event handler |
| 484 | * @handle: wma handle |
| 485 | * @cmd_param_info: data received with event from fw |
| 486 | * @len: length of data |
| 487 | * |
| 488 | * Return: 0 for success or error code |
| 489 | */ |
| 490 | static int wma_unified_link_peer_stats_event_handler(void *handle, |
| 491 | uint8_t *cmd_param_info, |
| 492 | uint32_t len) |
| 493 | { |
| 494 | WMI_PEER_LINK_STATS_EVENTID_param_tlvs *param_tlvs; |
| 495 | wmi_peer_stats_event_fixed_param *fixed_param; |
| 496 | wmi_peer_link_stats *peer_stats, *temp_peer_stats; |
| 497 | wmi_rate_stats *rate_stats; |
| 498 | tSirLLStatsResults *link_stats_results; |
| 499 | uint8_t *results, *t_peer_stats, *t_rate_stats; |
| 500 | uint32_t count, num_rates = 0; |
| 501 | uint32_t next_res_offset, next_peer_offset, next_rate_offset; |
| 502 | size_t peer_info_size, peer_stats_size, rate_stats_size; |
| 503 | size_t link_stats_results_size; |
| 504 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 505 | tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 506 | |
| 507 | if (!pMac) { |
| 508 | WMA_LOGD("%s: NULL pMac ptr. Exiting", __func__); |
| 509 | return -EINVAL; |
| 510 | } |
| 511 | |
| 512 | if (!pMac->sme.pLinkLayerStatsIndCallback) { |
| 513 | WMA_LOGD("%s: HDD callback is null", __func__); |
| 514 | return -EINVAL; |
| 515 | } |
| 516 | |
| 517 | WMA_LOGD("%s: Posting Peer Stats event to HDD", __func__); |
| 518 | param_tlvs = (WMI_PEER_LINK_STATS_EVENTID_param_tlvs *) cmd_param_info; |
| 519 | if (!param_tlvs) { |
| 520 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 521 | return -EINVAL; |
| 522 | } |
| 523 | /* |
| 524 | * cmd_param_info contains |
| 525 | * wmi_peer_stats_event_fixed_param fixed_param; |
| 526 | * num_peers * size of(struct wmi_peer_link_stats) |
| 527 | * num_rates * size of(struct wmi_rate_stats) |
| 528 | * num_rates is the sum of the rates of all the peers. |
| 529 | */ |
| 530 | fixed_param = param_tlvs->fixed_param; |
| 531 | peer_stats = param_tlvs->peer_stats; |
| 532 | rate_stats = param_tlvs->peer_rate_stats; |
| 533 | |
| 534 | if (!fixed_param || !peer_stats || |
| 535 | (peer_stats->num_rates && !rate_stats)) { |
| 536 | WMA_LOGA("%s: Invalid param_tlvs for Peer Stats", __func__); |
| 537 | return -EINVAL; |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 | * num_rates - sum of the rates of all the peers |
| 542 | */ |
| 543 | temp_peer_stats = (wmi_peer_link_stats *) peer_stats; |
| 544 | for (count = 0; count < fixed_param->num_peers; count++) { |
| 545 | num_rates += temp_peer_stats->num_rates; |
| 546 | temp_peer_stats++; |
| 547 | } |
| 548 | |
| 549 | peer_stats_size = sizeof(tSirWifiPeerStat); |
| 550 | peer_info_size = sizeof(tSirWifiPeerInfo); |
| 551 | rate_stats_size = sizeof(tSirWifiRateStat); |
| 552 | link_stats_results_size = |
| 553 | sizeof(*link_stats_results) + peer_stats_size + |
| 554 | (fixed_param->num_peers * peer_info_size) + |
| 555 | (num_rates * rate_stats_size); |
| 556 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 557 | link_stats_results = qdf_mem_malloc(link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | if (NULL == link_stats_results) { |
| 559 | WMA_LOGD("%s: could not allocate mem for stats results-len %zu", |
| 560 | __func__, link_stats_results_size); |
| 561 | return -ENOMEM; |
| 562 | } |
| 563 | |
| 564 | WMA_LOGD("Peer stats from FW event buf"); |
| 565 | WMA_LOGD("Fixed Param:"); |
| 566 | WMA_LOGD("request_id %u num_peers %u peer_event_number %u more_data %u", |
| 567 | fixed_param->request_id, fixed_param->num_peers, |
| 568 | fixed_param->peer_event_number, fixed_param->more_data); |
| 569 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 570 | qdf_mem_zero(link_stats_results, link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | |
| 572 | link_stats_results->paramId = WMI_LINK_STATS_ALL_PEER; |
| 573 | link_stats_results->rspId = fixed_param->request_id; |
| 574 | link_stats_results->ifaceId = 0; |
| 575 | link_stats_results->num_peers = fixed_param->num_peers; |
| 576 | link_stats_results->peer_event_number = fixed_param->peer_event_number; |
| 577 | link_stats_results->moreResultToFollow = fixed_param->more_data; |
| 578 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 579 | qdf_mem_copy(link_stats_results->results, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | &fixed_param->num_peers, peer_stats_size); |
| 581 | |
| 582 | results = (uint8_t *) link_stats_results->results; |
| 583 | t_peer_stats = (uint8_t *) peer_stats; |
| 584 | t_rate_stats = (uint8_t *) rate_stats; |
| 585 | next_res_offset = peer_stats_size; |
| 586 | next_peer_offset = WMI_TLV_HDR_SIZE; |
| 587 | next_rate_offset = WMI_TLV_HDR_SIZE; |
| 588 | for (count = 0; count < fixed_param->num_peers; count++) { |
| 589 | WMA_LOGD("Peer Info:"); |
| 590 | WMA_LOGD("peer_type %u capabilities %u num_rates %u", |
| 591 | peer_stats->peer_type, peer_stats->capabilities, |
| 592 | peer_stats->num_rates); |
| 593 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 594 | qdf_mem_copy(results + next_res_offset, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 595 | t_peer_stats + next_peer_offset, peer_info_size); |
| 596 | next_res_offset += peer_info_size; |
| 597 | |
| 598 | /* Copy rate stats associated with this peer */ |
| 599 | for (count = 0; count < peer_stats->num_rates; count++) { |
| 600 | WMA_LOGD("Rate Stats Info:"); |
| 601 | WMA_LOGD("rate %u bitrate %u tx_mpdu %u rx_mpdu %u " |
| 602 | "mpdu_lost %u retries %u retries_short %u " |
| 603 | "retries_long %u", rate_stats->rate, |
| 604 | rate_stats->bitrate, rate_stats->tx_mpdu, |
| 605 | rate_stats->rx_mpdu, rate_stats->mpdu_lost, |
| 606 | rate_stats->retries, rate_stats->retries_short, |
| 607 | rate_stats->retries_long); |
| 608 | rate_stats++; |
| 609 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 610 | qdf_mem_copy(results + next_res_offset, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 611 | t_rate_stats + next_rate_offset, |
| 612 | rate_stats_size); |
| 613 | next_res_offset += rate_stats_size; |
| 614 | next_rate_offset += sizeof(*rate_stats); |
| 615 | } |
| 616 | next_peer_offset += sizeof(*peer_stats); |
| 617 | peer_stats++; |
| 618 | } |
| 619 | |
| 620 | /* call hdd callback with Link Layer Statistics |
| 621 | * vdev_id/ifacId in link_stats_results will be |
| 622 | * used to retrieve the correct HDD context |
| 623 | */ |
| 624 | pMac->sme.pLinkLayerStatsIndCallback(pMac->hHdd, |
| 625 | WMA_LINK_LAYER_STATS_RESULTS_RSP, |
| 626 | link_stats_results); |
| 627 | WMA_LOGD("%s: Peer Stats event posted to HDD", __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 628 | qdf_mem_free(link_stats_results); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | |
| 630 | return 0; |
| 631 | } |
| 632 | |
| 633 | |
| 634 | /** |
| 635 | * wma_unified_link_radio_stats_event_handler() - radio link stats event handler |
| 636 | * @handle: wma handle |
| 637 | * @cmd_param_info: data received with event from fw |
| 638 | * @len: length of data |
| 639 | * |
| 640 | * Return: 0 for success or error code |
| 641 | */ |
| 642 | static int wma_unified_link_radio_stats_event_handler(void *handle, |
| 643 | uint8_t *cmd_param_info, |
| 644 | uint32_t len) |
| 645 | { |
| 646 | WMI_RADIO_LINK_STATS_EVENTID_param_tlvs *param_tlvs; |
| 647 | wmi_radio_link_stats_event_fixed_param *fixed_param; |
| 648 | wmi_radio_link_stats *radio_stats; |
| 649 | wmi_channel_stats *channel_stats; |
| 650 | tSirLLStatsResults *link_stats_results; |
| 651 | uint8_t *results, *t_radio_stats, *t_channel_stats; |
| 652 | uint32_t next_res_offset, next_chan_offset, count; |
| 653 | size_t radio_stats_size, chan_stats_size; |
| 654 | size_t link_stats_results_size; |
| 655 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 656 | tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 657 | |
| 658 | if (!pMac) { |
| 659 | WMA_LOGD("%s: NULL pMac ptr. Exiting", __func__); |
| 660 | return -EINVAL; |
| 661 | } |
| 662 | |
| 663 | if (!pMac->sme.pLinkLayerStatsIndCallback) { |
| 664 | WMA_LOGD("%s: HDD callback is null", __func__); |
| 665 | return -EINVAL; |
| 666 | } |
| 667 | |
| 668 | WMA_LOGD("%s: Posting Radio Stats event to HDD", __func__); |
| 669 | param_tlvs = (WMI_RADIO_LINK_STATS_EVENTID_param_tlvs *) cmd_param_info; |
| 670 | if (!param_tlvs) { |
| 671 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 672 | return -EINVAL; |
| 673 | } |
| 674 | |
| 675 | /* |
| 676 | * cmd_param_info contains |
| 677 | * wmi_radio_link_stats_event_fixed_param fixed_param; |
| 678 | * size of(struct wmi_radio_link_stats); |
| 679 | * num_channels * size of(struct wmi_channel_stats) |
| 680 | */ |
| 681 | fixed_param = param_tlvs->fixed_param; |
| 682 | radio_stats = param_tlvs->radio_stats; |
| 683 | channel_stats = param_tlvs->channel_stats; |
| 684 | |
| 685 | if (!fixed_param || !radio_stats || |
| 686 | (radio_stats->num_channels && !channel_stats)) { |
| 687 | WMA_LOGA("%s: Invalid param_tlvs for Radio Stats", __func__); |
| 688 | return -EINVAL; |
| 689 | } |
| 690 | |
| 691 | radio_stats_size = sizeof(tSirWifiRadioStat); |
| 692 | chan_stats_size = sizeof(tSirWifiChannelStats); |
| 693 | link_stats_results_size = sizeof(*link_stats_results) + |
| 694 | radio_stats_size + (radio_stats->num_channels * chan_stats_size); |
| 695 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 696 | link_stats_results = qdf_mem_malloc(link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 697 | if (NULL == link_stats_results) { |
| 698 | WMA_LOGD("%s: could not allocate mem for stats results-len %zu", |
| 699 | __func__, link_stats_results_size); |
| 700 | return -ENOMEM; |
| 701 | } |
| 702 | |
| 703 | WMA_LOGD("Radio stats from FW event buf"); |
| 704 | WMA_LOGD("Fixed Param:"); |
| 705 | WMA_LOGD("request_id %u num_radio %u more_radio_events %u", |
| 706 | fixed_param->request_id, fixed_param->num_radio, |
| 707 | fixed_param->more_radio_events); |
| 708 | |
| 709 | WMA_LOGD("Radio Info"); |
| 710 | WMA_LOGD("radio_id %u on_time %u tx_time %u rx_time %u on_time_scan %u " |
| 711 | "on_time_nbd %u on_time_gscan %u on_time_roam_scan %u " |
| 712 | "on_time_pno_scan %u on_time_hs20 %u num_channels %u", |
| 713 | radio_stats->radio_id, radio_stats->on_time, |
| 714 | radio_stats->tx_time, radio_stats->rx_time, |
| 715 | radio_stats->on_time_scan, radio_stats->on_time_nbd, |
| 716 | radio_stats->on_time_gscan, |
| 717 | radio_stats->on_time_roam_scan, |
| 718 | radio_stats->on_time_pno_scan, |
| 719 | radio_stats->on_time_hs20, radio_stats->num_channels); |
| 720 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 721 | qdf_mem_zero(link_stats_results, link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 722 | |
| 723 | link_stats_results->paramId = WMI_LINK_STATS_RADIO; |
| 724 | link_stats_results->rspId = fixed_param->request_id; |
| 725 | link_stats_results->ifaceId = 0; |
| 726 | link_stats_results->num_radio = fixed_param->num_radio; |
| 727 | link_stats_results->peer_event_number = 0; |
| 728 | link_stats_results->moreResultToFollow = fixed_param->more_radio_events; |
| 729 | |
| 730 | results = (uint8_t *) link_stats_results->results; |
| 731 | t_radio_stats = (uint8_t *) radio_stats; |
| 732 | t_channel_stats = (uint8_t *) channel_stats; |
| 733 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 734 | qdf_mem_copy(results, t_radio_stats + WMI_TLV_HDR_SIZE, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | radio_stats_size); |
| 736 | |
| 737 | next_res_offset = radio_stats_size; |
| 738 | next_chan_offset = WMI_TLV_HDR_SIZE; |
| 739 | WMA_LOGD("Channel Stats Info"); |
| 740 | for (count = 0; count < radio_stats->num_channels; count++) { |
| 741 | WMA_LOGD("channel_width %u center_freq %u center_freq0 %u " |
| 742 | "center_freq1 %u radio_awake_time %u cca_busy_time %u", |
| 743 | channel_stats->channel_width, |
| 744 | channel_stats->center_freq, |
| 745 | channel_stats->center_freq0, |
| 746 | channel_stats->center_freq1, |
| 747 | channel_stats->radio_awake_time, |
| 748 | channel_stats->cca_busy_time); |
| 749 | channel_stats++; |
| 750 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 751 | qdf_mem_copy(results + next_res_offset, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 752 | t_channel_stats + next_chan_offset, |
| 753 | chan_stats_size); |
| 754 | next_res_offset += chan_stats_size; |
| 755 | next_chan_offset += sizeof(*channel_stats); |
| 756 | } |
| 757 | |
| 758 | /* call hdd callback with Link Layer Statistics |
| 759 | * vdev_id/ifacId in link_stats_results will be |
| 760 | * used to retrieve the correct HDD context |
| 761 | */ |
| 762 | pMac->sme.pLinkLayerStatsIndCallback(pMac->hHdd, |
| 763 | WMA_LINK_LAYER_STATS_RESULTS_RSP, |
| 764 | link_stats_results); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 765 | qdf_mem_free(link_stats_results); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | |
| 767 | return 0; |
| 768 | } |
| 769 | |
| 770 | /** |
| 771 | * wma_register_ll_stats_event_handler() - register link layer stats related |
| 772 | * event handler |
| 773 | * @wma_handle: wma handle |
| 774 | * |
| 775 | * Return: none |
| 776 | */ |
| 777 | void wma_register_ll_stats_event_handler(tp_wma_handle wma_handle) |
| 778 | { |
| 779 | if (NULL == wma_handle) { |
| 780 | WMA_LOGE("%s: wma_handle is NULL", __func__); |
| 781 | return; |
| 782 | } |
| 783 | |
| 784 | wmi_unified_register_event_handler(wma_handle->wmi_handle, |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 785 | WMI_IFACE_LINK_STATS_EVENTID, |
| 786 | wma_unified_link_iface_stats_event_handler, |
| 787 | WMA_RX_SERIALIZER_CTX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | wmi_unified_register_event_handler(wma_handle->wmi_handle, |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 789 | WMI_PEER_LINK_STATS_EVENTID, |
| 790 | wma_unified_link_peer_stats_event_handler, |
| 791 | WMA_RX_SERIALIZER_CTX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | wmi_unified_register_event_handler(wma_handle->wmi_handle, |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 793 | WMI_RADIO_LINK_STATS_EVENTID, |
| 794 | wma_unified_link_radio_stats_event_handler, |
| 795 | WMA_RX_SERIALIZER_CTX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | |
| 797 | return; |
| 798 | } |
| 799 | |
| 800 | |
| 801 | /** |
| 802 | * wma_process_ll_stats_clear_req() - clear link layer stats |
| 803 | * @wma: wma handle |
| 804 | * @clearReq: ll stats clear request command params |
| 805 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 806 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 808 | QDF_STATUS wma_process_ll_stats_clear_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | (tp_wma_handle wma, const tpSirLLStatsClearReq clearReq) |
| 810 | { |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 811 | struct ll_stats_clear_params cmd = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | int ret; |
| 813 | |
| 814 | if (!clearReq || !wma) { |
| 815 | WMA_LOGE("%s: input pointer is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 816 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | } |
| 818 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 819 | cmd.stop_req = clearReq->stopReq; |
| 820 | cmd.sta_id = clearReq->staId; |
| 821 | cmd.stats_clear_mask = clearReq->statsClearReqMask; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 823 | ret = wmi_unified_process_ll_stats_clear_cmd(wma->wmi_handle, &cmd, |
| 824 | wma->interfaces[clearReq->staId].addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 825 | if (ret) { |
| 826 | WMA_LOGE("%s: Failed to send clear link stats req", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 827 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 828 | } |
| 829 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 830 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | /** |
| 834 | * wma_process_ll_stats_set_req() - link layer stats set request |
| 835 | * @wma: wma handle |
| 836 | * @setReq: ll stats set request command params |
| 837 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 838 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 840 | QDF_STATUS wma_process_ll_stats_set_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 841 | (tp_wma_handle wma, const tpSirLLStatsSetReq setReq) |
| 842 | { |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 843 | struct ll_stats_set_params cmd = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | int ret; |
| 845 | |
| 846 | if (!setReq || !wma) { |
| 847 | WMA_LOGE("%s: input pointer is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 848 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 849 | } |
| 850 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 851 | cmd.mpdu_size_threshold = setReq->mpduSizeThreshold; |
| 852 | cmd.aggressive_statistics_gathering = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | setReq->aggressiveStatisticsGathering; |
| 854 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 855 | ret = wmi_unified_process_ll_stats_set_cmd(wma->wmi_handle, |
| 856 | &cmd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | if (ret) { |
| 858 | WMA_LOGE("%s: Failed to send set link stats request", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 859 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | } |
| 861 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 862 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | /** |
| 866 | * wma_process_ll_stats_get_req() - link layer stats get request |
| 867 | * @wma:wma handle |
| 868 | * @getReq:ll stats get request command params |
| 869 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 870 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 871 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 872 | QDF_STATUS wma_process_ll_stats_get_req |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | (tp_wma_handle wma, const tpSirLLStatsGetReq getReq) |
| 874 | { |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 875 | struct ll_stats_get_params cmd = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | int ret; |
| 877 | |
| 878 | if (!getReq || !wma) { |
| 879 | WMA_LOGE("%s: input pointer is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 880 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 881 | } |
| 882 | |
Selvaraj, Sridhar | 171e225 | 2016-06-22 22:33:26 +0530 | [diff] [blame] | 883 | if (!wma->interfaces[getReq->staId].vdev_active) { |
| 884 | WMA_LOGE("%s: vdev not created yet", __func__); |
| 885 | return QDF_STATUS_E_FAILURE; |
| 886 | } |
| 887 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 888 | cmd.req_id = getReq->reqId; |
| 889 | cmd.param_id_mask = getReq->paramIdMask; |
| 890 | cmd.sta_id = getReq->staId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 891 | |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 892 | ret = wmi_unified_process_ll_stats_get_cmd(wma->wmi_handle, &cmd, |
| 893 | wma->interfaces[getReq->staId].addr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 894 | if (ret) { |
| 895 | WMA_LOGE("%s: Failed to send get link stats request", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 896 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | } |
| 898 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 899 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | /** |
| 903 | * wma_unified_link_iface_stats_event_handler() - link iface stats event handler |
| 904 | * @wma:wma handle |
| 905 | * @cmd_param_info: data from event |
| 906 | * @len: length |
| 907 | * |
| 908 | * Return: 0 for success or error code |
| 909 | */ |
| 910 | int wma_unified_link_iface_stats_event_handler(void *handle, |
| 911 | uint8_t *cmd_param_info, |
| 912 | uint32_t len) |
| 913 | { |
| 914 | WMI_IFACE_LINK_STATS_EVENTID_param_tlvs *param_tlvs; |
| 915 | wmi_iface_link_stats_event_fixed_param *fixed_param; |
| 916 | wmi_iface_link_stats *link_stats; |
| 917 | wmi_wmm_ac_stats *ac_stats; |
| 918 | tSirLLStatsResults *link_stats_results; |
| 919 | uint8_t *results, *t_link_stats, *t_ac_stats; |
| 920 | uint32_t next_res_offset, next_ac_offset, count; |
| 921 | uint32_t roaming_offset, roaming_size; |
| 922 | size_t link_stats_size, ac_stats_size, iface_info_size; |
| 923 | size_t link_stats_results_size; |
| 924 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 925 | tpAniSirGlobal pMac = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 926 | |
| 927 | if (!pMac) { |
| 928 | WMA_LOGD("%s: NULL pMac ptr. Exiting", __func__); |
| 929 | return -EINVAL; |
| 930 | } |
| 931 | |
| 932 | if (!pMac->sme.pLinkLayerStatsIndCallback) { |
| 933 | WMA_LOGD("%s: HDD callback is null", __func__); |
| 934 | return -EINVAL; |
| 935 | } |
| 936 | |
| 937 | WMA_LOGD("%s: Posting Iface Stats event to HDD", __func__); |
| 938 | param_tlvs = (WMI_IFACE_LINK_STATS_EVENTID_param_tlvs *) cmd_param_info; |
| 939 | if (!param_tlvs) { |
| 940 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 941 | return -EINVAL; |
| 942 | } |
| 943 | |
| 944 | /* |
| 945 | * cmd_param_info contains |
| 946 | * wmi_iface_link_stats_event_fixed_param fixed_param; |
| 947 | * wmi_iface_link_stats iface_link_stats; |
| 948 | * iface_link_stats->num_ac * size of(struct wmi_wmm_ac_stats) |
| 949 | */ |
| 950 | fixed_param = param_tlvs->fixed_param; |
| 951 | link_stats = param_tlvs->iface_link_stats; |
| 952 | ac_stats = param_tlvs->ac; |
| 953 | |
| 954 | if (!fixed_param || !link_stats || (link_stats->num_ac && !ac_stats)) { |
| 955 | WMA_LOGA("%s: Invalid param_tlvs for Iface Stats", __func__); |
| 956 | return -EINVAL; |
| 957 | } |
| 958 | |
| 959 | link_stats_size = sizeof(tSirWifiIfaceStat); |
| 960 | iface_info_size = sizeof(tSirWifiInterfaceInfo); |
| 961 | ac_stats_size = sizeof(tSirWifiWmmAcStat); |
| 962 | link_stats_results_size = sizeof(*link_stats_results) + link_stats_size; |
| 963 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 964 | link_stats_results = qdf_mem_malloc(link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 965 | if (!link_stats_results) { |
| 966 | WMA_LOGD("%s: could not allocate mem for stats results-len %zu", |
| 967 | __func__, link_stats_results_size); |
| 968 | return -ENOMEM; |
| 969 | } |
| 970 | |
| 971 | WMA_LOGD("Interface stats from FW event buf"); |
| 972 | WMA_LOGD("Fixed Param:"); |
| 973 | WMA_LOGD("request_id %u vdev_id %u", |
| 974 | fixed_param->request_id, fixed_param->vdev_id); |
| 975 | |
| 976 | WMA_LOGD("Iface Stats:"); |
| 977 | WMA_LOGD("beacon_rx %u mgmt_rx %u mgmt_action_rx %u mgmt_action_tx %u " |
| 978 | "rssi_mgmt %u rssi_data %u rssi_ack %u num_peers %u " |
| 979 | "num_peer_events %u num_ac %u roam_state %u" |
| 980 | " avg_bcn_spread_offset_high %u" |
| 981 | " avg_bcn_spread_offset_low %u" |
| 982 | " is leaky_ap %u" |
| 983 | " avg_rx_frames_leaked %u" |
| 984 | " rx_leak_window %u", |
| 985 | link_stats->beacon_rx, link_stats->mgmt_rx, |
| 986 | link_stats->mgmt_action_rx, link_stats->mgmt_action_tx, |
| 987 | link_stats->rssi_mgmt, link_stats->rssi_data, |
| 988 | link_stats->rssi_ack, link_stats->num_peers, |
| 989 | link_stats->num_peer_events, link_stats->num_ac, |
| 990 | link_stats->roam_state, |
| 991 | link_stats->avg_bcn_spread_offset_high, |
| 992 | link_stats->avg_bcn_spread_offset_low, |
| 993 | link_stats->is_leaky_ap, |
| 994 | link_stats->avg_rx_frms_leaked, |
| 995 | link_stats->rx_leak_window); |
| 996 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 997 | qdf_mem_zero(link_stats_results, link_stats_results_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | |
| 999 | link_stats_results->paramId = WMI_LINK_STATS_IFACE; |
| 1000 | link_stats_results->rspId = fixed_param->request_id; |
| 1001 | link_stats_results->ifaceId = fixed_param->vdev_id; |
| 1002 | link_stats_results->num_peers = link_stats->num_peers; |
| 1003 | link_stats_results->peer_event_number = 0; |
| 1004 | link_stats_results->moreResultToFollow = 0; |
| 1005 | |
| 1006 | results = (uint8_t *) link_stats_results->results; |
| 1007 | t_link_stats = (uint8_t *) link_stats; |
| 1008 | t_ac_stats = (uint8_t *) ac_stats; |
| 1009 | |
| 1010 | /* Copy roaming state */ |
| 1011 | roaming_offset = offsetof(tSirWifiInterfaceInfo, roaming); |
| 1012 | roaming_size = member_size(tSirWifiInterfaceInfo, roaming); |
| 1013 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1014 | qdf_mem_copy(results + roaming_offset, &link_stats->roam_state, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | roaming_size); |
| 1016 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1017 | qdf_mem_copy(results + iface_info_size, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | t_link_stats + WMI_TLV_HDR_SIZE, |
| 1019 | link_stats_size - iface_info_size - |
| 1020 | WIFI_AC_MAX * ac_stats_size); |
| 1021 | |
| 1022 | next_res_offset = link_stats_size - WIFI_AC_MAX * ac_stats_size; |
| 1023 | next_ac_offset = WMI_TLV_HDR_SIZE; |
| 1024 | |
| 1025 | WMA_LOGD("AC Stats:"); |
| 1026 | for (count = 0; count < link_stats->num_ac; count++) { |
| 1027 | WMA_LOGD("ac_type %u tx_mpdu %u rx_mpdu %u tx_mcast %u " |
| 1028 | "rx_mcast %u rx_ampdu %u tx_ampdu %u mpdu_lost %u " |
| 1029 | "retries %u retries_short %u retries_long %u " |
| 1030 | "contention_time_min %u contention_time_max %u " |
| 1031 | "contention_time_avg %u contention_num_samples %u", |
| 1032 | ac_stats->ac_type, ac_stats->tx_mpdu, |
| 1033 | ac_stats->rx_mpdu, ac_stats->tx_mcast, |
| 1034 | ac_stats->rx_mcast, ac_stats->rx_ampdu, |
| 1035 | ac_stats->tx_ampdu, ac_stats->mpdu_lost, |
| 1036 | ac_stats->retries, ac_stats->retries_short, |
| 1037 | ac_stats->retries_long, ac_stats->contention_time_min, |
| 1038 | ac_stats->contention_time_max, |
| 1039 | ac_stats->contention_time_avg, |
| 1040 | ac_stats->contention_num_samples); |
| 1041 | ac_stats++; |
| 1042 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1043 | qdf_mem_copy(results + next_res_offset, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1044 | t_ac_stats + next_ac_offset, ac_stats_size); |
| 1045 | next_res_offset += ac_stats_size; |
| 1046 | next_ac_offset += sizeof(*ac_stats); |
| 1047 | } |
| 1048 | |
| 1049 | /* call hdd callback with Link Layer Statistics |
| 1050 | * vdev_id/ifacId in link_stats_results will be |
| 1051 | * used to retrieve the correct HDD context |
| 1052 | */ |
| 1053 | pMac->sme.pLinkLayerStatsIndCallback(pMac->hHdd, |
| 1054 | WMA_LINK_LAYER_STATS_RESULTS_RSP, |
| 1055 | link_stats_results); |
| 1056 | WMA_LOGD("%s: Iface Stats event posted to HDD", __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1057 | qdf_mem_free(link_stats_results); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1058 | |
| 1059 | return 0; |
| 1060 | } |
| 1061 | |
| 1062 | #endif /* WLAN_FEATURE_LINK_LAYER_STATS */ |
| 1063 | |
| 1064 | /** |
| 1065 | * wma_update_pdev_stats() - update pdev stats |
| 1066 | * @wma: wma handle |
| 1067 | * @pdev_stats: pdev stats |
| 1068 | * |
| 1069 | * Return: none |
| 1070 | */ |
| 1071 | static void wma_update_pdev_stats(tp_wma_handle wma, |
| 1072 | wmi_pdev_stats *pdev_stats) |
| 1073 | { |
| 1074 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1075 | uint32_t temp_mask; |
| 1076 | uint8_t *stats_buf; |
| 1077 | tCsrGlobalClassAStatsInfo *classa_stats = NULL; |
| 1078 | struct wma_txrx_node *node; |
| 1079 | uint8_t i; |
| 1080 | |
| 1081 | for (i = 0; i < wma->max_bssid; i++) { |
| 1082 | node = &wma->interfaces[i]; |
| 1083 | stats_rsp_params = node->stats_rsp; |
| 1084 | if (stats_rsp_params) { |
| 1085 | node->fw_stats_set |= FW_PDEV_STATS_SET; |
| 1086 | WMA_LOGD("<---FW PDEV STATS received for vdevId:%d", i); |
| 1087 | stats_buf = (uint8_t *) (stats_rsp_params + 1); |
| 1088 | temp_mask = stats_rsp_params->statsMask; |
| 1089 | if (temp_mask & (1 << eCsrSummaryStats)) |
| 1090 | stats_buf += sizeof(tCsrSummaryStatsInfo); |
| 1091 | |
| 1092 | if (temp_mask & (1 << eCsrGlobalClassAStats)) { |
| 1093 | classa_stats = |
| 1094 | (tCsrGlobalClassAStatsInfo *) stats_buf; |
| 1095 | classa_stats->max_pwr = pdev_stats->chan_tx_pwr; |
| 1096 | } |
| 1097 | } |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | /** |
| 1102 | * wma_update_vdev_stats() - update vdev stats |
| 1103 | * @wma: wma handle |
| 1104 | * @vdev_stats: vdev stats |
| 1105 | * |
| 1106 | * Return: none |
| 1107 | */ |
| 1108 | static void wma_update_vdev_stats(tp_wma_handle wma, |
| 1109 | wmi_vdev_stats *vdev_stats) |
| 1110 | { |
| 1111 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1112 | tCsrSummaryStatsInfo *summary_stats = NULL; |
| 1113 | uint8_t *stats_buf; |
| 1114 | struct wma_txrx_node *node; |
| 1115 | uint8_t i; |
| 1116 | int8_t rssi = 0; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1117 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1118 | tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) wma->pGetRssiReq; |
| 1119 | cds_msg_t sme_msg = { 0 }; |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1120 | int8_t bcn_snr, dat_snr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | |
| 1122 | node = &wma->interfaces[vdev_stats->vdev_id]; |
| 1123 | stats_rsp_params = node->stats_rsp; |
| 1124 | if (stats_rsp_params) { |
| 1125 | stats_buf = (uint8_t *) (stats_rsp_params + 1); |
| 1126 | node->fw_stats_set |= FW_VDEV_STATS_SET; |
| 1127 | WMA_LOGD("<---FW VDEV STATS received for vdevId:%d", |
| 1128 | vdev_stats->vdev_id); |
| 1129 | if (stats_rsp_params->statsMask & (1 << eCsrSummaryStats)) { |
| 1130 | summary_stats = (tCsrSummaryStatsInfo *) stats_buf; |
| 1131 | for (i = 0; i < 4; i++) { |
| 1132 | summary_stats->tx_frm_cnt[i] = |
| 1133 | vdev_stats->tx_frm_cnt[i]; |
| 1134 | summary_stats->fail_cnt[i] = |
| 1135 | vdev_stats->fail_cnt[i]; |
| 1136 | summary_stats->multiple_retry_cnt[i] = |
| 1137 | vdev_stats->multiple_retry_cnt[i]; |
| 1138 | } |
| 1139 | |
| 1140 | summary_stats->rx_frm_cnt = vdev_stats->rx_frm_cnt; |
| 1141 | summary_stats->rx_error_cnt = vdev_stats->rx_err_cnt; |
| 1142 | summary_stats->rx_discard_cnt = |
| 1143 | vdev_stats->rx_discard_cnt; |
| 1144 | summary_stats->ack_fail_cnt = vdev_stats->ack_fail_cnt; |
| 1145 | summary_stats->rts_succ_cnt = vdev_stats->rts_succ_cnt; |
| 1146 | summary_stats->rts_fail_cnt = vdev_stats->rts_fail_cnt; |
| 1147 | } |
| 1148 | } |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1149 | bcn_snr = vdev_stats->vdev_snr.bcn_snr; |
| 1150 | dat_snr = vdev_stats->vdev_snr.dat_snr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1152 | WMA_LOGD("vdev id %d beancon snr %d data snr %d", |
| 1153 | vdev_stats->vdev_id, bcn_snr, dat_snr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1154 | |
| 1155 | if (pGetRssiReq && pGetRssiReq->sessionId == vdev_stats->vdev_id) { |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1156 | if ((bcn_snr == WMA_TGT_INVALID_SNR) && |
| 1157 | (dat_snr == WMA_TGT_INVALID_SNR)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1158 | /* |
| 1159 | * Firmware sends invalid snr till it sees |
| 1160 | * Beacon/Data after connection since after |
| 1161 | * vdev up fw resets the snr to invalid. |
| 1162 | * In this duartion Host will return the last know |
| 1163 | * rssi during connection. |
| 1164 | */ |
| 1165 | WMA_LOGE("Invalid SNR from firmware"); |
| 1166 | |
| 1167 | } else { |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1168 | if (bcn_snr != WMA_TGT_INVALID_SNR) { |
| 1169 | rssi = bcn_snr; |
| 1170 | } else if (dat_snr != WMA_TGT_INVALID_SNR) { |
| 1171 | rssi = dat_snr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | /* |
| 1175 | * Get the absolute rssi value from the current rssi value |
| 1176 | * the sinr value is hardcoded into 0 in the core stack |
| 1177 | */ |
| 1178 | rssi = rssi + WMA_TGT_NOISE_FLOOR_DBM; |
| 1179 | } |
| 1180 | |
| 1181 | WMA_LOGD("Average Rssi = %d, vdev id= %d", rssi, |
| 1182 | pGetRssiReq->sessionId); |
| 1183 | |
| 1184 | /* update the average rssi value to UMAC layer */ |
| 1185 | if (NULL != pGetRssiReq->rssiCallback) { |
| 1186 | ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))(rssi, |
| 1187 | pGetRssiReq->staId, |
| 1188 | pGetRssiReq->pDevContext); |
| 1189 | } |
| 1190 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1191 | qdf_mem_free(pGetRssiReq); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | wma->pGetRssiReq = NULL; |
| 1193 | } |
| 1194 | |
| 1195 | if (node->psnr_req) { |
| 1196 | tAniGetSnrReq *p_snr_req = node->psnr_req; |
| 1197 | |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1198 | if (bcn_snr != WMA_TGT_INVALID_SNR) |
| 1199 | p_snr_req->snr = bcn_snr; |
| 1200 | else if (dat_snr != WMA_TGT_INVALID_SNR) |
| 1201 | p_snr_req->snr = dat_snr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1202 | else |
Varun Reddy Yeturu | 83ccb9b | 2016-06-29 11:55:41 -0700 | [diff] [blame] | 1203 | p_snr_req->snr = (int8_t)WMA_TGT_INVALID_SNR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1204 | |
| 1205 | sme_msg.type = eWNI_SME_SNR_IND; |
| 1206 | sme_msg.bodyptr = p_snr_req; |
| 1207 | sme_msg.bodyval = 0; |
| 1208 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1209 | qdf_status = cds_mq_post_message(QDF_MODULE_ID_SME, &sme_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1210 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1211 | WMA_LOGE("%s: Fail to post snr ind msg", __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1212 | qdf_mem_free(p_snr_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | node->psnr_req = NULL; |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | /** |
| 1220 | * wma_post_stats() - update stats to PE |
| 1221 | * @wma: wma handle |
| 1222 | * @node: txrx node |
| 1223 | * |
| 1224 | * Return: none |
| 1225 | */ |
| 1226 | static void wma_post_stats(tp_wma_handle wma, struct wma_txrx_node *node) |
| 1227 | { |
| 1228 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1229 | |
| 1230 | stats_rsp_params = node->stats_rsp; |
| 1231 | /* send response to UMAC */ |
| 1232 | wma_send_msg(wma, WMA_GET_STATISTICS_RSP, (void *)stats_rsp_params, 0); |
| 1233 | node->stats_rsp = NULL; |
| 1234 | node->fw_stats_set = 0; |
| 1235 | } |
| 1236 | |
| 1237 | /** |
| 1238 | * wma_update_peer_stats() - update peer stats |
| 1239 | * @wma: wma handle |
| 1240 | * @peer_stats: peer stats |
| 1241 | * |
| 1242 | * Return: none |
| 1243 | */ |
| 1244 | static void wma_update_peer_stats(tp_wma_handle wma, |
| 1245 | wmi_peer_stats *peer_stats) |
| 1246 | { |
| 1247 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1248 | tCsrGlobalClassAStatsInfo *classa_stats = NULL; |
| 1249 | struct wma_txrx_node *node; |
| 1250 | uint8_t *stats_buf, vdev_id, macaddr[IEEE80211_ADDR_LEN], mcsRateFlags; |
| 1251 | uint32_t temp_mask; |
| 1252 | |
| 1253 | WMI_MAC_ADDR_TO_CHAR_ARRAY(&peer_stats->peer_macaddr, &macaddr[0]); |
| 1254 | if (!wma_find_vdev_by_bssid(wma, macaddr, &vdev_id)) |
| 1255 | return; |
| 1256 | |
| 1257 | node = &wma->interfaces[vdev_id]; |
| 1258 | if (node->stats_rsp) { |
| 1259 | node->fw_stats_set |= FW_PEER_STATS_SET; |
| 1260 | WMA_LOGD("<-- FW PEER STATS received for vdevId:%d", vdev_id); |
| 1261 | stats_rsp_params = (tAniGetPEStatsRsp *) node->stats_rsp; |
| 1262 | stats_buf = (uint8_t *) (stats_rsp_params + 1); |
| 1263 | temp_mask = stats_rsp_params->statsMask; |
| 1264 | if (temp_mask & (1 << eCsrSummaryStats)) |
| 1265 | stats_buf += sizeof(tCsrSummaryStatsInfo); |
| 1266 | |
| 1267 | if (temp_mask & (1 << eCsrGlobalClassAStats)) { |
| 1268 | classa_stats = (tCsrGlobalClassAStatsInfo *) stats_buf; |
| 1269 | WMA_LOGD("peer tx rate:%d", peer_stats->peer_tx_rate); |
| 1270 | /*The linkspeed returned by fw is in kbps so convert |
| 1271 | *it in to units of 500kbps which is expected by UMAC*/ |
| 1272 | if (peer_stats->peer_tx_rate) { |
| 1273 | classa_stats->tx_rate = |
| 1274 | peer_stats->peer_tx_rate / 500; |
| 1275 | } |
| 1276 | |
| 1277 | classa_stats->tx_rate_flags = node->rate_flags; |
| 1278 | if (!(node->rate_flags & eHAL_TX_RATE_LEGACY)) { |
| 1279 | classa_stats->mcs_index = |
| 1280 | wma_get_mcs_idx((peer_stats->peer_tx_rate / |
| 1281 | 100), node->rate_flags, |
| 1282 | node->nss, &mcsRateFlags); |
| 1283 | /* rx_frag_cnt and promiscuous_rx_frag_cnt |
| 1284 | * parameter is currently not used. lets use the |
| 1285 | * same parameter to hold the nss value and mcs |
| 1286 | * rate flags */ |
| 1287 | classa_stats->rx_frag_cnt = node->nss; |
| 1288 | classa_stats->promiscuous_rx_frag_cnt = |
| 1289 | mcsRateFlags; |
| 1290 | WMA_LOGD("Computed mcs_idx:%d mcs_rate_flags:%d", |
| 1291 | classa_stats->mcs_index, mcsRateFlags); |
| 1292 | } |
| 1293 | /* FW returns tx power in intervals of 0.5 dBm |
| 1294 | Convert it back to intervals of 1 dBm */ |
| 1295 | classa_stats->max_pwr = |
| 1296 | roundup(classa_stats->max_pwr, 2) >> 1; |
| 1297 | WMA_LOGD("peer tx rate flags:%d nss:%d max_txpwr:%d", |
| 1298 | node->rate_flags, node->nss, |
| 1299 | classa_stats->max_pwr); |
| 1300 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * wma_post_link_status() - post link status to SME |
| 1306 | * @pGetLinkStatus: SME Link status |
| 1307 | * @link_status: Link status |
| 1308 | * |
| 1309 | * Return: none |
| 1310 | */ |
| 1311 | void wma_post_link_status(tAniGetLinkStatus *pGetLinkStatus, |
| 1312 | uint8_t link_status) |
| 1313 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1314 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1315 | cds_msg_t sme_msg = { 0 }; |
| 1316 | |
| 1317 | pGetLinkStatus->linkStatus = link_status; |
| 1318 | sme_msg.type = eWNI_SME_LINK_STATUS_IND; |
| 1319 | sme_msg.bodyptr = pGetLinkStatus; |
| 1320 | sme_msg.bodyval = 0; |
| 1321 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1322 | qdf_status = cds_mq_post_message(QDF_MODULE_ID_SME, &sme_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1323 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1324 | WMA_LOGE("%s: Fail to post link status ind msg", __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1325 | qdf_mem_free(pGetLinkStatus); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | } |
| 1327 | } |
| 1328 | |
| 1329 | /** |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 1330 | * wma_update_per_chain_rssi_stats() - to store per chain rssi stats |
| 1331 | * @wma: wma handle |
| 1332 | * @rssi_stats: rssi stats |
| 1333 | * @rssi_per_chain_stats: buffer where rssi stats to be stored |
| 1334 | * |
| 1335 | * This function stores per chain rssi stats received from fw for all vdevs for |
| 1336 | * which the stats were requested into a csr stats structure. |
| 1337 | * |
| 1338 | * Return: void |
| 1339 | */ |
| 1340 | static void wma_update_per_chain_rssi_stats(tp_wma_handle wma, |
| 1341 | wmi_rssi_stats *rssi_stats, |
| 1342 | struct csr_per_chain_rssi_stats_info *rssi_per_chain_stats) |
| 1343 | { |
| 1344 | int i; |
| 1345 | int8_t bcn_snr, dat_snr; |
| 1346 | |
| 1347 | for (i = 0; i < NUM_CHAINS_MAX; i++) { |
| 1348 | bcn_snr = rssi_stats->rssi_avg_beacon[i]; |
| 1349 | dat_snr = rssi_stats->rssi_avg_data[i]; |
| 1350 | WMA_LOGD("chain %d beacon snr %d data snr %d", |
| 1351 | i, bcn_snr, dat_snr); |
| 1352 | if (dat_snr != WMA_TGT_INVALID_SNR) |
| 1353 | rssi_per_chain_stats->rssi[i] = dat_snr; |
| 1354 | else if (bcn_snr != WMA_TGT_INVALID_SNR) |
| 1355 | rssi_per_chain_stats->rssi[i] = bcn_snr; |
| 1356 | else |
| 1357 | /* |
| 1358 | * Firmware sends invalid snr till it sees |
| 1359 | * Beacon/Data after connection since after |
| 1360 | * vdev up fw resets the snr to invalid. |
| 1361 | * In this duartion Host will return an invalid rssi |
| 1362 | * value. |
| 1363 | */ |
| 1364 | rssi_per_chain_stats->rssi[i] = WMA_TGT_RSSI_INVALID; |
| 1365 | |
| 1366 | /* |
| 1367 | * Get the absolute rssi value from the current rssi value the |
| 1368 | * sinr value is hardcoded into 0 in the qcacld-new/CORE stack |
| 1369 | */ |
| 1370 | rssi_per_chain_stats->rssi[i] += WMA_TGT_NOISE_FLOOR_DBM; |
| 1371 | WMI_MAC_ADDR_TO_CHAR_ARRAY(&(rssi_stats->peer_macaddr), |
| 1372 | rssi_per_chain_stats->peer_mac_addr); |
| 1373 | } |
| 1374 | } |
| 1375 | |
| 1376 | /** |
| 1377 | * wma_update_rssi_stats() - to update rssi stats for all vdevs |
| 1378 | * for which the stats were requested. |
| 1379 | * @wma: wma handle |
| 1380 | * @rssi_stats: rssi stats |
| 1381 | * |
| 1382 | * This function updates the rssi stats for all vdevs for which |
| 1383 | * the stats were requested. |
| 1384 | * |
| 1385 | * Return: void |
| 1386 | */ |
| 1387 | static void wma_update_rssi_stats(tp_wma_handle wma, |
| 1388 | wmi_rssi_stats *rssi_stats) |
| 1389 | { |
| 1390 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1391 | struct csr_per_chain_rssi_stats_info *rssi_per_chain_stats = NULL; |
| 1392 | struct wma_txrx_node *node; |
| 1393 | uint8_t *stats_buf; |
| 1394 | uint32_t temp_mask; |
| 1395 | uint8_t vdev_id; |
| 1396 | |
| 1397 | vdev_id = rssi_stats->vdev_id; |
| 1398 | node = &wma->interfaces[vdev_id]; |
| 1399 | if (node->stats_rsp) { |
| 1400 | node->fw_stats_set |= FW_RSSI_PER_CHAIN_STATS_SET; |
| 1401 | WMA_LOGD("<-- FW RSSI PER CHAIN STATS received for vdevId:%d", |
| 1402 | vdev_id); |
| 1403 | stats_rsp_params = (tAniGetPEStatsRsp *) node->stats_rsp; |
| 1404 | stats_buf = (uint8_t *) (stats_rsp_params + 1); |
| 1405 | temp_mask = stats_rsp_params->statsMask; |
| 1406 | |
| 1407 | if (temp_mask & (1 << eCsrSummaryStats)) |
| 1408 | stats_buf += sizeof(tCsrSummaryStatsInfo); |
| 1409 | if (temp_mask & (1 << eCsrGlobalClassAStats)) |
| 1410 | stats_buf += sizeof(tCsrGlobalClassAStatsInfo); |
| 1411 | if (temp_mask & (1 << eCsrGlobalClassBStats)) |
| 1412 | stats_buf += sizeof(tCsrGlobalClassBStatsInfo); |
| 1413 | if (temp_mask & (1 << eCsrGlobalClassCStats)) |
| 1414 | stats_buf += sizeof(tCsrGlobalClassCStatsInfo); |
| 1415 | if (temp_mask & (1 << eCsrGlobalClassDStats)) |
| 1416 | stats_buf += sizeof(tCsrGlobalClassDStatsInfo); |
| 1417 | if (temp_mask & (1 << eCsrPerStaStats)) |
| 1418 | stats_buf += sizeof(tCsrPerStaStatsInfo); |
| 1419 | |
| 1420 | if (temp_mask & (1 << csr_per_chain_rssi_stats)) { |
| 1421 | rssi_per_chain_stats = |
| 1422 | (struct csr_per_chain_rssi_stats_info *)stats_buf; |
| 1423 | wma_update_per_chain_rssi_stats(wma, rssi_stats, |
| 1424 | rssi_per_chain_stats); |
| 1425 | } |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | |
| 1430 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | * wma_link_status_event_handler() - link status event handler |
| 1432 | * @handle: wma handle |
| 1433 | * @cmd_param_info: data from event |
| 1434 | * @len: length |
| 1435 | * |
| 1436 | * Return: 0 for success or error code |
| 1437 | */ |
| 1438 | int wma_link_status_event_handler(void *handle, uint8_t *cmd_param_info, |
| 1439 | uint32_t len) |
| 1440 | { |
| 1441 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1442 | WMI_UPDATE_VDEV_RATE_STATS_EVENTID_param_tlvs *param_buf; |
| 1443 | wmi_vdev_rate_stats_event_fixed_param *event; |
| 1444 | wmi_vdev_rate_ht_info *ht_info; |
| 1445 | struct wma_txrx_node *intr = wma->interfaces; |
| 1446 | uint8_t link_status = LINK_STATUS_LEGACY; |
| 1447 | int i; |
| 1448 | |
| 1449 | param_buf = |
| 1450 | (WMI_UPDATE_VDEV_RATE_STATS_EVENTID_param_tlvs *) cmd_param_info; |
| 1451 | if (!param_buf) { |
| 1452 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 1453 | return -EINVAL; |
| 1454 | } |
| 1455 | |
| 1456 | event = (wmi_vdev_rate_stats_event_fixed_param *) param_buf->fixed_param; |
| 1457 | ht_info = (wmi_vdev_rate_ht_info *) param_buf->ht_info; |
| 1458 | |
| 1459 | WMA_LOGD("num_vdev_stats: %d", event->num_vdev_stats); |
| 1460 | for (i = 0; (i < event->num_vdev_stats) && ht_info; i++) { |
| 1461 | WMA_LOGD("%s vdevId:%d tx_nss:%d rx_nss:%d tx_preamble:%d rx_preamble:%d", |
| 1462 | __func__, ht_info->vdevid, ht_info->tx_nss, |
| 1463 | ht_info->rx_nss, ht_info->tx_preamble, |
| 1464 | ht_info->rx_preamble); |
| 1465 | if (ht_info->vdevid < wma->max_bssid |
| 1466 | && intr[ht_info->vdevid].plink_status_req) { |
| 1467 | if (ht_info->tx_nss || ht_info->rx_nss) |
| 1468 | link_status = LINK_STATUS_MIMO; |
| 1469 | |
| 1470 | if ((ht_info->tx_preamble == LINK_RATE_VHT) || |
| 1471 | (ht_info->rx_preamble == LINK_RATE_VHT)) |
| 1472 | link_status |= LINK_STATUS_VHT; |
| 1473 | |
| 1474 | if (intr[ht_info->vdevid].nss == 2) |
| 1475 | link_status |= LINK_SUPPORT_MIMO; |
| 1476 | |
| 1477 | if (intr[ht_info->vdevid].rate_flags & |
| 1478 | (eHAL_TX_RATE_VHT20 | eHAL_TX_RATE_VHT40 | |
| 1479 | eHAL_TX_RATE_VHT80)) |
| 1480 | link_status |= LINK_SUPPORT_VHT; |
| 1481 | |
| 1482 | wma_post_link_status(intr[ht_info->vdevid].plink_status_req, |
| 1483 | link_status); |
| 1484 | intr[ht_info->vdevid].plink_status_req = NULL; |
| 1485 | link_status = LINK_STATUS_LEGACY; |
| 1486 | } |
| 1487 | |
| 1488 | ht_info++; |
| 1489 | } |
| 1490 | |
| 1491 | return 0; |
| 1492 | } |
| 1493 | |
| 1494 | /** |
| 1495 | * wma_stats_event_handler() - stats event handler |
| 1496 | * @handle: wma handle |
| 1497 | * @cmd_param_info: data from event |
| 1498 | * @len: length |
| 1499 | * |
| 1500 | * Return: 0 for success or error code |
| 1501 | */ |
| 1502 | int wma_stats_event_handler(void *handle, uint8_t *cmd_param_info, |
| 1503 | uint32_t len) |
| 1504 | { |
| 1505 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1506 | WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf; |
| 1507 | wmi_stats_event_fixed_param *event; |
| 1508 | wmi_pdev_stats *pdev_stats; |
| 1509 | wmi_vdev_stats *vdev_stats; |
| 1510 | wmi_peer_stats *peer_stats; |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 1511 | wmi_rssi_stats *rssi_stats; |
| 1512 | wmi_per_chain_rssi_stats *rssi_event; |
| 1513 | struct wma_txrx_node *node; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1514 | uint8_t i, *temp; |
| 1515 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1516 | param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) cmd_param_info; |
| 1517 | if (!param_buf) { |
| 1518 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 1519 | return -EINVAL; |
| 1520 | } |
| 1521 | event = param_buf->fixed_param; |
| 1522 | temp = (uint8_t *) param_buf->data; |
| 1523 | |
| 1524 | WMA_LOGD("%s: num_stats: pdev: %u vdev: %u peer %u", |
| 1525 | __func__, event->num_pdev_stats, event->num_vdev_stats, |
| 1526 | event->num_peer_stats); |
| 1527 | if (event->num_pdev_stats > 0) { |
| 1528 | for (i = 0; i < event->num_pdev_stats; i++) { |
| 1529 | pdev_stats = (wmi_pdev_stats *) temp; |
| 1530 | wma_update_pdev_stats(wma, pdev_stats); |
| 1531 | temp += sizeof(wmi_pdev_stats); |
| 1532 | } |
| 1533 | } |
| 1534 | |
| 1535 | if (event->num_vdev_stats > 0) { |
| 1536 | for (i = 0; i < event->num_vdev_stats; i++) { |
| 1537 | vdev_stats = (wmi_vdev_stats *) temp; |
| 1538 | wma_update_vdev_stats(wma, vdev_stats); |
| 1539 | temp += sizeof(wmi_vdev_stats); |
| 1540 | } |
| 1541 | } |
| 1542 | |
| 1543 | if (event->num_peer_stats > 0) { |
| 1544 | for (i = 0; i < event->num_peer_stats; i++) { |
| 1545 | peer_stats = (wmi_peer_stats *) temp; |
| 1546 | wma_update_peer_stats(wma, peer_stats); |
| 1547 | temp += sizeof(wmi_peer_stats); |
| 1548 | } |
| 1549 | } |
| 1550 | |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 1551 | rssi_event = (wmi_per_chain_rssi_stats *) param_buf->chain_stats; |
| 1552 | if (rssi_event) { |
Himanshu Agarwal | cd8a84a | 2016-07-21 14:59:50 +0530 | [diff] [blame^] | 1553 | if (((rssi_event->tlv_header & 0xFFFF0000) >> 16 == |
| 1554 | WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats) && |
| 1555 | ((rssi_event->tlv_header & 0x0000FFFF) == |
| 1556 | WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats))) { |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 1557 | WMA_LOGD("%s: num_rssi_stats %u", __func__, |
| 1558 | rssi_event->num_per_chain_rssi_stats); |
| 1559 | if (rssi_event->num_per_chain_rssi_stats > 0) { |
| 1560 | temp = (uint8_t *) rssi_event; |
| 1561 | temp += sizeof(*rssi_event); |
| 1562 | for (i = 0; |
| 1563 | i < rssi_event->num_per_chain_rssi_stats; |
| 1564 | i++) { |
| 1565 | rssi_stats = (wmi_rssi_stats *)temp; |
| 1566 | wma_update_rssi_stats(wma, rssi_stats); |
| 1567 | temp += sizeof(wmi_rssi_stats); |
| 1568 | } |
| 1569 | } |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | for (i = 0; i < wma->max_bssid; i++) { |
| 1574 | node = &wma->interfaces[i]; |
| 1575 | if (node->fw_stats_set & FW_PEER_STATS_SET) { |
| 1576 | WMA_LOGD("<--STATS RSP VDEV_ID:%d", i); |
| 1577 | wma_post_stats(wma, node); |
| 1578 | } |
| 1579 | } |
| 1580 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | WMA_LOGI("%s: Exit", __func__); |
| 1582 | return 0; |
| 1583 | } |
| 1584 | |
| 1585 | /** |
| 1586 | * wma_send_link_speed() - send link speed to SME |
| 1587 | * @link_speed: link speed |
| 1588 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1589 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1591 | QDF_STATUS wma_send_link_speed(uint32_t link_speed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1593 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | cds_msg_t sme_msg = { 0 }; |
| 1595 | tSirLinkSpeedInfo *ls_ind = |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1596 | (tSirLinkSpeedInfo *) qdf_mem_malloc(sizeof(tSirLinkSpeedInfo)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1597 | if (!ls_ind) { |
| 1598 | WMA_LOGE("%s: Memory allocation failed.", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1599 | qdf_status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | } else { |
| 1601 | ls_ind->estLinkSpeed = link_speed; |
| 1602 | sme_msg.type = eWNI_SME_LINK_SPEED_IND; |
| 1603 | sme_msg.bodyptr = ls_ind; |
| 1604 | sme_msg.bodyval = 0; |
| 1605 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1606 | qdf_status = cds_mq_post_message(QDF_MODULE_ID_SME, &sme_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1607 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | WMA_LOGE("%s: Fail to post linkspeed ind msg", |
| 1609 | __func__); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1610 | qdf_mem_free(ls_ind); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | } |
| 1612 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1613 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | /** |
| 1617 | * wma_link_speed_event_handler() - link speed event handler |
| 1618 | * @handle: wma handle |
| 1619 | * @cmd_param_info: event data |
| 1620 | * @len: length |
| 1621 | * |
| 1622 | * Return: 0 for success or error code |
| 1623 | */ |
| 1624 | int wma_link_speed_event_handler(void *handle, uint8_t *cmd_param_info, |
| 1625 | uint32_t len) |
| 1626 | { |
| 1627 | WMI_PEER_ESTIMATED_LINKSPEED_EVENTID_param_tlvs *param_buf; |
| 1628 | wmi_peer_estimated_linkspeed_event_fixed_param *event; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1629 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | |
| 1631 | param_buf = |
| 1632 | (WMI_PEER_ESTIMATED_LINKSPEED_EVENTID_param_tlvs *) cmd_param_info; |
| 1633 | if (!param_buf) { |
| 1634 | WMA_LOGE("%s: Invalid linkspeed event", __func__); |
| 1635 | return -EINVAL; |
| 1636 | } |
| 1637 | event = param_buf->fixed_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1638 | qdf_status = wma_send_link_speed(event->est_linkspeed_kbps); |
| 1639 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1640 | return -EINVAL; |
| 1641 | } |
| 1642 | return 0; |
| 1643 | } |
| 1644 | |
| 1645 | /** |
| 1646 | * wma_wni_cfg_dnld() - cfg download request |
| 1647 | * @handle: wma handle |
| 1648 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1649 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1650 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1651 | QDF_STATUS wma_wni_cfg_dnld(tp_wma_handle wma_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1653 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1654 | void *mac = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1655 | |
| 1656 | WMA_LOGD("%s: Enter", __func__); |
| 1657 | |
| 1658 | if (NULL == mac) { |
| 1659 | WMA_LOGP("%s: Invalid context", __func__); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1660 | QDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1661 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | process_cfg_download_req(mac); |
| 1665 | |
| 1666 | WMA_LOGD("%s: Exit", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1667 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1668 | } |
| 1669 | |
| 1670 | /** |
| 1671 | * wma_unified_debug_print_event_handler() - debug print event handler |
| 1672 | * @handle: wma handle |
| 1673 | * @datap: data pointer |
| 1674 | * @len: length |
| 1675 | * |
| 1676 | * Return: 0 for success or error code |
| 1677 | */ |
| 1678 | int wma_unified_debug_print_event_handler(void *handle, uint8_t *datap, |
| 1679 | uint32_t len) |
| 1680 | { |
| 1681 | WMI_DEBUG_PRINT_EVENTID_param_tlvs *param_buf; |
| 1682 | uint8_t *data; |
| 1683 | uint32_t datalen; |
| 1684 | |
| 1685 | param_buf = (WMI_DEBUG_PRINT_EVENTID_param_tlvs *) datap; |
| 1686 | if (!param_buf) { |
| 1687 | WMA_LOGE("Get NULL point message from FW"); |
| 1688 | return -ENOMEM; |
| 1689 | } |
| 1690 | data = param_buf->data; |
| 1691 | datalen = param_buf->num_data; |
| 1692 | |
| 1693 | #ifdef BIG_ENDIAN_HOST |
| 1694 | { |
| 1695 | char dbgbuf[500] = { 0 }; |
| 1696 | memcpy(dbgbuf, data, datalen); |
| 1697 | SWAPME(dbgbuf, datalen); |
| 1698 | WMA_LOGD("FIRMWARE:%s", dbgbuf); |
| 1699 | return 0; |
| 1700 | } |
| 1701 | #else |
| 1702 | WMA_LOGD("FIRMWARE:%s", data); |
| 1703 | return 0; |
| 1704 | #endif /* BIG_ENDIAN_HOST */ |
| 1705 | } |
| 1706 | |
| 1707 | /** |
| 1708 | * wma_check_scan_in_progress() - check scan is progress or not |
| 1709 | * @handle: wma handle |
| 1710 | * |
| 1711 | * Return: true/false |
| 1712 | */ |
| 1713 | bool wma_check_scan_in_progress(WMA_HANDLE handle) |
| 1714 | { |
| 1715 | tp_wma_handle wma_handle = handle; |
| 1716 | int i; |
| 1717 | |
| 1718 | for (i = 0; i < wma_handle->max_bssid; i++) { |
| 1719 | if (wma_handle->interfaces[i].scan_info.scan_id) { |
| 1720 | |
| 1721 | WMA_LOGE("%s: scan in progress on interface[%d],scanid = %d", |
| 1722 | __func__, i, |
| 1723 | wma_handle->interfaces[i].scan_info.scan_id); |
| 1724 | return true; |
| 1725 | } |
| 1726 | } |
| 1727 | return false; |
| 1728 | } |
| 1729 | |
| 1730 | /** |
| 1731 | * wma_is_sap_active() - check sap is active or not |
| 1732 | * @handle: wma handle |
| 1733 | * |
| 1734 | * Return: true/false |
| 1735 | */ |
| 1736 | bool wma_is_sap_active(tp_wma_handle wma_handle) |
| 1737 | { |
| 1738 | int i; |
| 1739 | |
| 1740 | for (i = 0; i < wma_handle->max_bssid; i++) { |
| 1741 | if (!wma_handle->interfaces[i].vdev_up) |
| 1742 | continue; |
| 1743 | if (wma_handle->interfaces[i].type == WMI_VDEV_TYPE_AP && |
| 1744 | wma_handle->interfaces[i].sub_type == 0) |
| 1745 | return true; |
| 1746 | } |
| 1747 | return false; |
| 1748 | } |
| 1749 | |
| 1750 | /** |
| 1751 | * wma_is_p2p_go_active() - check p2p go is active or not |
| 1752 | * @handle: wma handle |
| 1753 | * |
| 1754 | * Return: true/false |
| 1755 | */ |
| 1756 | bool wma_is_p2p_go_active(tp_wma_handle wma_handle) |
| 1757 | { |
| 1758 | int i; |
| 1759 | |
| 1760 | for (i = 0; i < wma_handle->max_bssid; i++) { |
| 1761 | if (!wma_handle->interfaces[i].vdev_up) |
| 1762 | continue; |
| 1763 | if (wma_handle->interfaces[i].type == WMI_VDEV_TYPE_AP && |
| 1764 | wma_handle->interfaces[i].sub_type == |
| 1765 | WMI_UNIFIED_VDEV_SUBTYPE_P2P_GO) |
| 1766 | return true; |
| 1767 | } |
| 1768 | return false; |
| 1769 | } |
| 1770 | |
| 1771 | /** |
| 1772 | * wma_is_p2p_cli_active() - check p2p cli is active or not |
| 1773 | * @handle: wma handle |
| 1774 | * |
| 1775 | * Return: true/false |
| 1776 | */ |
| 1777 | bool wma_is_p2p_cli_active(tp_wma_handle wma_handle) |
| 1778 | { |
| 1779 | int i; |
| 1780 | |
| 1781 | for (i = 0; i < wma_handle->max_bssid; i++) { |
| 1782 | if (!wma_handle->interfaces[i].vdev_up) |
| 1783 | continue; |
| 1784 | if (wma_handle->interfaces[i].type == WMI_VDEV_TYPE_STA && |
| 1785 | wma_handle->interfaces[i].sub_type == |
| 1786 | WMI_UNIFIED_VDEV_SUBTYPE_P2P_CLIENT) |
| 1787 | return true; |
| 1788 | } |
| 1789 | return false; |
| 1790 | } |
| 1791 | |
| 1792 | /** |
| 1793 | * wma_is_sta_active() - check sta is active or not |
| 1794 | * @handle: wma handle |
| 1795 | * |
| 1796 | * Return: true/false |
| 1797 | */ |
| 1798 | bool wma_is_sta_active(tp_wma_handle wma_handle) |
| 1799 | { |
| 1800 | int i; |
| 1801 | |
| 1802 | for (i = 0; i < wma_handle->max_bssid; i++) { |
| 1803 | if (!wma_handle->interfaces[i].vdev_up) |
| 1804 | continue; |
| 1805 | if (wma_handle->interfaces[i].type == WMI_VDEV_TYPE_STA && |
| 1806 | wma_handle->interfaces[i].sub_type == 0) |
| 1807 | return true; |
| 1808 | if (wma_handle->interfaces[i].type == WMI_VDEV_TYPE_IBSS) |
| 1809 | return true; |
| 1810 | } |
| 1811 | return false; |
| 1812 | } |
| 1813 | |
| 1814 | /** |
| 1815 | * wma_peer_phymode() - get phymode |
| 1816 | * @nw_type: nw type |
| 1817 | * @sta_type: sta type |
| 1818 | * @is_ht: is ht supported |
| 1819 | * @is_cw40: is channel width 40 supported |
| 1820 | * @is_vht: is vht supported |
| 1821 | * @is_cw_vht: is channel width 80 supported |
| 1822 | * |
| 1823 | * Return: WLAN_PHY_MODE |
| 1824 | */ |
| 1825 | WLAN_PHY_MODE wma_peer_phymode(tSirNwType nw_type, uint8_t sta_type, |
| 1826 | uint8_t is_ht, uint8_t ch_width, |
| 1827 | uint8_t is_vht) |
| 1828 | { |
| 1829 | WLAN_PHY_MODE phymode = MODE_UNKNOWN; |
| 1830 | |
| 1831 | switch (nw_type) { |
| 1832 | case eSIR_11B_NW_TYPE: |
| 1833 | phymode = MODE_11B; |
| 1834 | if (is_ht || is_vht) |
| 1835 | WMA_LOGE("HT/VHT is enabled with 11B NW type"); |
| 1836 | break; |
| 1837 | case eSIR_11G_NW_TYPE: |
| 1838 | if (!(is_ht || is_vht)) { |
| 1839 | phymode = MODE_11G; |
| 1840 | break; |
| 1841 | } |
| 1842 | if (CH_WIDTH_40MHZ < ch_width) |
| 1843 | WMA_LOGE("80/160 MHz BW sent in 11G, configured 40MHz"); |
| 1844 | if (ch_width) |
| 1845 | phymode = (is_vht) ? |
Krishna Kumaar Natarajan | 294da81 | 2016-04-28 14:39:30 -0700 | [diff] [blame] | 1846 | MODE_11AC_VHT40_2G : MODE_11NG_HT40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1847 | else |
| 1848 | phymode = (is_vht) ? |
Krishna Kumaar Natarajan | 294da81 | 2016-04-28 14:39:30 -0700 | [diff] [blame] | 1849 | MODE_11AC_VHT20_2G : MODE_11NG_HT20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1850 | break; |
| 1851 | case eSIR_11A_NW_TYPE: |
| 1852 | if (!(is_ht || is_vht)) { |
| 1853 | phymode = MODE_11A; |
| 1854 | break; |
| 1855 | } |
| 1856 | if (is_vht) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1857 | if (ch_width == CH_WIDTH_160MHZ) |
| 1858 | phymode = MODE_11AC_VHT160; |
| 1859 | else if (ch_width == CH_WIDTH_80P80MHZ) |
| 1860 | phymode = MODE_11AC_VHT80_80; |
Amar Singhal | 046eb8a | 2016-05-05 12:50:15 -0700 | [diff] [blame] | 1861 | else if (ch_width == CH_WIDTH_80MHZ) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1862 | phymode = MODE_11AC_VHT80; |
| 1863 | else |
| 1864 | phymode = (ch_width) ? |
| 1865 | MODE_11AC_VHT40 : MODE_11AC_VHT20; |
| 1866 | } else |
| 1867 | phymode = (ch_width) ? MODE_11NA_HT40 : MODE_11NA_HT20; |
| 1868 | break; |
| 1869 | default: |
| 1870 | WMA_LOGP("%s: Invalid nw type %d", __func__, nw_type); |
| 1871 | break; |
| 1872 | } |
| 1873 | WMA_LOGD("%s: nw_type %d is_ht %d ch_width %d is_vht %d phymode %d", |
| 1874 | __func__, nw_type, is_ht, ch_width, is_vht, phymode); |
| 1875 | |
| 1876 | return phymode; |
| 1877 | } |
| 1878 | |
| 1879 | /** |
| 1880 | * wma_txrx_fw_stats_reset() - reset txrx fw statistics |
| 1881 | * @wma_handle: wma handle |
| 1882 | * @vdev_id: vdev id |
| 1883 | * @value: value |
| 1884 | * |
| 1885 | * Return: 0 for success or return error |
| 1886 | */ |
| 1887 | int32_t wma_txrx_fw_stats_reset(tp_wma_handle wma_handle, |
| 1888 | uint8_t vdev_id, uint32_t value) |
| 1889 | { |
| 1890 | struct ol_txrx_stats_req req; |
| 1891 | ol_txrx_vdev_handle vdev; |
| 1892 | |
| 1893 | vdev = wma_find_vdev_by_id(wma_handle, vdev_id); |
| 1894 | if (!vdev) { |
| 1895 | WMA_LOGE("%s:Invalid vdev handle", __func__); |
| 1896 | return -EINVAL; |
| 1897 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1898 | qdf_mem_zero(&req, sizeof(req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | req.stats_type_reset_mask = value; |
Nirav Shah | d231042 | 2016-01-21 18:58:06 +0530 | [diff] [blame] | 1900 | ol_txrx_fw_stats_get(vdev, &req, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1901 | |
| 1902 | return 0; |
| 1903 | } |
| 1904 | |
| 1905 | #ifdef HELIUMPLUS |
| 1906 | #define SET_UPLOAD_MASK(_mask, _rate_info) \ |
| 1907 | ((_mask) = 1 << (_rate_info ## _V2)) |
| 1908 | #else /* !HELIUMPLUS */ |
| 1909 | #define SET_UPLOAD_MASK(_mask, _rate_info) \ |
| 1910 | ((_mask) = 1 << (_rate_info)) |
| 1911 | #endif |
| 1912 | |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 1913 | #ifdef HELIUMPLUS |
| 1914 | bool wma_is_valid_fw_stats_cmd(uint32_t value) |
| 1915 | { |
| 1916 | if (value > (HTT_DBG_NUM_STATS + 1) || |
| 1917 | value == (HTT_DBG_STATS_RX_RATE_INFO + 1) || |
| 1918 | value == (HTT_DBG_STATS_TX_RATE_INFO + 1) || |
| 1919 | value == (HTT_DBG_STATS_TXBF_MUSU_NDPA_PKT + 1)) { |
| 1920 | WMA_LOGE("%s: Not supported", __func__); |
| 1921 | return false; |
| 1922 | } |
| 1923 | return true; |
| 1924 | } |
| 1925 | #else |
| 1926 | bool wma_is_valid_fw_stats_cmd(uint32_t value) |
| 1927 | { |
| 1928 | if (value > (HTT_DBG_NUM_STATS + 1) || |
| 1929 | value == (HTT_DBG_STATS_RX_RATE_INFO_V2 + 1) || |
| 1930 | value == (HTT_DBG_STATS_TX_RATE_INFO_V2 + 1) || |
| 1931 | value == (HTT_DBG_STATS_TXBF_MUSU_NDPA_PKT + 1)) { |
| 1932 | WMA_LOGE("%s: Not supported", __func__); |
| 1933 | return false; |
| 1934 | } |
| 1935 | return true; |
| 1936 | } |
| 1937 | #endif |
| 1938 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1939 | /** |
| 1940 | * wma_set_txrx_fw_stats_level() - set txrx fw stats level |
| 1941 | * @wma_handle: wma handle |
| 1942 | * @vdev_id: vdev id |
| 1943 | * @value: value |
| 1944 | * |
| 1945 | * Return: 0 for success or return error |
| 1946 | */ |
| 1947 | int32_t wma_set_txrx_fw_stats_level(tp_wma_handle wma_handle, |
| 1948 | uint8_t vdev_id, uint32_t value) |
| 1949 | { |
| 1950 | struct ol_txrx_stats_req req; |
| 1951 | ol_txrx_vdev_handle vdev; |
| 1952 | uint32_t l_up_mask; |
| 1953 | |
| 1954 | vdev = wma_find_vdev_by_id(wma_handle, vdev_id); |
| 1955 | if (!vdev) { |
| 1956 | WMA_LOGE("%s:Invalid vdev handle", __func__); |
| 1957 | return -EINVAL; |
| 1958 | } |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 1959 | |
| 1960 | if (wma_is_valid_fw_stats_cmd(value) == false) |
| 1961 | return -EINVAL; |
| 1962 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1963 | qdf_mem_zero(&req, sizeof(req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | req.print.verbose = 1; |
| 1965 | |
Nirav Shah | 93e789e | 2016-04-14 19:47:43 +0530 | [diff] [blame] | 1966 | /* TODO: Need to check how to avoid mem leak*/ |
| 1967 | l_up_mask = 1 << (value - 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1968 | req.stats_type_upload_mask = l_up_mask; |
| 1969 | |
Nirav Shah | d231042 | 2016-01-21 18:58:06 +0530 | [diff] [blame] | 1970 | ol_txrx_fw_stats_get(vdev, &req, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | |
| 1972 | return 0; |
| 1973 | } |
| 1974 | |
| 1975 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1976 | * wma_get_stats_rsp_buf() - fill get stats response buffer |
| 1977 | * @get_stats_param: get stats parameters |
| 1978 | * |
| 1979 | * Return: stats response buffer |
| 1980 | */ |
| 1981 | static tAniGetPEStatsRsp *wma_get_stats_rsp_buf |
| 1982 | (tAniGetPEStatsReq *get_stats_param) |
| 1983 | { |
| 1984 | tAniGetPEStatsRsp *stats_rsp_params; |
| 1985 | uint32_t len, temp_mask, counter = 0; |
| 1986 | |
| 1987 | len = sizeof(tAniGetPEStatsRsp); |
| 1988 | temp_mask = get_stats_param->statsMask; |
| 1989 | |
| 1990 | while (temp_mask) { |
| 1991 | if (temp_mask & 1) { |
| 1992 | switch (counter) { |
| 1993 | case eCsrSummaryStats: |
| 1994 | len += sizeof(tCsrSummaryStatsInfo); |
| 1995 | break; |
| 1996 | case eCsrGlobalClassAStats: |
| 1997 | len += sizeof(tCsrGlobalClassAStatsInfo); |
| 1998 | break; |
| 1999 | case eCsrGlobalClassBStats: |
| 2000 | len += sizeof(tCsrGlobalClassBStatsInfo); |
| 2001 | break; |
| 2002 | case eCsrGlobalClassCStats: |
| 2003 | len += sizeof(tCsrGlobalClassCStatsInfo); |
| 2004 | break; |
| 2005 | case eCsrGlobalClassDStats: |
| 2006 | len += sizeof(tCsrGlobalClassDStatsInfo); |
| 2007 | break; |
| 2008 | case eCsrPerStaStats: |
| 2009 | len += sizeof(tCsrPerStaStatsInfo); |
| 2010 | break; |
Himanshu Agarwal | 37e4241 | 2016-07-21 14:35:09 +0530 | [diff] [blame] | 2011 | case csr_per_chain_rssi_stats: |
| 2012 | len += |
| 2013 | sizeof(struct csr_per_chain_rssi_stats_info); |
| 2014 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2015 | } |
| 2016 | } |
| 2017 | |
| 2018 | counter++; |
| 2019 | temp_mask >>= 1; |
| 2020 | } |
| 2021 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2022 | stats_rsp_params = (tAniGetPEStatsRsp *) qdf_mem_malloc(len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2023 | if (!stats_rsp_params) { |
| 2024 | WMA_LOGE("memory allocation failed for tAniGetPEStatsRsp"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2025 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2026 | return NULL; |
| 2027 | } |
| 2028 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2029 | qdf_mem_zero(stats_rsp_params, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2030 | stats_rsp_params->staId = get_stats_param->staId; |
| 2031 | stats_rsp_params->statsMask = get_stats_param->statsMask; |
| 2032 | stats_rsp_params->msgType = WMA_GET_STATISTICS_RSP; |
| 2033 | stats_rsp_params->msgLen = len - sizeof(tAniGetPEStatsRsp); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2034 | stats_rsp_params->rc = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2035 | return stats_rsp_params; |
| 2036 | } |
| 2037 | |
| 2038 | /** |
| 2039 | * wma_get_stats_req() - get stats request |
| 2040 | * @handle: wma handle |
| 2041 | * @get_stats_param: stats params |
| 2042 | * |
| 2043 | * Return: none |
| 2044 | */ |
| 2045 | void wma_get_stats_req(WMA_HANDLE handle, |
| 2046 | tAniGetPEStatsReq *get_stats_param) |
| 2047 | { |
| 2048 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 2049 | struct wma_txrx_node *node; |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 2050 | struct pe_stats_req cmd = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | tAniGetPEStatsRsp *pGetPEStatsRspParams; |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 2052 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2053 | |
| 2054 | WMA_LOGD("%s: Enter", __func__); |
| 2055 | node = &wma_handle->interfaces[get_stats_param->sessionId]; |
| 2056 | if (node->stats_rsp) { |
| 2057 | pGetPEStatsRspParams = node->stats_rsp; |
| 2058 | if (pGetPEStatsRspParams->staId == get_stats_param->staId && |
| 2059 | pGetPEStatsRspParams->statsMask == |
| 2060 | get_stats_param->statsMask) { |
| 2061 | WMA_LOGI("Stats for staId %d with stats mask %d " |
| 2062 | "is pending.... ignore new request", |
| 2063 | get_stats_param->staId, |
| 2064 | get_stats_param->statsMask); |
| 2065 | goto end; |
| 2066 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2067 | qdf_mem_free(node->stats_rsp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2068 | node->stats_rsp = NULL; |
| 2069 | node->fw_stats_set = 0; |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | pGetPEStatsRspParams = wma_get_stats_rsp_buf(get_stats_param); |
| 2074 | if (!pGetPEStatsRspParams) |
| 2075 | goto end; |
| 2076 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2077 | node->fw_stats_set = 0; |
| 2078 | node->stats_rsp = pGetPEStatsRspParams; |
Govind Singh | 4863da4 | 2016-03-08 11:45:00 +0530 | [diff] [blame] | 2079 | |
| 2080 | cmd.session_id = get_stats_param->sessionId; |
| 2081 | if (wmi_unified_get_stats_cmd(wma_handle->wmi_handle, &cmd, |
| 2082 | node->bssid)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2083 | |
| 2084 | WMA_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID", |
| 2085 | __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2086 | goto failed; |
| 2087 | } |
| 2088 | |
| 2089 | goto end; |
| 2090 | failed: |
| 2091 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2092 | pGetPEStatsRspParams->rc = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2093 | node->stats_rsp = NULL; |
| 2094 | /* send response to UMAC */ |
| 2095 | wma_send_msg(wma_handle, WMA_GET_STATISTICS_RSP, pGetPEStatsRspParams, |
| 2096 | 0); |
| 2097 | end: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2098 | qdf_mem_free(get_stats_param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2099 | WMA_LOGD("%s: Exit", __func__); |
| 2100 | return; |
| 2101 | } |
| 2102 | |
| 2103 | /** |
| 2104 | * wma_get_beacon_buffer_by_vdev_id() - get the beacon buffer from vdev ID |
| 2105 | * @vdev_id: vdev id |
| 2106 | * @buffer_size: size of buffer |
| 2107 | * |
| 2108 | * Return: none |
| 2109 | */ |
| 2110 | void *wma_get_beacon_buffer_by_vdev_id(uint8_t vdev_id, uint32_t *buffer_size) |
| 2111 | { |
| 2112 | tp_wma_handle wma; |
| 2113 | struct beacon_info *beacon; |
| 2114 | uint8_t *buf; |
| 2115 | uint32_t buf_size; |
| 2116 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2117 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2118 | if (!wma) { |
| 2119 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2120 | return NULL; |
| 2121 | } |
| 2122 | |
| 2123 | if (vdev_id >= wma->max_bssid) { |
| 2124 | WMA_LOGE("%s: Invalid vdev_id %u", __func__, vdev_id); |
| 2125 | return NULL; |
| 2126 | } |
| 2127 | |
| 2128 | if (!wma_is_vdev_in_ap_mode(wma, vdev_id)) { |
| 2129 | WMA_LOGE("%s: vdevid %d is not in AP mode", __func__, vdev_id); |
| 2130 | return NULL; |
| 2131 | } |
| 2132 | |
| 2133 | beacon = wma->interfaces[vdev_id].beacon; |
| 2134 | |
| 2135 | if (!beacon) { |
| 2136 | WMA_LOGE("%s: beacon invalid", __func__); |
| 2137 | return NULL; |
| 2138 | } |
| 2139 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2140 | qdf_spin_lock_bh(&beacon->lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2141 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2142 | buf_size = qdf_nbuf_len(beacon->buf); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2143 | buf = qdf_mem_malloc(buf_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2144 | |
| 2145 | if (!buf) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2146 | qdf_spin_unlock_bh(&beacon->lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2147 | WMA_LOGE("%s: alloc failed for beacon buf", __func__); |
| 2148 | return NULL; |
| 2149 | } |
| 2150 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2151 | qdf_mem_copy(buf, qdf_nbuf_data(beacon->buf), buf_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2152 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2153 | qdf_spin_unlock_bh(&beacon->lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2154 | |
| 2155 | if (buffer_size) |
| 2156 | *buffer_size = buf_size; |
| 2157 | |
| 2158 | return buf; |
| 2159 | } |
| 2160 | |
| 2161 | /** |
| 2162 | * wma_get_vdev_address_by_vdev_id() - lookup MAC address from vdev ID |
| 2163 | * @vdev_id: vdev id |
| 2164 | * |
| 2165 | * Return: mac address |
| 2166 | */ |
| 2167 | uint8_t *wma_get_vdev_address_by_vdev_id(uint8_t vdev_id) |
| 2168 | { |
| 2169 | tp_wma_handle wma; |
| 2170 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2171 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2172 | if (!wma) { |
| 2173 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2174 | return NULL; |
| 2175 | } |
| 2176 | |
| 2177 | if (vdev_id >= wma->max_bssid) { |
| 2178 | WMA_LOGE("%s: Invalid vdev_id %u", __func__, vdev_id); |
| 2179 | return NULL; |
| 2180 | } |
| 2181 | |
| 2182 | return wma->interfaces[vdev_id].addr; |
| 2183 | } |
| 2184 | |
| 2185 | /** |
| 2186 | * wma_get_interface_by_vdev_id() - lookup interface entry using vdev ID |
| 2187 | * @vdev_id: vdev id |
| 2188 | * |
| 2189 | * Return: entry from vdev table |
| 2190 | */ |
| 2191 | struct wma_txrx_node *wma_get_interface_by_vdev_id(uint8_t vdev_id) |
| 2192 | { |
| 2193 | tp_wma_handle wma; |
| 2194 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2195 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2196 | if (!wma) { |
| 2197 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2198 | return NULL; |
| 2199 | } |
| 2200 | |
| 2201 | if (vdev_id >= wma->max_bssid) { |
| 2202 | WMA_LOGE("%s: Invalid vdev_id %u", __func__, vdev_id); |
| 2203 | return NULL; |
| 2204 | } |
| 2205 | |
| 2206 | return &wma->interfaces[vdev_id]; |
| 2207 | } |
| 2208 | |
| 2209 | /** |
| 2210 | * wma_is_vdev_up() - return whether a vdev is up |
| 2211 | * @vdev_id: vdev id |
| 2212 | * |
| 2213 | * Return: true if the vdev is up, false otherwise |
| 2214 | */ |
| 2215 | bool wma_is_vdev_up(uint8_t vdev_id) |
| 2216 | { |
| 2217 | struct wma_txrx_node *vdev = wma_get_interface_by_vdev_id(vdev_id); |
| 2218 | if (vdev) |
| 2219 | return vdev->vdev_up; |
| 2220 | else |
| 2221 | return false; |
| 2222 | } |
| 2223 | |
| 2224 | #if defined(QCA_WIFI_FTM) |
| 2225 | /** |
| 2226 | * wma_utf_rsp() - utf response |
| 2227 | * @wma_handle: wma handle |
| 2228 | * @payload: payload |
| 2229 | * @len: length of payload |
| 2230 | * |
| 2231 | * Return: 0 for success or error code |
| 2232 | */ |
| 2233 | int wma_utf_rsp(tp_wma_handle wma_handle, uint8_t **payload, uint32_t *len) |
| 2234 | { |
| 2235 | int ret = -1; |
| 2236 | uint32_t payload_len; |
| 2237 | |
| 2238 | payload_len = wma_handle->utf_event_info.length; |
| 2239 | if (payload_len) { |
| 2240 | ret = 0; |
| 2241 | |
| 2242 | /* |
| 2243 | * The first 4 bytes holds the payload size |
| 2244 | * and the actual payload sits next to it |
| 2245 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2246 | *payload = (uint8_t *) qdf_mem_malloc((uint32_t) payload_len |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2247 | + sizeof(A_UINT32)); |
| 2248 | *(A_UINT32 *) &(*payload[0]) = |
| 2249 | wma_handle->utf_event_info.length; |
| 2250 | memcpy(*payload + sizeof(A_UINT32), |
| 2251 | wma_handle->utf_event_info.data, payload_len); |
| 2252 | wma_handle->utf_event_info.length = 0; |
| 2253 | *len = payload_len; |
| 2254 | } |
| 2255 | |
| 2256 | return ret; |
| 2257 | } |
| 2258 | |
| 2259 | /** |
| 2260 | * wma_post_ftm_response() - post ftm response to upper layer |
| 2261 | * @wma_handle: wma handle |
| 2262 | * |
| 2263 | * Return: none |
| 2264 | */ |
| 2265 | static void wma_post_ftm_response(tp_wma_handle wma_handle) |
| 2266 | { |
| 2267 | int ret; |
| 2268 | uint8_t *payload; |
| 2269 | uint32_t data_len; |
| 2270 | cds_msg_t msg = { 0 }; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2271 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2272 | |
| 2273 | ret = wma_utf_rsp(wma_handle, &payload, &data_len); |
| 2274 | |
| 2275 | if (ret) { |
| 2276 | return; |
| 2277 | } |
| 2278 | |
| 2279 | sys_build_message_header(SYS_MSG_ID_FTM_RSP, &msg); |
| 2280 | msg.bodyptr = payload; |
| 2281 | msg.bodyval = 0; |
| 2282 | |
| 2283 | status = cds_mq_post_message(CDS_MQ_ID_SYS, &msg); |
| 2284 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2285 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2286 | WMA_LOGE("failed to post ftm response to SYS"); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2287 | qdf_mem_free(payload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | /** |
| 2292 | * wma_process_utf_event() - process utf event |
| 2293 | * @handle: wma handle |
| 2294 | * @datap: data buffer |
| 2295 | * @dataplen: data length |
| 2296 | * |
| 2297 | * Return: 0 for success or error code |
| 2298 | */ |
| 2299 | static int |
| 2300 | wma_process_utf_event(WMA_HANDLE handle, uint8_t *datap, uint32_t dataplen) |
| 2301 | { |
| 2302 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2303 | struct seg_hdr_info segHdrInfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2304 | uint8_t totalNumOfSegments, currentSeq; |
| 2305 | WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf; |
| 2306 | uint8_t *data; |
| 2307 | uint32_t datalen; |
| 2308 | |
| 2309 | param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *) datap; |
| 2310 | if (!param_buf) { |
| 2311 | WMA_LOGE("Get NULL point message from FW"); |
| 2312 | return -EINVAL; |
| 2313 | } |
| 2314 | data = param_buf->data; |
| 2315 | datalen = param_buf->num_data; |
| 2316 | |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2317 | segHdrInfo = *(struct seg_hdr_info *) &(data[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2318 | |
| 2319 | wma_handle->utf_event_info.currentSeq = (segHdrInfo.segmentInfo & 0xF); |
| 2320 | |
| 2321 | currentSeq = (segHdrInfo.segmentInfo & 0xF); |
| 2322 | totalNumOfSegments = (segHdrInfo.segmentInfo >> 4) & 0xF; |
| 2323 | |
| 2324 | datalen = datalen - sizeof(segHdrInfo); |
| 2325 | |
| 2326 | if (currentSeq == 0) { |
| 2327 | wma_handle->utf_event_info.expectedSeq = 0; |
| 2328 | wma_handle->utf_event_info.offset = 0; |
| 2329 | } else { |
| 2330 | if (wma_handle->utf_event_info.expectedSeq != currentSeq) |
| 2331 | WMA_LOGE("Mismatch in expecting seq expected" |
| 2332 | " Seq %d got seq %d", |
| 2333 | wma_handle->utf_event_info.expectedSeq, |
| 2334 | currentSeq); |
| 2335 | } |
| 2336 | |
| 2337 | memcpy(&wma_handle->utf_event_info. |
| 2338 | data[wma_handle->utf_event_info.offset], |
| 2339 | &data[sizeof(segHdrInfo)], datalen); |
| 2340 | wma_handle->utf_event_info.offset = |
| 2341 | wma_handle->utf_event_info.offset + datalen; |
| 2342 | wma_handle->utf_event_info.expectedSeq++; |
| 2343 | |
| 2344 | if (wma_handle->utf_event_info.expectedSeq == totalNumOfSegments) { |
| 2345 | if (wma_handle->utf_event_info.offset != segHdrInfo.len) |
| 2346 | WMA_LOGE("All segs received total len mismatch.." |
| 2347 | " len %zu total len %d", |
| 2348 | wma_handle->utf_event_info.offset, |
| 2349 | segHdrInfo.len); |
| 2350 | |
| 2351 | wma_handle->utf_event_info.length = |
| 2352 | wma_handle->utf_event_info.offset; |
| 2353 | } |
| 2354 | |
| 2355 | wma_post_ftm_response(wma_handle); |
| 2356 | |
| 2357 | return 0; |
| 2358 | } |
| 2359 | |
| 2360 | /** |
| 2361 | * wma_utf_detach() - utf detach |
| 2362 | * @wma_handle: wma handle |
| 2363 | * |
| 2364 | * Return: none |
| 2365 | */ |
| 2366 | void wma_utf_detach(tp_wma_handle wma_handle) |
| 2367 | { |
| 2368 | if (wma_handle->utf_event_info.data) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2369 | qdf_mem_free(wma_handle->utf_event_info.data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2370 | wma_handle->utf_event_info.data = NULL; |
| 2371 | wma_handle->utf_event_info.length = 0; |
| 2372 | wmi_unified_unregister_event_handler(wma_handle->wmi_handle, |
| 2373 | WMI_PDEV_UTF_EVENTID); |
| 2374 | } |
| 2375 | } |
| 2376 | |
| 2377 | /** |
| 2378 | * wma_utf_attach() - utf attach |
| 2379 | * @wma_handle: wma handle |
| 2380 | * |
| 2381 | * Return: none |
| 2382 | */ |
| 2383 | void wma_utf_attach(tp_wma_handle wma_handle) |
| 2384 | { |
| 2385 | int ret; |
| 2386 | |
| 2387 | wma_handle->utf_event_info.data = (unsigned char *) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2388 | qdf_mem_malloc(MAX_UTF_EVENT_LENGTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2389 | wma_handle->utf_event_info.length = 0; |
| 2390 | |
| 2391 | ret = wmi_unified_register_event_handler(wma_handle->wmi_handle, |
| 2392 | WMI_PDEV_UTF_EVENTID, |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2393 | wma_process_utf_event, |
| 2394 | WMA_RX_SERIALIZER_CTX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2395 | |
| 2396 | if (ret) |
| 2397 | WMA_LOGP("%s: Failed to register UTF event callback", __func__); |
| 2398 | } |
| 2399 | |
| 2400 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2401 | * wma_utf_cmd() - utf command |
| 2402 | * @wma_handle: wma handle |
| 2403 | * @data: data |
| 2404 | * @len: length |
| 2405 | * |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2406 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2407 | */ |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2408 | QDF_STATUS wma_utf_cmd(tp_wma_handle wma_handle, uint8_t *data, uint16_t len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2409 | { |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2410 | struct pdev_utf_params param = {0}; |
| 2411 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2412 | wma_handle->utf_event_info.length = 0; |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 2413 | param.utf_payload = data; |
| 2414 | param.len = len; |
| 2415 | |
| 2416 | return wmi_unified_pdev_utf_cmd_send(wma_handle->wmi_handle, ¶m, |
| 2417 | WMA_WILDCARD_PDEV_ID); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2418 | } |
| 2419 | |
| 2420 | /** |
| 2421 | * wma_process_ftm_command() - process ftm command |
| 2422 | * @wma_handle: wma handle |
| 2423 | * @msg_buffer: message buffer |
| 2424 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2425 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2426 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2427 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2428 | wma_process_ftm_command(tp_wma_handle wma_handle, |
| 2429 | struct ar6k_testmode_cmd_data *msg_buffer) |
| 2430 | { |
| 2431 | uint8_t *data = NULL; |
| 2432 | uint16_t len = 0; |
| 2433 | int ret; |
| 2434 | |
| 2435 | if (!msg_buffer) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2436 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2437 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2438 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2439 | WMA_LOGE("FTM command issued in non-FTM mode"); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2440 | qdf_mem_free(msg_buffer->data); |
| 2441 | qdf_mem_free(msg_buffer); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2442 | return QDF_STATUS_E_NOSUPPORT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2443 | } |
| 2444 | |
| 2445 | data = msg_buffer->data; |
| 2446 | len = msg_buffer->len; |
| 2447 | |
| 2448 | ret = wma_utf_cmd(wma_handle, data, len); |
| 2449 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2450 | qdf_mem_free(msg_buffer->data); |
| 2451 | qdf_mem_free(msg_buffer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2452 | |
| 2453 | if (ret) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2454 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2455 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2456 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2457 | } |
| 2458 | #endif /* QCA_WIFI_FTM */ |
| 2459 | |
| 2460 | /** |
| 2461 | * wma_get_wcnss_software_version() - get wcnss software version |
| 2462 | * @p_cds_gctx: cds context |
| 2463 | * @pVersion: version pointer |
| 2464 | * @versionBufferSize: buffer size |
| 2465 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2466 | * Return: QDF_STATUS_SUCCESS for success or error code |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2467 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2468 | QDF_STATUS wma_get_wcnss_software_version(void *p_cds_gctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2469 | uint8_t *pVersion, |
| 2470 | uint32_t versionBufferSize) |
| 2471 | { |
| 2472 | tp_wma_handle wma_handle; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2473 | wma_handle = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2474 | |
| 2475 | if (NULL == wma_handle) { |
| 2476 | WMA_LOGE("%s: Failed to get wma", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2477 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2478 | } |
| 2479 | |
| 2480 | snprintf(pVersion, versionBufferSize, "%x", |
| 2481 | (unsigned int)wma_handle->target_fw_version); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2482 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2483 | } |
| 2484 | |
| 2485 | /** |
| 2486 | * wma_get_tx_rx_ss_from_config() - Get Tx/Rx spatial stream from HW mode config |
| 2487 | * @mac_ss: Config which indicates the HW mode as per 'hw_mode_ss_config' |
| 2488 | * @tx_ss: Contains the Tx spatial stream |
| 2489 | * @rx_ss: Contains the Rx spatial stream |
| 2490 | * |
| 2491 | * Returns the number of spatial streams of Tx and Rx |
| 2492 | * |
| 2493 | * Return: None |
| 2494 | */ |
| 2495 | void wma_get_tx_rx_ss_from_config(enum hw_mode_ss_config mac_ss, |
| 2496 | uint32_t *tx_ss, |
| 2497 | uint32_t *rx_ss) |
| 2498 | { |
| 2499 | switch (mac_ss) { |
| 2500 | case HW_MODE_SS_0x0: |
| 2501 | *tx_ss = 0; |
| 2502 | *rx_ss = 0; |
| 2503 | break; |
| 2504 | case HW_MODE_SS_1x1: |
| 2505 | *tx_ss = 1; |
| 2506 | *rx_ss = 1; |
| 2507 | break; |
| 2508 | case HW_MODE_SS_2x2: |
| 2509 | *tx_ss = 2; |
| 2510 | *rx_ss = 2; |
| 2511 | break; |
| 2512 | case HW_MODE_SS_3x3: |
| 2513 | *tx_ss = 3; |
| 2514 | *rx_ss = 3; |
| 2515 | break; |
| 2516 | case HW_MODE_SS_4x4: |
| 2517 | *tx_ss = 4; |
| 2518 | *rx_ss = 4; |
| 2519 | break; |
| 2520 | default: |
| 2521 | *tx_ss = 0; |
| 2522 | *rx_ss = 0; |
| 2523 | } |
| 2524 | } |
| 2525 | |
| 2526 | /** |
| 2527 | * wma_get_matching_hw_mode_index() - Get matching HW mode index |
| 2528 | * @wma: WMA handle |
| 2529 | * @mac0_tx_ss: Number of tx spatial streams of MAC0 |
| 2530 | * @mac0_rx_ss: Number of rx spatial streams of MAC0 |
| 2531 | * @mac0_bw: Bandwidth of MAC0 of type 'hw_mode_bandwidth' |
| 2532 | * @mac1_tx_ss: Number of tx spatial streams of MAC1 |
| 2533 | * @mac1_rx_ss: Number of rx spatial streams of MAC1 |
| 2534 | * @mac1_bw: Bandwidth of MAC1 of type 'hw_mode_bandwidth' |
| 2535 | * @dbs: DBS capability of type 'hw_mode_dbs_capab' |
| 2536 | * @dfs: Agile DFS capability of type 'hw_mode_agile_dfs_capab' |
| 2537 | * |
| 2538 | * Fetches the HW mode index corresponding to the HW mode provided |
| 2539 | * |
| 2540 | * Return: Positive hw mode index in case a match is found or a negative |
| 2541 | * value, otherwise |
| 2542 | */ |
| 2543 | static int8_t wma_get_matching_hw_mode_index(tp_wma_handle wma, |
| 2544 | uint32_t mac0_tx_ss, uint32_t mac0_rx_ss, |
| 2545 | enum hw_mode_bandwidth mac0_bw, |
| 2546 | uint32_t mac1_tx_ss, uint32_t mac1_rx_ss, |
| 2547 | enum hw_mode_bandwidth mac1_bw, |
| 2548 | enum hw_mode_dbs_capab dbs, |
| 2549 | enum hw_mode_agile_dfs_capab dfs) |
| 2550 | { |
| 2551 | uint32_t i; |
| 2552 | uint32_t t_mac0_tx_ss, t_mac0_rx_ss, t_mac0_bw; |
| 2553 | uint32_t t_mac1_tx_ss, t_mac1_rx_ss, t_mac1_bw; |
| 2554 | uint32_t dbs_mode, agile_dfs_mode; |
| 2555 | int8_t found = -EINVAL; |
| 2556 | |
| 2557 | if (!wma) { |
| 2558 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2559 | return found; |
| 2560 | } |
| 2561 | |
| 2562 | for (i = 0; i < wma->num_dbs_hw_modes; i++) { |
| 2563 | t_mac0_tx_ss = WMI_DBS_HW_MODE_MAC0_TX_STREAMS_GET( |
| 2564 | wma->hw_mode.hw_mode_list[i]); |
| 2565 | if (t_mac0_tx_ss != mac0_tx_ss) |
| 2566 | continue; |
| 2567 | |
| 2568 | t_mac0_rx_ss = WMI_DBS_HW_MODE_MAC0_RX_STREAMS_GET( |
| 2569 | wma->hw_mode.hw_mode_list[i]); |
| 2570 | if (t_mac0_rx_ss != mac0_rx_ss) |
| 2571 | continue; |
| 2572 | |
| 2573 | t_mac0_bw = WMI_DBS_HW_MODE_MAC0_BANDWIDTH_GET( |
| 2574 | wma->hw_mode.hw_mode_list[i]); |
| 2575 | if (t_mac0_bw != mac0_bw) |
| 2576 | continue; |
| 2577 | |
| 2578 | t_mac1_tx_ss = WMI_DBS_HW_MODE_MAC1_TX_STREAMS_GET( |
| 2579 | wma->hw_mode.hw_mode_list[i]); |
| 2580 | if (t_mac1_tx_ss != mac1_tx_ss) |
| 2581 | continue; |
| 2582 | |
| 2583 | t_mac1_rx_ss = WMI_DBS_HW_MODE_MAC1_RX_STREAMS_GET( |
| 2584 | wma->hw_mode.hw_mode_list[i]); |
| 2585 | if (t_mac1_rx_ss != mac1_rx_ss) |
| 2586 | continue; |
| 2587 | |
| 2588 | t_mac1_bw = WMI_DBS_HW_MODE_MAC1_BANDWIDTH_GET( |
| 2589 | wma->hw_mode.hw_mode_list[i]); |
| 2590 | if (t_mac1_bw != mac1_bw) |
| 2591 | continue; |
| 2592 | |
| 2593 | dbs_mode = WMI_DBS_HW_MODE_DBS_MODE_GET( |
| 2594 | wma->hw_mode.hw_mode_list[i]); |
| 2595 | if (dbs_mode != dbs) |
| 2596 | continue; |
| 2597 | |
| 2598 | agile_dfs_mode = WMI_DBS_HW_MODE_AGILE_DFS_GET( |
| 2599 | wma->hw_mode.hw_mode_list[i]); |
| 2600 | if (agile_dfs_mode != dfs) |
| 2601 | continue; |
| 2602 | |
| 2603 | found = i; |
| 2604 | WMA_LOGI("%s: hw_mode index %d found", |
| 2605 | __func__, i); |
| 2606 | break; |
| 2607 | } |
| 2608 | return found; |
| 2609 | } |
| 2610 | |
| 2611 | /** |
| 2612 | * wma_get_hw_mode_from_dbs_hw_list() - Get hw_mode index |
| 2613 | * @mac0_ss: MAC0 spatial stream configuration |
| 2614 | * @mac0_bw: MAC0 bandwidth configuration |
| 2615 | * @mac1_ss: MAC1 spatial stream configuration |
| 2616 | * @mac1_bw: MAC1 bandwidth configuration |
| 2617 | * @dbs: HW DBS capability |
| 2618 | * @dfs: HW Agile DFS capability |
| 2619 | * |
| 2620 | * Get the HW mode index corresponding to the HW modes spatial stream, |
| 2621 | * bandwidth, DBS and Agile DFS capability |
| 2622 | * |
| 2623 | * Return: Index number if a match is found or -negative value if not found |
| 2624 | */ |
| 2625 | int8_t wma_get_hw_mode_idx_from_dbs_hw_list(enum hw_mode_ss_config mac0_ss, |
| 2626 | enum hw_mode_bandwidth mac0_bw, |
| 2627 | enum hw_mode_ss_config mac1_ss, |
| 2628 | enum hw_mode_bandwidth mac1_bw, |
| 2629 | enum hw_mode_dbs_capab dbs, |
| 2630 | enum hw_mode_agile_dfs_capab dfs) |
| 2631 | { |
| 2632 | tp_wma_handle wma; |
| 2633 | uint32_t mac0_tx_ss, mac0_rx_ss; |
| 2634 | uint32_t mac1_tx_ss, mac1_rx_ss; |
| 2635 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2636 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2637 | if (!wma) { |
| 2638 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2639 | return -EINVAL; |
| 2640 | } |
| 2641 | |
| 2642 | wma_get_tx_rx_ss_from_config(mac0_ss, &mac0_tx_ss, &mac0_rx_ss); |
| 2643 | wma_get_tx_rx_ss_from_config(mac1_ss, &mac1_tx_ss, &mac1_rx_ss); |
| 2644 | |
| 2645 | WMA_LOGI("%s: MAC0: TxSS=%d, RxSS=%d, BW=%d", |
| 2646 | __func__, mac0_tx_ss, mac0_rx_ss, mac0_bw); |
| 2647 | WMA_LOGI("%s: MAC1: TxSS=%d, RxSS=%d, BW=%d", |
| 2648 | __func__, mac1_tx_ss, mac1_rx_ss, mac1_bw); |
| 2649 | WMA_LOGI("%s: DBS capab=%d, Agile DFS capab=%d", |
| 2650 | __func__, dbs, dfs); |
| 2651 | |
| 2652 | return wma_get_matching_hw_mode_index(wma, mac0_tx_ss, mac0_rx_ss, |
| 2653 | mac0_bw, |
| 2654 | mac1_tx_ss, mac1_rx_ss, |
| 2655 | mac1_bw, |
| 2656 | dbs, dfs); |
| 2657 | } |
| 2658 | |
| 2659 | /** |
| 2660 | * wma_get_hw_mode_from_idx() - Get HW mode based on index |
| 2661 | * @idx: HW mode index |
| 2662 | * @hw_mode: HW mode params |
| 2663 | * |
| 2664 | * Fetches the HW mode parameters |
| 2665 | * |
| 2666 | * Return: Success if hw mode is obtained and the hw mode params |
| 2667 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2668 | QDF_STATUS wma_get_hw_mode_from_idx(uint32_t idx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2669 | struct sir_hw_mode_params *hw_mode) |
| 2670 | { |
| 2671 | tp_wma_handle wma; |
| 2672 | uint32_t param; |
| 2673 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2674 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2675 | if (!wma) { |
| 2676 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2677 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2678 | } |
| 2679 | |
| 2680 | if (idx > wma->num_dbs_hw_modes) { |
| 2681 | WMA_LOGE("%s: Invalid index", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2682 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2683 | } |
| 2684 | |
Mahesh Kumar Kalikot Veetil | d43e165 | 2015-11-02 15:35:10 -0800 | [diff] [blame] | 2685 | if (!wma->num_dbs_hw_modes) { |
| 2686 | WMA_LOGE("%s: No dbs hw modes available", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2687 | return QDF_STATUS_E_FAILURE; |
Mahesh Kumar Kalikot Veetil | d43e165 | 2015-11-02 15:35:10 -0800 | [diff] [blame] | 2688 | } |
| 2689 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | param = wma->hw_mode.hw_mode_list[idx]; |
| 2691 | |
| 2692 | hw_mode->mac0_tx_ss = WMI_DBS_HW_MODE_MAC0_TX_STREAMS_GET(param); |
| 2693 | hw_mode->mac0_rx_ss = WMI_DBS_HW_MODE_MAC0_RX_STREAMS_GET(param); |
| 2694 | hw_mode->mac0_bw = WMI_DBS_HW_MODE_MAC0_BANDWIDTH_GET(param); |
| 2695 | hw_mode->mac1_tx_ss = WMI_DBS_HW_MODE_MAC1_TX_STREAMS_GET(param); |
| 2696 | hw_mode->mac1_rx_ss = WMI_DBS_HW_MODE_MAC1_RX_STREAMS_GET(param); |
| 2697 | hw_mode->mac1_bw = WMI_DBS_HW_MODE_MAC1_BANDWIDTH_GET(param); |
| 2698 | hw_mode->dbs_cap = WMI_DBS_HW_MODE_DBS_MODE_GET(param); |
| 2699 | hw_mode->agile_dfs_cap = WMI_DBS_HW_MODE_AGILE_DFS_GET(param); |
| 2700 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2701 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2702 | } |
| 2703 | |
| 2704 | /** |
| 2705 | * wma_get_num_dbs_hw_modes() - Get number of HW mode |
| 2706 | * |
| 2707 | * Fetches the number of DBS HW modes returned by the FW |
| 2708 | * |
| 2709 | * Return: Negative value on error or returns the number of DBS HW modes |
| 2710 | */ |
| 2711 | int8_t wma_get_num_dbs_hw_modes(void) |
| 2712 | { |
| 2713 | tp_wma_handle wma; |
| 2714 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2715 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2716 | if (!wma) { |
| 2717 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2718 | return -EINVAL; |
| 2719 | } |
| 2720 | return wma->num_dbs_hw_modes; |
| 2721 | } |
| 2722 | |
| 2723 | /** |
| 2724 | * wma_is_hw_dbs_capable() - Check if HW is DBS capable |
| 2725 | * |
| 2726 | * Checks if the HW is DBS capable |
| 2727 | * |
| 2728 | * Return: true if the HW is DBS capable |
| 2729 | */ |
| 2730 | bool wma_is_hw_dbs_capable(void) |
| 2731 | { |
| 2732 | tp_wma_handle wma; |
| 2733 | uint32_t param, i, found = 0; |
| 2734 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2735 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2736 | if (!wma) { |
| 2737 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2738 | return false; |
| 2739 | } |
| 2740 | |
| 2741 | if (!wma_is_dbs_enable()) { |
| 2742 | WMA_LOGI("%s: DBS is disabled", __func__); |
| 2743 | return false; |
| 2744 | } |
| 2745 | |
| 2746 | WMA_LOGI("%s: DBS service bit map: %d", __func__, |
| 2747 | WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 2748 | WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT)); |
| 2749 | |
| 2750 | /* The agreement with FW is that: To know if the target is DBS |
| 2751 | * capable, DBS needs to be supported both in the HW mode list |
| 2752 | * and in the service ready event |
| 2753 | */ |
| 2754 | if (!(WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 2755 | WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT))) |
| 2756 | return false; |
| 2757 | |
| 2758 | for (i = 0; i < wma->num_dbs_hw_modes; i++) { |
| 2759 | param = wma->hw_mode.hw_mode_list[i]; |
| 2760 | WMA_LOGI("%s: HW param: %x", __func__, param); |
| 2761 | if (WMI_DBS_HW_MODE_DBS_MODE_GET(param)) { |
| 2762 | WMA_LOGI("%s: HW (%d) is DBS capable", __func__, i); |
| 2763 | found = 1; |
| 2764 | break; |
| 2765 | } |
| 2766 | } |
| 2767 | |
| 2768 | if (found) |
| 2769 | return true; |
| 2770 | |
| 2771 | return false; |
| 2772 | } |
| 2773 | |
| 2774 | /** |
| 2775 | * wma_is_hw_agile_dfs_capable() - Check if HW is agile DFS capable |
| 2776 | * |
| 2777 | * Checks if the HW is agile DFS capable |
| 2778 | * |
| 2779 | * Return: true if the HW is agile DFS capable |
| 2780 | */ |
| 2781 | bool wma_is_hw_agile_dfs_capable(void) |
| 2782 | { |
| 2783 | tp_wma_handle wma; |
| 2784 | uint32_t param, i, found = 0; |
| 2785 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2786 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2787 | if (!wma) { |
| 2788 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2789 | return false; |
| 2790 | } |
| 2791 | |
| 2792 | if (!wma_is_agile_dfs_enable()) { |
| 2793 | WMA_LOGI("%s: Agile DFS is disabled", __func__); |
| 2794 | return false; |
| 2795 | } |
| 2796 | |
| 2797 | WMA_LOGI("%s: DBS service bit map: %d", __func__, |
| 2798 | WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 2799 | WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT)); |
| 2800 | |
| 2801 | /* The agreement with FW is that to know if the target is Agile DFS |
| 2802 | * capable, DBS needs to be supported in the service bit map and |
| 2803 | * Agile DFS needs to be supported in the HW mode list |
| 2804 | */ |
| 2805 | if (!(WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 2806 | WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT))) |
| 2807 | return false; |
| 2808 | |
| 2809 | for (i = 0; i < wma->num_dbs_hw_modes; i++) { |
| 2810 | param = wma->hw_mode.hw_mode_list[i]; |
| 2811 | WMA_LOGI("%s: HW param: %x", __func__, param); |
| 2812 | if (WMI_DBS_HW_MODE_AGILE_DFS_GET(param)) { |
| 2813 | WMA_LOGI("%s: HW %d is agile DFS capable", |
| 2814 | __func__, i); |
| 2815 | found = 1; |
| 2816 | break; |
| 2817 | } |
| 2818 | } |
| 2819 | |
| 2820 | if (found) |
| 2821 | return true; |
| 2822 | |
| 2823 | return false; |
| 2824 | } |
| 2825 | |
| 2826 | /** |
| 2827 | * wma_get_mac_id_of_vdev() - Get MAC id corresponding to a vdev |
| 2828 | * @vdev_id: VDEV whose MAC ID is required |
| 2829 | * |
| 2830 | * Get MAC id corresponding to a vdev id from the WMA structure |
| 2831 | * |
| 2832 | * Return: Negative value on failure and MAC id on success |
| 2833 | */ |
| 2834 | int8_t wma_get_mac_id_of_vdev(uint32_t vdev_id) |
| 2835 | { |
| 2836 | tp_wma_handle wma; |
| 2837 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2838 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2839 | if (!wma) { |
| 2840 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2841 | return -EINVAL; |
| 2842 | } |
| 2843 | |
| 2844 | if (wma->interfaces) |
| 2845 | return wma->interfaces[vdev_id].mac_id; |
| 2846 | |
| 2847 | return -EINVAL; |
| 2848 | } |
| 2849 | |
| 2850 | /** |
| 2851 | * wma_get_old_and_new_hw_index() - Get the old and new HW index |
| 2852 | * @old_hw_mode_index: Value at this pointer contains the old HW mode index |
| 2853 | * Default value when not configured is WMA_DEFAULT_HW_MODE_INDEX |
| 2854 | * @new_hw_mode_index: Value at this pointer contains the new HW mode index |
| 2855 | * Default value when not configured is WMA_DEFAULT_HW_MODE_INDEX |
| 2856 | * |
| 2857 | * Get the old and new HW index configured in the driver |
| 2858 | * |
| 2859 | * Return: Failure in case the HW mode indices cannot be fetched and Success |
| 2860 | * otherwise. When no HW mode transition has happened the values of |
| 2861 | * old_hw_mode_index and new_hw_mode_index will be the same. |
| 2862 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2863 | QDF_STATUS wma_get_old_and_new_hw_index(uint32_t *old_hw_mode_index, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2864 | uint32_t *new_hw_mode_index) |
| 2865 | { |
| 2866 | tp_wma_handle wma; |
| 2867 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2868 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2869 | if (!wma) { |
| 2870 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2871 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2872 | } |
| 2873 | |
| 2874 | *old_hw_mode_index = wma->old_hw_mode_index; |
| 2875 | *new_hw_mode_index = wma->new_hw_mode_index; |
| 2876 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2877 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2878 | } |
| 2879 | |
| 2880 | /** |
| 2881 | * wma_update_intf_hw_mode_params() - Update WMA params |
| 2882 | * @vdev_id: VDEV id whose params needs to be updated |
| 2883 | * @mac_id: MAC id to be updated |
| 2884 | * @cfgd_hw_mode_index: HW mode index from which Tx and Rx SS will be updated |
| 2885 | * |
| 2886 | * Updates the MAC id, tx spatial stream, rx spatial stream in WMA |
| 2887 | * |
| 2888 | * Return: None |
| 2889 | */ |
| 2890 | void wma_update_intf_hw_mode_params(uint32_t vdev_id, uint32_t mac_id, |
| 2891 | uint32_t cfgd_hw_mode_index) |
| 2892 | { |
| 2893 | tp_wma_handle wma; |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2894 | uint32_t param; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2895 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2896 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2897 | if (!wma) { |
| 2898 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 2899 | return; |
| 2900 | } |
| 2901 | |
| 2902 | if (!wma->interfaces) { |
| 2903 | WMA_LOGE("%s: Interface is NULL", __func__); |
| 2904 | return; |
| 2905 | } |
| 2906 | |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2907 | if (cfgd_hw_mode_index > wma->num_dbs_hw_modes) { |
| 2908 | WMA_LOGE("%s: Invalid index", __func__); |
| 2909 | return; |
| 2910 | } |
| 2911 | |
| 2912 | param = wma->hw_mode.hw_mode_list[cfgd_hw_mode_index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | wma->interfaces[vdev_id].mac_id = mac_id; |
| 2914 | if (mac_id == 0) { |
| 2915 | wma->interfaces[vdev_id].tx_streams = |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2916 | WMI_DBS_HW_MODE_MAC0_TX_STREAMS_GET(param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2917 | wma->interfaces[vdev_id].rx_streams = |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2918 | WMI_DBS_HW_MODE_MAC0_RX_STREAMS_GET(param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2919 | } else { |
| 2920 | wma->interfaces[vdev_id].tx_streams = |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2921 | WMI_DBS_HW_MODE_MAC1_TX_STREAMS_GET(param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2922 | wma->interfaces[vdev_id].rx_streams = |
Tushnim Bhattacharyya | 206bcac | 2015-11-10 15:20:06 -0800 | [diff] [blame] | 2923 | WMI_DBS_HW_MODE_MAC1_RX_STREAMS_GET(param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2924 | } |
| 2925 | } |
| 2926 | |
| 2927 | /** |
| 2928 | * wma_get_dbs_hw_modes() - Get the DBS HW modes for userspace |
| 2929 | * @one_by_one_dbs: 1x1 DBS capability of HW |
| 2930 | * @two_by_two_dbs: 2x2 DBS capability of HW |
| 2931 | * |
| 2932 | * Provides the DBS HW mode capability such as whether |
| 2933 | * 1x1 DBS, 2x2 DBS is supported by the HW or not. |
| 2934 | * |
| 2935 | * Return: Failure in case of error and 0 on success |
| 2936 | * one_by_one_dbs/two_by_two_dbs will be false, |
| 2937 | * if they are not supported. |
| 2938 | * one_by_one_dbs/two_by_two_dbs will be true, |
| 2939 | * if they are supported. |
| 2940 | * false values of one_by_one_dbs/two_by_two_dbs, |
| 2941 | * indicate DBS is disabled |
| 2942 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2943 | QDF_STATUS wma_get_dbs_hw_modes(bool *one_by_one_dbs, bool *two_by_two_dbs) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2944 | { |
| 2945 | tp_wma_handle wma; |
| 2946 | uint32_t i; |
| 2947 | int8_t found_one_by_one = -EINVAL, found_two_by_two = -EINVAL; |
| 2948 | uint32_t conf1_tx_ss, conf1_rx_ss; |
| 2949 | uint32_t conf2_tx_ss, conf2_rx_ss; |
| 2950 | |
| 2951 | *one_by_one_dbs = false; |
| 2952 | *two_by_two_dbs = false; |
| 2953 | |
| 2954 | if (wma_is_hw_dbs_capable() == false) { |
| 2955 | WMA_LOGE("%s: HW is not DBS capable", __func__); |
| 2956 | /* Caller will understand that DBS is disabled */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2957 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2958 | |
| 2959 | } |
| 2960 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2961 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2962 | if (!wma) { |
| 2963 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2964 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2965 | } |
| 2966 | |
| 2967 | /* To check 1x1 capability */ |
| 2968 | wma_get_tx_rx_ss_from_config(HW_MODE_SS_1x1, |
| 2969 | &conf1_tx_ss, &conf1_rx_ss); |
| 2970 | /* To check 2x2 capability */ |
| 2971 | wma_get_tx_rx_ss_from_config(HW_MODE_SS_2x2, |
| 2972 | &conf2_tx_ss, &conf2_rx_ss); |
| 2973 | |
| 2974 | for (i = 0; i < wma->num_dbs_hw_modes; i++) { |
| 2975 | uint32_t t_conf0_tx_ss, t_conf0_rx_ss; |
| 2976 | uint32_t t_conf1_tx_ss, t_conf1_rx_ss; |
| 2977 | uint32_t dbs_mode; |
| 2978 | |
| 2979 | t_conf0_tx_ss = WMI_DBS_HW_MODE_MAC0_TX_STREAMS_GET( |
| 2980 | wma->hw_mode.hw_mode_list[i]); |
| 2981 | t_conf0_rx_ss = WMI_DBS_HW_MODE_MAC0_RX_STREAMS_GET( |
| 2982 | wma->hw_mode.hw_mode_list[i]); |
| 2983 | t_conf1_tx_ss = WMI_DBS_HW_MODE_MAC1_TX_STREAMS_GET( |
| 2984 | wma->hw_mode.hw_mode_list[i]); |
| 2985 | t_conf1_rx_ss = WMI_DBS_HW_MODE_MAC1_RX_STREAMS_GET( |
| 2986 | wma->hw_mode.hw_mode_list[i]); |
| 2987 | dbs_mode = WMI_DBS_HW_MODE_DBS_MODE_GET( |
| 2988 | wma->hw_mode.hw_mode_list[i]); |
| 2989 | |
| 2990 | if (((((t_conf0_tx_ss == conf1_tx_ss) && |
| 2991 | (t_conf0_rx_ss == conf1_rx_ss)) || |
| 2992 | ((t_conf1_tx_ss == conf1_tx_ss) && |
| 2993 | (t_conf1_rx_ss == conf1_rx_ss))) && |
| 2994 | (dbs_mode == HW_MODE_DBS)) && |
| 2995 | (found_one_by_one < 0)) { |
| 2996 | found_one_by_one = i; |
| 2997 | WMA_LOGI("%s: 1x1 hw_mode index %d found", |
| 2998 | __func__, i); |
| 2999 | /* Once an entry is found, need not check for 1x1 |
| 3000 | * again |
| 3001 | */ |
| 3002 | continue; |
| 3003 | } |
| 3004 | |
| 3005 | if (((((t_conf0_tx_ss == conf2_tx_ss) && |
| 3006 | (t_conf0_rx_ss == conf2_rx_ss)) || |
| 3007 | ((t_conf1_tx_ss == conf2_tx_ss) && |
| 3008 | (t_conf1_rx_ss == conf2_rx_ss))) && |
| 3009 | (dbs_mode == HW_MODE_DBS)) && |
| 3010 | (found_two_by_two < 0)) { |
| 3011 | found_two_by_two = i; |
| 3012 | WMA_LOGI("%s: 2x2 hw_mode index %d found", |
| 3013 | __func__, i); |
| 3014 | /* Once an entry is found, need not check for 2x2 |
| 3015 | * again |
| 3016 | */ |
| 3017 | continue; |
| 3018 | } |
| 3019 | } |
| 3020 | |
| 3021 | if (found_one_by_one >= 0) |
| 3022 | *one_by_one_dbs = true; |
| 3023 | if (found_two_by_two >= 0) |
| 3024 | *two_by_two_dbs = true; |
| 3025 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3026 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3027 | } |
| 3028 | |
| 3029 | /** |
| 3030 | * wma_get_current_hw_mode() - Get current HW mode params |
| 3031 | * @hw_mode: HW mode parameters |
| 3032 | * |
| 3033 | * Provides the current HW mode parameters if the HW mode is initialized |
| 3034 | * in the driver |
| 3035 | * |
| 3036 | * Return: Success if the current HW mode params are successfully populated |
| 3037 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3038 | QDF_STATUS wma_get_current_hw_mode(struct sir_hw_mode_params *hw_mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3039 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3040 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3041 | uint32_t old_hw_index = 0, new_hw_index = 0; |
| 3042 | |
| 3043 | WMA_LOGI("%s: Get the current hw mode", __func__); |
| 3044 | |
| 3045 | status = wma_get_old_and_new_hw_index(&old_hw_index, |
| 3046 | &new_hw_index); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3047 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | WMA_LOGE("%s: Failed to get HW mode index", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3049 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3050 | } |
| 3051 | |
| 3052 | if (new_hw_index == WMA_DEFAULT_HW_MODE_INDEX) { |
| 3053 | WMA_LOGE("%s: HW mode is not yet initialized", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3054 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | } |
| 3056 | |
| 3057 | status = wma_get_hw_mode_from_idx(new_hw_index, hw_mode); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3058 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | WMA_LOGE("%s: Failed to get HW mode index", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3060 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3061 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3062 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | } |
| 3064 | |
| 3065 | /** |
| 3066 | * wma_is_dbs_enable() - Check if master DBS control is enabled |
| 3067 | * |
| 3068 | * Checks if the master DBS control is enabled. This will be used |
| 3069 | * to override any other DBS capability |
| 3070 | * |
| 3071 | * Return: True if master DBS control is enabled |
| 3072 | */ |
| 3073 | bool wma_is_dbs_enable(void) |
| 3074 | { |
| 3075 | tp_wma_handle wma; |
| 3076 | |
| 3077 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3078 | return false; |
| 3079 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3080 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3081 | if (!wma) { |
| 3082 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3083 | return false; |
| 3084 | } |
| 3085 | |
| 3086 | WMA_LOGD("%s: DBS=%d", __func__, |
| 3087 | WMI_DBS_FW_MODE_CFG_DBS_GET(wma->dual_mac_cfg.cur_fw_mode_config)); |
| 3088 | |
| 3089 | if (WMI_DBS_FW_MODE_CFG_DBS_GET(wma->dual_mac_cfg.cur_fw_mode_config)) |
| 3090 | return true; |
| 3091 | |
| 3092 | return false; |
| 3093 | } |
| 3094 | |
| 3095 | /** |
| 3096 | * wma_is_agile_dfs_enable() - Check if master Agile DFS control is enabled |
| 3097 | * |
| 3098 | * Checks if the master Agile DFS control is enabled. This will be used |
| 3099 | * to override any other Agile DFS capability |
| 3100 | * |
| 3101 | * Return: True if master Agile DFS control is enabled |
| 3102 | */ |
| 3103 | bool wma_is_agile_dfs_enable(void) |
| 3104 | { |
| 3105 | tp_wma_handle wma; |
| 3106 | |
| 3107 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3108 | return false; |
| 3109 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3110 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3111 | if (!wma) { |
| 3112 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3113 | return false; |
| 3114 | } |
| 3115 | |
| 3116 | WMA_LOGD("%s: DFS=%d Single mac with DFS=%d", __func__, |
| 3117 | WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET( |
| 3118 | wma->dual_mac_cfg.cur_fw_mode_config), |
| 3119 | WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET( |
| 3120 | wma->dual_mac_cfg.cur_scan_config)); |
| 3121 | |
| 3122 | if ((WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET( |
| 3123 | wma->dual_mac_cfg.cur_fw_mode_config)) && |
| 3124 | (WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET( |
| 3125 | wma->dual_mac_cfg.cur_scan_config))) |
| 3126 | return true; |
| 3127 | |
| 3128 | return false; |
| 3129 | } |
| 3130 | |
| 3131 | /** |
| 3132 | * wma_get_updated_scan_config() - Get the updated scan configuration |
| 3133 | * @scan_config: Pointer containing the updated scan config |
| 3134 | * @dbs_scan: 0 or 1 indicating if DBS scan needs to be enabled/disabled |
| 3135 | * @dbs_plus_agile_scan: 0 or 1 indicating if DBS plus agile scan needs to be |
| 3136 | * enabled/disabled |
| 3137 | * @single_mac_scan_with_dfs: 0 or 1 indicating if single MAC scan with DFS |
| 3138 | * needs to be enabled/disabled |
| 3139 | * |
| 3140 | * Takes the current scan configuration and set the necessary scan config |
| 3141 | * bits to either 0/1 and provides the updated value to the caller who |
| 3142 | * can use this to pass it on to the FW |
| 3143 | * |
| 3144 | * Return: 0 on success |
| 3145 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3146 | QDF_STATUS wma_get_updated_scan_config(uint32_t *scan_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3147 | bool dbs_scan, |
| 3148 | bool dbs_plus_agile_scan, |
| 3149 | bool single_mac_scan_with_dfs) |
| 3150 | { |
| 3151 | tp_wma_handle wma; |
| 3152 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3153 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3154 | if (!wma) { |
| 3155 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3156 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3157 | } |
| 3158 | *scan_config = wma->dual_mac_cfg.cur_scan_config; |
| 3159 | |
| 3160 | WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_SET(*scan_config, dbs_scan); |
| 3161 | WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_SET(*scan_config, |
| 3162 | dbs_plus_agile_scan); |
| 3163 | WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_SET(*scan_config, |
| 3164 | single_mac_scan_with_dfs); |
| 3165 | |
| 3166 | WMA_LOGD("%s: *scan_config:%x ", __func__, *scan_config); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3167 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3168 | } |
| 3169 | |
| 3170 | /** |
| 3171 | * wma_get_updated_fw_mode_config() - Get the updated fw mode configuration |
| 3172 | * @fw_mode_config: Pointer containing the updated fw mode config |
| 3173 | * @dbs: 0 or 1 indicating if DBS needs to be enabled/disabled |
| 3174 | * @agile_dfs: 0 or 1 indicating if agile DFS needs to be enabled/disabled |
| 3175 | * |
| 3176 | * Takes the current fw mode configuration and set the necessary fw mode config |
| 3177 | * bits to either 0/1 and provides the updated value to the caller who |
| 3178 | * can use this to pass it on to the FW |
| 3179 | * |
| 3180 | * Return: 0 on success |
| 3181 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3182 | QDF_STATUS wma_get_updated_fw_mode_config(uint32_t *fw_mode_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3183 | bool dbs, |
| 3184 | bool agile_dfs) |
| 3185 | { |
| 3186 | tp_wma_handle wma; |
| 3187 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3188 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3189 | if (!wma) { |
| 3190 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3191 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | } |
| 3193 | *fw_mode_config = wma->dual_mac_cfg.cur_fw_mode_config; |
| 3194 | |
| 3195 | WMI_DBS_FW_MODE_CFG_DBS_SET(*fw_mode_config, dbs); |
| 3196 | WMI_DBS_FW_MODE_CFG_AGILE_DFS_SET(*fw_mode_config, agile_dfs); |
| 3197 | |
| 3198 | WMA_LOGD("%s: *fw_mode_config:%x ", __func__, *fw_mode_config); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3199 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | } |
| 3201 | |
| 3202 | /** |
| 3203 | * wma_get_dbs_config() - Get DBS bit |
| 3204 | * |
| 3205 | * Gets the DBS bit of fw_mode_config_bits |
| 3206 | * |
| 3207 | * Return: 0 or 1 to indicate the DBS bit |
| 3208 | */ |
| 3209 | bool wma_get_dbs_config(void) |
| 3210 | { |
| 3211 | tp_wma_handle wma; |
| 3212 | uint32_t fw_mode_config; |
| 3213 | |
| 3214 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3215 | return false; |
| 3216 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3217 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | if (!wma) { |
| 3219 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3220 | /* We take that it is disabled and proceed */ |
| 3221 | return false; |
| 3222 | } |
| 3223 | fw_mode_config = wma->dual_mac_cfg.cur_fw_mode_config; |
| 3224 | |
| 3225 | return WMI_DBS_FW_MODE_CFG_DBS_GET(fw_mode_config); |
| 3226 | } |
| 3227 | |
| 3228 | /** |
| 3229 | * wma_get_agile_dfs_config() - Get Agile DFS bit |
| 3230 | * |
| 3231 | * Gets the Agile DFS bit of fw_mode_config_bits |
| 3232 | * |
| 3233 | * Return: 0 or 1 to indicate the Agile DFS bit |
| 3234 | */ |
| 3235 | bool wma_get_agile_dfs_config(void) |
| 3236 | { |
| 3237 | tp_wma_handle wma; |
| 3238 | uint32_t fw_mode_config; |
| 3239 | |
| 3240 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3241 | return false; |
| 3242 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3243 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3244 | if (!wma) { |
| 3245 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3246 | /* We take that it is disabled and proceed */ |
| 3247 | return false; |
| 3248 | } |
| 3249 | fw_mode_config = wma->dual_mac_cfg.cur_fw_mode_config; |
| 3250 | |
| 3251 | return WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET(fw_mode_config); |
| 3252 | } |
| 3253 | |
| 3254 | /** |
| 3255 | * wma_get_dbs_scan_config() - Get DBS scan bit |
| 3256 | * |
| 3257 | * Gets the DBS scan bit of concurrent_scan_config_bits |
| 3258 | * |
| 3259 | * Return: 0 or 1 to indicate the DBS scan bit |
| 3260 | */ |
| 3261 | bool wma_get_dbs_scan_config(void) |
| 3262 | { |
| 3263 | tp_wma_handle wma; |
| 3264 | uint32_t scan_config; |
| 3265 | |
| 3266 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3267 | return false; |
| 3268 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3269 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | if (!wma) { |
| 3271 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3272 | /* We take that it is disabled and proceed */ |
| 3273 | return false; |
| 3274 | } |
| 3275 | scan_config = wma->dual_mac_cfg.cur_scan_config; |
| 3276 | |
| 3277 | return WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_GET(scan_config); |
| 3278 | } |
| 3279 | |
| 3280 | /** |
| 3281 | * wma_get_dbs_plus_agile_scan_config() - Get DBS plus agile scan bit |
| 3282 | * |
| 3283 | * Gets the DBS plus agile scan bit of concurrent_scan_config_bits |
| 3284 | * |
| 3285 | * Return: 0 or 1 to indicate the DBS plus agile scan bit |
| 3286 | */ |
| 3287 | bool wma_get_dbs_plus_agile_scan_config(void) |
| 3288 | { |
| 3289 | tp_wma_handle wma; |
| 3290 | uint32_t scan_config; |
| 3291 | |
| 3292 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3293 | return false; |
| 3294 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3295 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3296 | if (!wma) { |
| 3297 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3298 | /* We take that it is disabled and proceed */ |
| 3299 | return false; |
| 3300 | } |
| 3301 | scan_config = wma->dual_mac_cfg.cur_scan_config; |
| 3302 | |
| 3303 | return WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config); |
| 3304 | } |
| 3305 | |
| 3306 | /** |
| 3307 | * wma_get_single_mac_scan_with_dfs_config() - Get Single MAC scan with DFS bit |
| 3308 | * |
| 3309 | * Gets the Single MAC scan with DFS bit of concurrent_scan_config_bits |
| 3310 | * |
| 3311 | * Return: 0 or 1 to indicate the Single MAC scan with DFS bit |
| 3312 | */ |
| 3313 | bool wma_get_single_mac_scan_with_dfs_config(void) |
| 3314 | { |
| 3315 | tp_wma_handle wma; |
| 3316 | uint32_t scan_config; |
| 3317 | |
| 3318 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3319 | return false; |
| 3320 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3321 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | if (!wma) { |
| 3323 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3324 | /* We take that it is disabled and proceed */ |
| 3325 | return false; |
| 3326 | } |
| 3327 | scan_config = wma->dual_mac_cfg.cur_scan_config; |
| 3328 | |
| 3329 | return WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config); |
| 3330 | } |
| 3331 | |
| 3332 | /** |
| 3333 | * wma_is_dual_mac_disabled_in_ini() - Check if dual mac is disabled in INI |
| 3334 | * |
| 3335 | * Checks if the dual mac feature is disabled in INI |
| 3336 | * |
| 3337 | * Return: true if the dual mac feature is disabled from INI |
| 3338 | */ |
| 3339 | bool wma_is_dual_mac_disabled_in_ini(void) |
| 3340 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3341 | tpAniSirGlobal mac = cds_get_context(QDF_MODULE_ID_PE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3342 | |
| 3343 | if (!mac) { |
| 3344 | WMA_LOGE("%s: Invalid mac pointer", __func__); |
| 3345 | return true; |
| 3346 | } |
| 3347 | |
| 3348 | if (mac->dual_mac_feature_disable) |
| 3349 | return true; |
| 3350 | |
| 3351 | return false; |
| 3352 | } |
| 3353 | |
| 3354 | /** |
| 3355 | * wma_get_prev_dbs_config() - Get prev DBS bit |
| 3356 | * |
| 3357 | * Gets the previous DBS bit of fw_mode_config_bits |
| 3358 | * |
| 3359 | * Return: 0 or 1 to indicate the DBS bit |
| 3360 | */ |
| 3361 | bool wma_get_prev_dbs_config(void) |
| 3362 | { |
| 3363 | tp_wma_handle wma; |
| 3364 | uint32_t fw_mode_config; |
| 3365 | |
| 3366 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3367 | return false; |
| 3368 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3369 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3370 | if (!wma) { |
| 3371 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3372 | /* We take that it is disabled and proceed */ |
| 3373 | return false; |
| 3374 | } |
| 3375 | fw_mode_config = wma->dual_mac_cfg.prev_fw_mode_config; |
| 3376 | |
| 3377 | return WMI_DBS_FW_MODE_CFG_DBS_GET(fw_mode_config); |
| 3378 | } |
| 3379 | |
| 3380 | /** |
| 3381 | * wma_get_prev_agile_dfs_config() - Get prev Agile DFS bit |
| 3382 | * |
| 3383 | * Gets the previous Agile DFS bit of fw_mode_config_bits |
| 3384 | * |
| 3385 | * Return: 0 or 1 to indicate the Agile DFS bit |
| 3386 | */ |
| 3387 | bool wma_get_prev_agile_dfs_config(void) |
| 3388 | { |
| 3389 | tp_wma_handle wma; |
| 3390 | uint32_t fw_mode_config; |
| 3391 | |
| 3392 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3393 | return false; |
| 3394 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3395 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | if (!wma) { |
| 3397 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3398 | /* We take that it is disabled and proceed */ |
| 3399 | return false; |
| 3400 | } |
| 3401 | fw_mode_config = wma->dual_mac_cfg.prev_fw_mode_config; |
| 3402 | |
| 3403 | return WMI_DBS_FW_MODE_CFG_AGILE_DFS_GET(fw_mode_config); |
| 3404 | } |
| 3405 | |
| 3406 | /** |
| 3407 | * wma_get_prev_dbs_scan_config() - Get prev DBS scan bit |
| 3408 | * |
| 3409 | * Gets the previous DBS scan bit of concurrent_scan_config_bits |
| 3410 | * |
| 3411 | * Return: 0 or 1 to indicate the DBS scan bit |
| 3412 | */ |
| 3413 | bool wma_get_prev_dbs_scan_config(void) |
| 3414 | { |
| 3415 | tp_wma_handle wma; |
| 3416 | uint32_t scan_config; |
| 3417 | |
| 3418 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3419 | return false; |
| 3420 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3421 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3422 | if (!wma) { |
| 3423 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3424 | /* We take that it is disabled and proceed */ |
| 3425 | return false; |
| 3426 | } |
| 3427 | scan_config = wma->dual_mac_cfg.prev_scan_config; |
| 3428 | |
| 3429 | return WMI_DBS_CONC_SCAN_CFG_DBS_SCAN_GET(scan_config); |
| 3430 | } |
| 3431 | |
| 3432 | /** |
| 3433 | * wma_get_prev_dbs_plus_agile_scan_config() - Get prev DBS plus agile scan bit |
| 3434 | * |
| 3435 | * Gets the previous DBS plus agile scan bit of concurrent_scan_config_bits |
| 3436 | * |
| 3437 | * Return: 0 or 1 to indicate the DBS plus agile scan bit |
| 3438 | */ |
| 3439 | bool wma_get_prev_dbs_plus_agile_scan_config(void) |
| 3440 | { |
| 3441 | tp_wma_handle wma; |
| 3442 | uint32_t scan_config; |
| 3443 | |
| 3444 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3445 | return false; |
| 3446 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3447 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3448 | if (!wma) { |
| 3449 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3450 | /* We take that it is disabled and proceed */ |
| 3451 | return false; |
| 3452 | } |
| 3453 | scan_config = wma->dual_mac_cfg.prev_scan_config; |
| 3454 | |
| 3455 | return WMI_DBS_CONC_SCAN_CFG_AGILE_SCAN_GET(scan_config); |
| 3456 | } |
| 3457 | |
| 3458 | /** |
| 3459 | * wma_get_prev_single_mac_scan_with_dfs_config() - Get prev Single MAC scan |
| 3460 | * with DFS bit |
| 3461 | * |
| 3462 | * Gets the previous Single MAC scan with DFS bit of concurrent_scan_config_bits |
| 3463 | * |
| 3464 | * Return: 0 or 1 to indicate the Single MAC scan with DFS bit |
| 3465 | */ |
| 3466 | bool wma_get_prev_single_mac_scan_with_dfs_config(void) |
| 3467 | { |
| 3468 | tp_wma_handle wma; |
| 3469 | uint32_t scan_config; |
| 3470 | |
| 3471 | if (wma_is_dual_mac_disabled_in_ini()) |
| 3472 | return false; |
| 3473 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3474 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3475 | if (!wma) { |
| 3476 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3477 | /* We take that it is disabled and proceed */ |
| 3478 | return false; |
| 3479 | } |
| 3480 | scan_config = wma->dual_mac_cfg.prev_scan_config; |
| 3481 | |
| 3482 | return WMI_DBS_CONC_SCAN_CFG_AGILE_DFS_SCAN_GET(scan_config); |
| 3483 | } |
| 3484 | |
| 3485 | /** |
| 3486 | * wma_is_scan_simultaneous_capable() - Check if scan parallelization is |
| 3487 | * supported or not |
| 3488 | * |
| 3489 | * currently scan parallelization feature support is dependent on DBS but |
| 3490 | * it can be independent in future. |
| 3491 | * |
| 3492 | * Return: True if master DBS control is enabled |
| 3493 | */ |
| 3494 | bool wma_is_scan_simultaneous_capable(void) |
| 3495 | { |
| 3496 | if (wma_is_hw_dbs_capable()) |
| 3497 | return true; |
| 3498 | |
| 3499 | return false; |
| 3500 | } |
Naveen Rawat | c0c91cd | 2015-11-05 14:27:37 -0800 | [diff] [blame] | 3501 | |
| 3502 | /** |
| 3503 | * wma_get_vht_ch_width - return vht channel width |
| 3504 | * |
| 3505 | * Return: return vht channel width |
| 3506 | */ |
| 3507 | uint32_t wma_get_vht_ch_width(void) |
| 3508 | { |
| 3509 | uint32_t fw_ch_wd = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3510 | tp_wma_handle wm_hdl = cds_get_context(QDF_MODULE_ID_WMA); |
Naveen Rawat | c0c91cd | 2015-11-05 14:27:37 -0800 | [diff] [blame] | 3511 | |
| 3512 | if (NULL == wm_hdl) |
| 3513 | return fw_ch_wd; |
| 3514 | |
Kiran Kumar Lokere | 02b9aa4 | 2016-05-26 14:54:49 -0700 | [diff] [blame] | 3515 | if (wm_hdl->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_80P80_160MHZ) |
Naveen Rawat | c0c91cd | 2015-11-05 14:27:37 -0800 | [diff] [blame] | 3516 | fw_ch_wd = WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ; |
Kiran Kumar Lokere | 02b9aa4 | 2016-05-26 14:54:49 -0700 | [diff] [blame] | 3517 | else if (wm_hdl->vht_cap_info & WMI_VHT_CAP_CH_WIDTH_160MHZ) |
| 3518 | fw_ch_wd = WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ; |
Naveen Rawat | c0c91cd | 2015-11-05 14:27:37 -0800 | [diff] [blame] | 3519 | |
| 3520 | return fw_ch_wd; |
| 3521 | } |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 3522 | |
| 3523 | /** |
Krunal Soni | aa664da | 2016-06-15 23:46:40 -0700 | [diff] [blame] | 3524 | * wma_get_num_of_setbits_from_bitmask() - to get num of setbits from bitmask |
| 3525 | * @mask: given bitmask |
| 3526 | * |
| 3527 | * This helper function should return number of setbits from bitmask |
| 3528 | * |
| 3529 | * Return: number of setbits from bitmask |
| 3530 | */ |
| 3531 | uint32_t wma_get_num_of_setbits_from_bitmask(uint32_t mask) |
| 3532 | { |
| 3533 | uint32_t num_of_setbits = 0; |
| 3534 | |
| 3535 | while (mask) { |
| 3536 | mask &= (mask - 1); |
| 3537 | num_of_setbits++; |
| 3538 | } |
| 3539 | return num_of_setbits; |
| 3540 | } |
| 3541 | |
| 3542 | /** |
Govind Singh | d76a5b0 | 2016-03-08 15:12:14 +0530 | [diff] [blame] | 3543 | * wma_config_debug_module_cmd - set debug log config |
| 3544 | * @wmi_handle: wmi layer handle |
| 3545 | * @param: debug log parameter |
| 3546 | * @val: debug log value |
| 3547 | * @module_id_bitmap: debug module id bitmap |
| 3548 | * @bitmap_len: debug module bitmap length |
| 3549 | * |
| 3550 | * Return: QDF_STATUS_SUCCESS for success or error code |
| 3551 | */ |
| 3552 | QDF_STATUS |
| 3553 | wma_config_debug_module_cmd(wmi_unified_t wmi_handle, A_UINT32 param, |
| 3554 | A_UINT32 val, A_UINT32 *module_id_bitmap, |
| 3555 | A_UINT32 bitmap_len) |
| 3556 | { |
| 3557 | struct dbglog_params dbg_param; |
| 3558 | dbg_param.param = param; |
| 3559 | dbg_param.val = val; |
| 3560 | dbg_param.module_id_bitmap = module_id_bitmap; |
| 3561 | dbg_param.bitmap_len = bitmap_len; |
| 3562 | |
| 3563 | return wmi_unified_dbglog_cmd_send(wmi_handle, &dbg_param); |
| 3564 | } |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 3565 | |
| 3566 | /** |
| 3567 | * wma_is_p2p_lo_capable() - if driver is capable of p2p listen offload |
| 3568 | * |
| 3569 | * This function checks if driver is capable of p2p listen offload |
| 3570 | * true: capable of p2p offload |
| 3571 | * false: not capable |
| 3572 | * |
| 3573 | * Return: true - capable, false - not capable |
| 3574 | */ |
| 3575 | bool wma_is_p2p_lo_capable(void) |
| 3576 | { |
| 3577 | tp_wma_handle wma; |
| 3578 | |
| 3579 | wma = cds_get_context(QDF_MODULE_ID_WMA); |
| 3580 | if (!wma) { |
| 3581 | WMA_LOGE("%s: Invalid WMA handle", __func__); |
| 3582 | return false; |
| 3583 | } |
| 3584 | |
| 3585 | if (WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 3586 | WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT)) |
| 3587 | return true; |
| 3588 | |
| 3589 | return false; |
| 3590 | } |