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