Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Ryan Hsu | f75bd24 | 2015-12-17 12:22:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wma_features.c |
| 30 | * This file contains different features related functions like WoW, |
| 31 | * Offloads, TDLS etc. |
| 32 | */ |
| 33 | |
| 34 | /* Header files */ |
| 35 | |
| 36 | #include "wma.h" |
| 37 | #include "wma_api.h" |
| 38 | #include "cds_api.h" |
| 39 | #include "wmi_unified_api.h" |
| 40 | #include "wlan_qct_sys.h" |
| 41 | #include "wni_api.h" |
| 42 | #include "ani_global.h" |
| 43 | #include "wmi_unified.h" |
| 44 | #include "wni_cfg.h" |
| 45 | #include "cfg_api.h" |
| 46 | #include "ol_txrx_ctrl_api.h" |
| 47 | #include "wlan_tgt_def_config.h" |
| 48 | |
| 49 | #include "cdf_nbuf.h" |
| 50 | #include "cdf_types.h" |
| 51 | #include "ol_txrx_api.h" |
| 52 | #include "cdf_memory.h" |
| 53 | #include "ol_txrx_types.h" |
| 54 | #include "ol_txrx_peer_find.h" |
| 55 | |
| 56 | #include "wma_types.h" |
| 57 | #include "lim_api.h" |
| 58 | #include "lim_session_utils.h" |
| 59 | |
| 60 | #include "cds_utils.h" |
| 61 | |
| 62 | #if !defined(REMOVE_PKT_LOG) |
| 63 | #include "pktlog_ac.h" |
| 64 | #endif /* REMOVE_PKT_LOG */ |
| 65 | |
| 66 | #include "dbglog_host.h" |
| 67 | #include "csr_api.h" |
| 68 | #include "ol_fw.h" |
| 69 | |
| 70 | #include "dfs.h" |
| 71 | #include "radar_filters.h" |
| 72 | #include "wma_internal.h" |
| 73 | |
| 74 | #ifndef ARRAY_LENGTH |
| 75 | #define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0])) |
| 76 | #endif |
| 77 | |
| 78 | #define WMA_WOW_STA_WAKE_UP_EVENTS ((1 << WOW_CSA_IE_EVENT) |\ |
| 79 | (1 << WOW_CLIENT_KICKOUT_EVENT) |\ |
| 80 | (1 << WOW_PATTERN_MATCH_EVENT) |\ |
| 81 | (1 << WOW_MAGIC_PKT_RECVD_EVENT) |\ |
| 82 | (1 << WOW_DEAUTH_RECVD_EVENT) |\ |
| 83 | (1 << WOW_DISASSOC_RECVD_EVENT) |\ |
| 84 | (1 << WOW_BMISS_EVENT) |\ |
| 85 | (1 << WOW_GTK_ERR_EVENT) |\ |
| 86 | (1 << WOW_BETTER_AP_EVENT) |\ |
| 87 | (1 << WOW_HTT_EVENT) |\ |
| 88 | (1 << WOW_RA_MATCH_EVENT) |\ |
| 89 | (1 << WOW_NLO_DETECTED_EVENT) |\ |
| 90 | (1 << WOW_EXTSCAN_EVENT))\ |
| 91 | |
| 92 | #define WMA_WOW_SAP_WAKE_UP_EVENTS ((1 << WOW_PROBE_REQ_WPS_IE_EVENT) |\ |
| 93 | (1 << WOW_PATTERN_MATCH_EVENT) |\ |
| 94 | (1 << WOW_AUTH_REQ_EVENT) |\ |
| 95 | (1 << WOW_ASSOC_REQ_EVENT) |\ |
| 96 | (1 << WOW_DEAUTH_RECVD_EVENT) |\ |
| 97 | (1 << WOW_DISASSOC_RECVD_EVENT) |\ |
| 98 | (1 << WOW_HTT_EVENT))\ |
| 99 | |
| 100 | static const uint8_t arp_ptrn[] = {0x08, 0x06}; |
| 101 | static const uint8_t arp_mask[] = {0xff, 0xff}; |
| 102 | static const uint8_t ns_ptrn[] = {0x86, 0xDD}; |
| 103 | static const uint8_t discvr_ptrn[] = {0xe0, 0x00, 0x00, 0xf8}; |
| 104 | static const uint8_t discvr_mask[] = {0xf0, 0x00, 0x00, 0xf8}; |
| 105 | |
| 106 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 107 | /** |
| 108 | * wma_post_auto_shutdown_msg() - to post auto shutdown event to sme |
| 109 | * |
| 110 | * Return: 0 for success or error code |
| 111 | */ |
| 112 | static int wma_post_auto_shutdown_msg(void) |
| 113 | { |
| 114 | tSirAutoShutdownEvtParams *auto_sh_evt; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 115 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 116 | cds_msg_t sme_msg = { 0 }; |
| 117 | |
| 118 | auto_sh_evt = (tSirAutoShutdownEvtParams *) |
| 119 | cdf_mem_malloc(sizeof(tSirAutoShutdownEvtParams)); |
| 120 | if (!auto_sh_evt) { |
| 121 | WMA_LOGE(FL("No Mem")); |
| 122 | return -ENOMEM; |
| 123 | } |
| 124 | |
| 125 | auto_sh_evt->shutdown_reason = |
| 126 | WMI_HOST_AUTO_SHUTDOWN_REASON_TIMER_EXPIRY; |
| 127 | sme_msg.type = eWNI_SME_AUTO_SHUTDOWN_IND; |
| 128 | sme_msg.bodyptr = auto_sh_evt; |
| 129 | sme_msg.bodyval = 0; |
| 130 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 131 | qdf_status = cds_mq_post_message(CDF_MODULE_ID_SME, &sme_msg); |
| 132 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 133 | WMA_LOGE("Fail to post eWNI_SME_AUTO_SHUTDOWN_IND msg to SME"); |
| 134 | cdf_mem_free(auto_sh_evt); |
| 135 | return -EINVAL; |
| 136 | } |
| 137 | |
| 138 | return 0; |
| 139 | } |
| 140 | #endif |
| 141 | /** |
| 142 | * wma_send_snr_request() - send request to fw to get RSSI stats |
| 143 | * @wma_handle: wma handle |
| 144 | * @pGetRssiReq: get RSSI request |
| 145 | * |
| 146 | * Return: CDF status |
| 147 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 148 | QDF_STATUS wma_send_snr_request(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 149 | void *pGetRssiReq) |
| 150 | { |
| 151 | wmi_buf_t buf; |
| 152 | wmi_request_stats_cmd_fixed_param *cmd; |
| 153 | uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param); |
| 154 | tAniGetRssiReq *pRssiBkUp = NULL; |
| 155 | |
| 156 | /* command is in progess */ |
| 157 | if (NULL != wma_handle->pGetRssiReq) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 158 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | |
| 160 | /* create a copy of csrRssiCallback to send rssi value |
| 161 | * after wmi event |
| 162 | */ |
| 163 | if (pGetRssiReq) { |
| 164 | pRssiBkUp = cdf_mem_malloc(sizeof(tAniGetRssiReq)); |
| 165 | if (!pRssiBkUp) { |
| 166 | WMA_LOGE("Failed to allocate memory for tAniGetRssiReq"); |
| 167 | wma_handle->pGetRssiReq = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 168 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | } |
| 170 | cdf_mem_set(pRssiBkUp, sizeof(tAniGetRssiReq), 0); |
| 171 | pRssiBkUp->sessionId = |
| 172 | ((tAniGetRssiReq *) pGetRssiReq)->sessionId; |
| 173 | pRssiBkUp->rssiCallback = |
| 174 | ((tAniGetRssiReq *) pGetRssiReq)->rssiCallback; |
| 175 | pRssiBkUp->pDevContext = |
| 176 | ((tAniGetRssiReq *) pGetRssiReq)->pDevContext; |
| 177 | wma_handle->pGetRssiReq = (void *)pRssiBkUp; |
| 178 | } |
| 179 | |
| 180 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 181 | if (!buf) { |
| 182 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
| 183 | cdf_mem_free(pRssiBkUp); |
| 184 | wma_handle->pGetRssiReq = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 185 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf); |
| 189 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 190 | WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param, |
| 191 | WMITLV_GET_STRUCT_TLVLEN |
| 192 | (wmi_request_stats_cmd_fixed_param)); |
| 193 | cmd->stats_id = WMI_REQUEST_VDEV_STAT; |
| 194 | if (wmi_unified_cmd_send |
| 195 | (wma_handle->wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) { |
| 196 | WMA_LOGE("Failed to send host stats request to fw"); |
| 197 | wmi_buf_free(buf); |
| 198 | cdf_mem_free(pRssiBkUp); |
| 199 | wma_handle->pGetRssiReq = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 200 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 201 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 202 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /** |
| 206 | * wma_get_snr() - get RSSI from fw |
| 207 | * @psnr_req: request params |
| 208 | * |
| 209 | * Return: CDF status |
| 210 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 211 | QDF_STATUS wma_get_snr(tAniGetSnrReq *psnr_req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | { |
| 213 | wmi_buf_t buf; |
| 214 | wmi_request_stats_cmd_fixed_param *cmd; |
| 215 | tAniGetSnrReq *psnr_req_bkp; |
| 216 | uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param); |
| 217 | tp_wma_handle wma_handle = NULL; |
| 218 | struct wma_txrx_node *intr; |
| 219 | |
| 220 | wma_handle = cds_get_context(CDF_MODULE_ID_WMA); |
| 221 | |
| 222 | if (NULL == wma_handle) { |
| 223 | WMA_LOGE("%s : Failed to get wma_handle", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 224 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | intr = &wma_handle->interfaces[psnr_req->sessionId]; |
| 228 | /* command is in progess */ |
| 229 | if (NULL != intr->psnr_req) { |
| 230 | WMA_LOGE("%s : previous snr request is pending", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 231 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | psnr_req_bkp = cdf_mem_malloc(sizeof(tAniGetSnrReq)); |
| 235 | if (!psnr_req_bkp) { |
| 236 | WMA_LOGE("Failed to allocate memory for tAniGetSnrReq"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 237 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | cdf_mem_set(psnr_req_bkp, sizeof(tAniGetSnrReq), 0); |
| 241 | psnr_req_bkp->staId = psnr_req->staId; |
| 242 | psnr_req_bkp->pDevContext = psnr_req->pDevContext; |
| 243 | psnr_req_bkp->snrCallback = psnr_req->snrCallback; |
| 244 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 245 | if (!buf) { |
| 246 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
| 247 | cdf_mem_free(psnr_req_bkp); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 248 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf); |
| 252 | cmd->vdev_id = psnr_req->sessionId; |
| 253 | |
| 254 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 255 | WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param, |
| 256 | WMITLV_GET_STRUCT_TLVLEN |
| 257 | (wmi_request_stats_cmd_fixed_param)); |
| 258 | cmd->stats_id = WMI_REQUEST_VDEV_STAT; |
| 259 | intr->psnr_req = (void *)psnr_req_bkp; |
| 260 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 261 | WMI_REQUEST_STATS_CMDID)) { |
| 262 | WMA_LOGE("Failed to send host stats request to fw"); |
| 263 | wmi_buf_free(buf); |
| 264 | cdf_mem_free(psnr_req_bkp); |
| 265 | intr->psnr_req = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 266 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 267 | } |
| 268 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 269 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | /** |
| 273 | * wma_process_link_status_req() - process link status request from UMAC |
| 274 | * @wma: wma handle |
| 275 | * @pGetLinkStatus: get link params |
| 276 | * |
| 277 | * Return: none |
| 278 | */ |
| 279 | void wma_process_link_status_req(tp_wma_handle wma, |
| 280 | tAniGetLinkStatus *pGetLinkStatus) |
| 281 | { |
| 282 | wmi_buf_t buf; |
| 283 | wmi_request_stats_cmd_fixed_param *cmd; |
| 284 | uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param); |
| 285 | struct wma_txrx_node *iface = |
| 286 | &wma->interfaces[pGetLinkStatus->sessionId]; |
| 287 | |
| 288 | if (iface->plink_status_req) { |
| 289 | WMA_LOGE("%s:previous link status request is pending,deleting the new request", |
| 290 | __func__); |
| 291 | cdf_mem_free(pGetLinkStatus); |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 296 | if (!buf) { |
| 297 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
| 298 | goto end; |
| 299 | } |
| 300 | |
| 301 | iface->plink_status_req = pGetLinkStatus; |
| 302 | cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf); |
| 303 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 304 | WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param, |
| 305 | WMITLV_GET_STRUCT_TLVLEN |
| 306 | (wmi_request_stats_cmd_fixed_param)); |
| 307 | cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT; |
| 308 | cmd->vdev_id = pGetLinkStatus->sessionId; |
| 309 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 310 | WMI_REQUEST_STATS_CMDID)) { |
| 311 | WMA_LOGE("Failed to send WMI link status request to fw"); |
| 312 | wmi_buf_free(buf); |
| 313 | iface->plink_status_req = NULL; |
| 314 | goto end; |
| 315 | } |
| 316 | |
| 317 | return; |
| 318 | |
| 319 | end: |
| 320 | wma_post_link_status(pGetLinkStatus, LINK_STATUS_LEGACY); |
| 321 | } |
| 322 | |
| 323 | #ifdef FEATURE_WLAN_LPHB |
| 324 | /** |
| 325 | * wma_lphb_conf_hbenable() - enable command of LPHB configuration requests |
| 326 | * @wma_handle: WMA handle |
| 327 | * @lphb_conf_req: configuration info |
| 328 | * @by_user: whether this call is from user or cached resent |
| 329 | * |
| 330 | * Return: CDF status |
| 331 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 332 | QDF_STATUS wma_lphb_conf_hbenable(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 333 | tSirLPHBReq *lphb_conf_req, bool by_user) |
| 334 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 335 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | int status = 0; |
| 337 | tSirLPHBEnableStruct *ts_lphb_enable; |
| 338 | wmi_buf_t buf = NULL; |
| 339 | uint8_t *buf_ptr; |
| 340 | wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp; |
| 341 | int len = sizeof(wmi_hb_set_enable_cmd_fixed_param); |
| 342 | int i; |
| 343 | |
| 344 | if (lphb_conf_req == NULL) { |
| 345 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 346 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | ts_lphb_enable = &(lphb_conf_req->params.lphbEnableReq); |
| 350 | WMA_LOGI("%s: WMA --> WMI_HB_SET_ENABLE enable=%d, item=%d, session=%d", |
| 351 | __func__, |
| 352 | ts_lphb_enable->enable, |
| 353 | ts_lphb_enable->item, ts_lphb_enable->session); |
| 354 | |
| 355 | if ((ts_lphb_enable->item != 1) && (ts_lphb_enable->item != 2)) { |
| 356 | WMA_LOGE("%s : LPHB configuration wrong item %d", |
| 357 | __func__, ts_lphb_enable->item); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 358 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 362 | if (!buf) { |
| 363 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 364 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 368 | hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr; |
| 369 | WMITLV_SET_HDR(&hb_enable_fp->tlv_header, |
| 370 | WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param, |
| 371 | WMITLV_GET_STRUCT_TLVLEN |
| 372 | (wmi_hb_set_enable_cmd_fixed_param)); |
| 373 | |
| 374 | /* fill in values */ |
| 375 | hb_enable_fp->vdev_id = ts_lphb_enable->session; |
| 376 | hb_enable_fp->enable = ts_lphb_enable->enable; |
| 377 | hb_enable_fp->item = ts_lphb_enable->item; |
| 378 | hb_enable_fp->session = ts_lphb_enable->session; |
| 379 | |
| 380 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 381 | len, WMI_HB_SET_ENABLE_CMDID); |
| 382 | if (status != EOK) { |
| 383 | WMA_LOGE("wmi_unified_cmd_send WMI_HB_SET_ENABLE returned Error %d", |
| 384 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 385 | qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 386 | goto error; |
| 387 | } |
| 388 | |
| 389 | if (by_user) { |
| 390 | /* target already configured, now cache command status */ |
| 391 | if (ts_lphb_enable->enable) { |
| 392 | i = ts_lphb_enable->item - 1; |
| 393 | wma_handle->wow.lphb_cache[i].cmd |
| 394 | = LPHB_SET_EN_PARAMS_INDID; |
| 395 | wma_handle->wow.lphb_cache[i].params.lphbEnableReq. |
| 396 | enable = ts_lphb_enable->enable; |
| 397 | wma_handle->wow.lphb_cache[i].params.lphbEnableReq. |
| 398 | item = ts_lphb_enable->item; |
| 399 | wma_handle->wow.lphb_cache[i].params.lphbEnableReq. |
| 400 | session = ts_lphb_enable->session; |
| 401 | |
| 402 | WMA_LOGI("%s: cached LPHB status in WMA context for item %d", |
| 403 | __func__, i); |
| 404 | } else { |
| 405 | cdf_mem_zero((void *)&wma_handle->wow.lphb_cache, |
| 406 | sizeof(wma_handle->wow.lphb_cache)); |
| 407 | WMA_LOGI("%s: cleared all cached LPHB status in WMA context", |
| 408 | __func__); |
| 409 | } |
| 410 | } |
| 411 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 412 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 413 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 414 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 415 | } |
| 416 | |
| 417 | /** |
| 418 | * wma_lphb_conf_tcp_params() - set tcp params of LPHB configuration requests |
| 419 | * @wma_handle: wma handle |
| 420 | * @lphb_conf_req: lphb config request |
| 421 | * |
| 422 | * Return: CDF status |
| 423 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 424 | QDF_STATUS wma_lphb_conf_tcp_params(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 425 | tSirLPHBReq *lphb_conf_req) |
| 426 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 427 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 428 | int status = 0; |
| 429 | tSirLPHBTcpParamStruct *ts_lphb_tcp_param; |
| 430 | wmi_buf_t buf = NULL; |
| 431 | uint8_t *buf_ptr; |
| 432 | wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp; |
| 433 | int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param); |
| 434 | |
| 435 | if (lphb_conf_req == NULL) { |
| 436 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 437 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | ts_lphb_tcp_param = &(lphb_conf_req->params.lphbTcpParamReq); |
Srinivas Girigowda | 9dc32cf | 2015-11-19 14:47:04 -0800 | [diff] [blame] | 441 | WMA_LOGI("%s: WMA --> WMI_HB_SET_TCP_PARAMS srv_ip=%08x, " |
| 442 | "dev_ip=%08x, src_port=%d, dst_port=%d, timeout=%d, " |
| 443 | "session=%d, gateway_mac="MAC_ADDRESS_STR", timePeriodSec=%d, " |
| 444 | "tcpSn=%d", __func__, ts_lphb_tcp_param->srv_ip, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 445 | ts_lphb_tcp_param->dev_ip, ts_lphb_tcp_param->src_port, |
| 446 | ts_lphb_tcp_param->dst_port, ts_lphb_tcp_param->timeout, |
Srinivas Girigowda | 9dc32cf | 2015-11-19 14:47:04 -0800 | [diff] [blame] | 447 | ts_lphb_tcp_param->session, |
| 448 | MAC_ADDR_ARRAY(ts_lphb_tcp_param->gateway_mac.bytes), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | ts_lphb_tcp_param->timePeriodSec, ts_lphb_tcp_param->tcpSn); |
| 450 | |
| 451 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 452 | if (!buf) { |
| 453 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 454 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 458 | hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr; |
| 459 | WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header, |
| 460 | WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param, |
| 461 | WMITLV_GET_STRUCT_TLVLEN |
| 462 | (wmi_hb_set_tcp_params_cmd_fixed_param)); |
| 463 | |
| 464 | /* fill in values */ |
| 465 | hb_tcp_params_fp->vdev_id = ts_lphb_tcp_param->session; |
| 466 | hb_tcp_params_fp->srv_ip = ts_lphb_tcp_param->srv_ip; |
| 467 | hb_tcp_params_fp->dev_ip = ts_lphb_tcp_param->dev_ip; |
| 468 | hb_tcp_params_fp->seq = ts_lphb_tcp_param->tcpSn; |
| 469 | hb_tcp_params_fp->src_port = ts_lphb_tcp_param->src_port; |
| 470 | hb_tcp_params_fp->dst_port = ts_lphb_tcp_param->dst_port; |
| 471 | hb_tcp_params_fp->interval = ts_lphb_tcp_param->timePeriodSec; |
| 472 | hb_tcp_params_fp->timeout = ts_lphb_tcp_param->timeout; |
| 473 | hb_tcp_params_fp->session = ts_lphb_tcp_param->session; |
Srinivas Girigowda | 9dc32cf | 2015-11-19 14:47:04 -0800 | [diff] [blame] | 474 | WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_tcp_param->gateway_mac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | &hb_tcp_params_fp->gateway_mac); |
| 476 | |
| 477 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 478 | len, WMI_HB_SET_TCP_PARAMS_CMDID); |
| 479 | if (status != EOK) { |
| 480 | WMA_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d", |
| 481 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 482 | qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 483 | goto error; |
| 484 | } |
| 485 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 486 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 487 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 488 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | /** |
| 492 | * wma_lphb_conf_tcp_pkt_filter() - configure tcp packet filter command of LPHB |
| 493 | * @wma_handle: wma handle |
| 494 | * @lphb_conf_req: lphb config request |
| 495 | * |
| 496 | * Return: CDF status |
| 497 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 498 | QDF_STATUS wma_lphb_conf_tcp_pkt_filter(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 499 | tSirLPHBReq *lphb_conf_req) |
| 500 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 501 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 502 | int status = 0; |
| 503 | tSirLPHBTcpFilterStruct *ts_lphb_tcp_filter; |
| 504 | wmi_buf_t buf = NULL; |
| 505 | uint8_t *buf_ptr; |
| 506 | wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp; |
| 507 | int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param); |
| 508 | |
| 509 | if (lphb_conf_req == NULL) { |
| 510 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 511 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | ts_lphb_tcp_filter = &(lphb_conf_req->params.lphbTcpFilterReq); |
| 515 | WMA_LOGI("%s: WMA --> WMI_HB_SET_TCP_PKT_FILTER length=%d, offset=%d, session=%d, " |
| 516 | "filter=%2x:%2x:%2x:%2x:%2x:%2x ...", __func__, |
| 517 | ts_lphb_tcp_filter->length, ts_lphb_tcp_filter->offset, |
| 518 | ts_lphb_tcp_filter->session, ts_lphb_tcp_filter->filter[0], |
| 519 | ts_lphb_tcp_filter->filter[1], ts_lphb_tcp_filter->filter[2], |
| 520 | ts_lphb_tcp_filter->filter[3], ts_lphb_tcp_filter->filter[4], |
| 521 | ts_lphb_tcp_filter->filter[5]); |
| 522 | |
| 523 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 524 | if (!buf) { |
| 525 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 526 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 530 | hb_tcp_filter_fp = |
| 531 | (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr; |
| 532 | WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header, |
| 533 | WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param, |
| 534 | WMITLV_GET_STRUCT_TLVLEN |
| 535 | (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param)); |
| 536 | |
| 537 | /* fill in values */ |
| 538 | hb_tcp_filter_fp->vdev_id = ts_lphb_tcp_filter->session; |
| 539 | hb_tcp_filter_fp->length = ts_lphb_tcp_filter->length; |
| 540 | hb_tcp_filter_fp->offset = ts_lphb_tcp_filter->offset; |
| 541 | hb_tcp_filter_fp->session = ts_lphb_tcp_filter->session; |
| 542 | memcpy((void *)&hb_tcp_filter_fp->filter, |
| 543 | (void *)&ts_lphb_tcp_filter->filter, |
| 544 | WMI_WLAN_HB_MAX_FILTER_SIZE); |
| 545 | |
| 546 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 547 | len, WMI_HB_SET_TCP_PKT_FILTER_CMDID); |
| 548 | if (status != EOK) { |
| 549 | WMA_LOGE("wmi_unified_cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d", |
| 550 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 551 | qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 552 | goto error; |
| 553 | } |
| 554 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 555 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 557 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /** |
| 561 | * wma_lphb_conf_udp_params() - configure udp param command of LPHB |
| 562 | * @wma_handle: wma handle |
| 563 | * @lphb_conf_req: lphb config request |
| 564 | * |
| 565 | * Return: CDF status |
| 566 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 567 | QDF_STATUS wma_lphb_conf_udp_params(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | tSirLPHBReq *lphb_conf_req) |
| 569 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 570 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | int status = 0; |
| 572 | tSirLPHBUdpParamStruct *ts_lphb_udp_param; |
| 573 | wmi_buf_t buf = NULL; |
| 574 | uint8_t *buf_ptr; |
| 575 | wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp; |
| 576 | int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param); |
| 577 | |
| 578 | if (lphb_conf_req == NULL) { |
| 579 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 580 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | ts_lphb_udp_param = &(lphb_conf_req->params.lphbUdpParamReq); |
| 584 | WMA_LOGI("%s: WMA --> WMI_HB_SET_UDP_PARAMS srv_ip=%d, dev_ip=%d, src_port=%d, " |
| 585 | "dst_port=%d, interval=%d, timeout=%d, session=%d, " |
Srinivas Girigowda | 9eddfda | 2015-11-19 14:38:02 -0800 | [diff] [blame] | 586 | "gateway_mac="MAC_ADDRESS_STR, __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 587 | ts_lphb_udp_param->srv_ip, ts_lphb_udp_param->dev_ip, |
| 588 | ts_lphb_udp_param->src_port, ts_lphb_udp_param->dst_port, |
| 589 | ts_lphb_udp_param->interval, ts_lphb_udp_param->timeout, |
Srinivas Girigowda | 9eddfda | 2015-11-19 14:38:02 -0800 | [diff] [blame] | 590 | ts_lphb_udp_param->session, |
| 591 | MAC_ADDR_ARRAY(ts_lphb_udp_param->gateway_mac.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | |
| 593 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 594 | if (!buf) { |
| 595 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 596 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 600 | hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr; |
| 601 | WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header, |
| 602 | WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param, |
| 603 | WMITLV_GET_STRUCT_TLVLEN |
| 604 | (wmi_hb_set_udp_params_cmd_fixed_param)); |
| 605 | |
| 606 | /* fill in values */ |
| 607 | hb_udp_params_fp->vdev_id = ts_lphb_udp_param->session; |
| 608 | hb_udp_params_fp->srv_ip = ts_lphb_udp_param->srv_ip; |
| 609 | hb_udp_params_fp->dev_ip = ts_lphb_udp_param->dev_ip; |
| 610 | hb_udp_params_fp->src_port = ts_lphb_udp_param->src_port; |
| 611 | hb_udp_params_fp->dst_port = ts_lphb_udp_param->dst_port; |
| 612 | hb_udp_params_fp->interval = ts_lphb_udp_param->interval; |
| 613 | hb_udp_params_fp->timeout = ts_lphb_udp_param->timeout; |
| 614 | hb_udp_params_fp->session = ts_lphb_udp_param->session; |
Srinivas Girigowda | 9eddfda | 2015-11-19 14:38:02 -0800 | [diff] [blame] | 615 | WMI_CHAR_ARRAY_TO_MAC_ADDR(ts_lphb_udp_param->gateway_mac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | &hb_udp_params_fp->gateway_mac); |
| 617 | |
| 618 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 619 | len, WMI_HB_SET_UDP_PARAMS_CMDID); |
| 620 | if (status != EOK) { |
| 621 | WMA_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d", |
| 622 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 623 | qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 624 | goto error; |
| 625 | } |
| 626 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 627 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 628 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 629 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | /** |
| 633 | * wma_lphb_conf_udp_pkt_filter() - configure udp pkt filter command of LPHB |
| 634 | * @wma_handle: wma handle |
| 635 | * @lphb_conf_req: lphb config request |
| 636 | * |
| 637 | * Return: CDF status |
| 638 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 639 | QDF_STATUS wma_lphb_conf_udp_pkt_filter(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 640 | tSirLPHBReq *lphb_conf_req) |
| 641 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 642 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 643 | int status = 0; |
| 644 | tSirLPHBUdpFilterStruct *ts_lphb_udp_filter; |
| 645 | wmi_buf_t buf = NULL; |
| 646 | uint8_t *buf_ptr; |
| 647 | wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp; |
| 648 | int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param); |
| 649 | |
| 650 | if (lphb_conf_req == NULL) { |
| 651 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 652 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | ts_lphb_udp_filter = &(lphb_conf_req->params.lphbUdpFilterReq); |
| 656 | WMA_LOGI("%s: WMA --> WMI_HB_SET_UDP_PKT_FILTER length=%d, offset=%d, session=%d, " |
| 657 | "filter=%2x:%2x:%2x:%2x:%2x:%2x ...", __func__, |
| 658 | ts_lphb_udp_filter->length, ts_lphb_udp_filter->offset, |
| 659 | ts_lphb_udp_filter->session, ts_lphb_udp_filter->filter[0], |
| 660 | ts_lphb_udp_filter->filter[1], ts_lphb_udp_filter->filter[2], |
| 661 | ts_lphb_udp_filter->filter[3], ts_lphb_udp_filter->filter[4], |
| 662 | ts_lphb_udp_filter->filter[5]); |
| 663 | |
| 664 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 665 | if (!buf) { |
| 666 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 667 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 671 | hb_udp_filter_fp = |
| 672 | (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr; |
| 673 | WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header, |
| 674 | WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param, |
| 675 | WMITLV_GET_STRUCT_TLVLEN |
| 676 | (wmi_hb_set_udp_pkt_filter_cmd_fixed_param)); |
| 677 | |
| 678 | /* fill in values */ |
| 679 | hb_udp_filter_fp->vdev_id = ts_lphb_udp_filter->session; |
| 680 | hb_udp_filter_fp->length = ts_lphb_udp_filter->length; |
| 681 | hb_udp_filter_fp->offset = ts_lphb_udp_filter->offset; |
| 682 | hb_udp_filter_fp->session = ts_lphb_udp_filter->session; |
| 683 | memcpy((void *)&hb_udp_filter_fp->filter, |
| 684 | (void *)&ts_lphb_udp_filter->filter, |
| 685 | WMI_WLAN_HB_MAX_FILTER_SIZE); |
| 686 | |
| 687 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 688 | len, WMI_HB_SET_UDP_PKT_FILTER_CMDID); |
| 689 | if (status != EOK) { |
| 690 | WMA_LOGE("wmi_unified_cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d", |
| 691 | status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 692 | qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | goto error; |
| 694 | } |
| 695 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 696 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 697 | error: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 698 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | /** |
| 702 | * wma_process_lphb_conf_req() - handle LPHB configuration requests |
| 703 | * @wma_handle: wma handle |
| 704 | * @lphb_conf_req: lphb config request |
| 705 | * |
| 706 | * Return: CDF status |
| 707 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 708 | QDF_STATUS wma_process_lphb_conf_req(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 709 | tSirLPHBReq *lphb_conf_req) |
| 710 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 711 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 712 | |
| 713 | if (lphb_conf_req == NULL) { |
| 714 | WMA_LOGE("%s : LPHB configuration is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 715 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | WMA_LOGI("%s : LPHB configuration cmd id is %d", __func__, |
| 719 | lphb_conf_req->cmd); |
| 720 | switch (lphb_conf_req->cmd) { |
| 721 | case LPHB_SET_EN_PARAMS_INDID: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 722 | qdf_status = wma_lphb_conf_hbenable(wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 723 | lphb_conf_req, true); |
| 724 | break; |
| 725 | |
| 726 | case LPHB_SET_TCP_PARAMS_INDID: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 727 | qdf_status = wma_lphb_conf_tcp_params(wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 728 | lphb_conf_req); |
| 729 | break; |
| 730 | |
| 731 | case LPHB_SET_TCP_PKT_FILTER_INDID: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 732 | qdf_status = wma_lphb_conf_tcp_pkt_filter(wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | lphb_conf_req); |
| 734 | break; |
| 735 | |
| 736 | case LPHB_SET_UDP_PARAMS_INDID: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 737 | qdf_status = wma_lphb_conf_udp_params(wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | lphb_conf_req); |
| 739 | break; |
| 740 | |
| 741 | case LPHB_SET_UDP_PKT_FILTER_INDID: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 742 | qdf_status = wma_lphb_conf_udp_pkt_filter(wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 743 | lphb_conf_req); |
| 744 | break; |
| 745 | |
| 746 | case LPHB_SET_NETWORK_INFO_INDID: |
| 747 | default: |
| 748 | break; |
| 749 | } |
| 750 | |
| 751 | cdf_mem_free(lphb_conf_req); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 752 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | } |
| 754 | #endif /* FEATURE_WLAN_LPHB */ |
| 755 | |
| 756 | /** |
| 757 | * wma_process_dhcp_ind() - process dhcp indication from SME |
| 758 | * @wma_handle: wma handle |
| 759 | * @ta_dhcp_ind: DHCP indication |
| 760 | * |
| 761 | * Return: CDF Status |
| 762 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 763 | QDF_STATUS wma_process_dhcp_ind(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | tAniDHCPInd *ta_dhcp_ind) |
| 765 | { |
| 766 | uint8_t vdev_id; |
| 767 | int status = 0; |
| 768 | wmi_buf_t buf = NULL; |
| 769 | uint8_t *buf_ptr; |
| 770 | wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp; |
| 771 | int len = sizeof(wmi_peer_set_param_cmd_fixed_param); |
| 772 | |
| 773 | if (!ta_dhcp_ind) { |
| 774 | WMA_LOGE("%s : DHCP indication is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 775 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 776 | } |
| 777 | |
Srinivas Girigowda | 296105a | 2015-09-24 16:31:16 -0700 | [diff] [blame] | 778 | if (!wma_find_vdev_by_addr(wma_handle, |
| 779 | ta_dhcp_ind->adapterMacAddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 780 | &vdev_id)) { |
| 781 | WMA_LOGE("%s: Failed to find vdev id for DHCP indication", |
| 782 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 783 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | WMA_LOGI("%s: WMA --> WMI_PEER_SET_PARAM triggered by DHCP, " |
| 787 | "msgType=%s," |
| 788 | "device_mode=%d, macAddr=" MAC_ADDRESS_STR, |
| 789 | __func__, |
| 790 | ta_dhcp_ind->msgType == WMA_DHCP_START_IND ? |
| 791 | "WMA_DHCP_START_IND" : "WMA_DHCP_STOP_IND", |
| 792 | ta_dhcp_ind->device_mode, |
Srinivas Girigowda | 296105a | 2015-09-24 16:31:16 -0700 | [diff] [blame] | 793 | MAC_ADDR_ARRAY(ta_dhcp_ind->peerMacAddr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | |
| 795 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 796 | if (!buf) { |
| 797 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 798 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | } |
| 800 | |
| 801 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 802 | peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr; |
| 803 | WMITLV_SET_HDR(&peer_set_param_fp->tlv_header, |
| 804 | WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param, |
| 805 | WMITLV_GET_STRUCT_TLVLEN |
| 806 | (wmi_peer_set_param_cmd_fixed_param)); |
| 807 | |
| 808 | /* fill in values */ |
| 809 | peer_set_param_fp->vdev_id = vdev_id; |
| 810 | peer_set_param_fp->param_id = WMI_PEER_CRIT_PROTO_HINT_ENABLED; |
| 811 | if (WMA_DHCP_START_IND == ta_dhcp_ind->msgType) |
| 812 | peer_set_param_fp->param_value = 1; |
| 813 | else |
| 814 | peer_set_param_fp->param_value = 0; |
Srinivas Girigowda | 296105a | 2015-09-24 16:31:16 -0700 | [diff] [blame] | 815 | WMI_CHAR_ARRAY_TO_MAC_ADDR(ta_dhcp_ind->peerMacAddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | &peer_set_param_fp->peer_macaddr); |
| 817 | |
| 818 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 819 | len, WMI_PEER_SET_PARAM_CMDID); |
| 820 | if (status != EOK) { |
| 821 | WMA_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD" |
| 822 | " returned Error %d", __func__, status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 823 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 824 | } |
| 825 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 826 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | /** |
| 830 | * wma_chan_to_mode() - convert channel to phy mode |
| 831 | * @chan: channel number |
| 832 | * @chan_width: channel width |
| 833 | * @vht_capable: vht capable |
| 834 | * @dot11_mode: 802.11 mode |
| 835 | * |
| 836 | * Return: return phy mode |
| 837 | */ |
| 838 | WLAN_PHY_MODE wma_chan_to_mode(u8 chan, phy_ch_width chan_width, |
| 839 | u8 vht_capable, u8 dot11_mode) |
| 840 | { |
| 841 | WLAN_PHY_MODE phymode = MODE_UNKNOWN; |
| 842 | |
| 843 | /* 2.4 GHz band */ |
| 844 | if ((chan >= WMA_11G_CHANNEL_BEGIN) && (chan <= WMA_11G_CHANNEL_END)) { |
| 845 | switch (chan_width) { |
| 846 | case CH_WIDTH_20MHZ: |
| 847 | /* In case of no channel bonding, use dot11_mode |
| 848 | * to set phy mode |
| 849 | */ |
| 850 | switch (dot11_mode) { |
| 851 | case WNI_CFG_DOT11_MODE_11A: |
| 852 | phymode = MODE_11A; |
| 853 | break; |
| 854 | case WNI_CFG_DOT11_MODE_11B: |
| 855 | phymode = MODE_11B; |
| 856 | break; |
| 857 | case WNI_CFG_DOT11_MODE_11G: |
| 858 | phymode = MODE_11G; |
| 859 | break; |
| 860 | case WNI_CFG_DOT11_MODE_11G_ONLY: |
| 861 | phymode = MODE_11GONLY; |
| 862 | break; |
| 863 | default: |
| 864 | /* Configure MODE_11NG_HT20 for |
| 865 | * self vdev(for vht too) |
| 866 | */ |
| 867 | phymode = MODE_11NG_HT20; |
| 868 | break; |
| 869 | } |
| 870 | break; |
| 871 | case CH_WIDTH_40MHZ: |
| 872 | phymode = vht_capable ? MODE_11AC_VHT40 : |
| 873 | MODE_11NG_HT40; |
| 874 | break; |
| 875 | default: |
| 876 | break; |
| 877 | } |
| 878 | } |
| 879 | |
| 880 | /* 5 GHz band */ |
| 881 | if ((chan >= WMA_11A_CHANNEL_BEGIN) && (chan <= WMA_11A_CHANNEL_END)) { |
| 882 | switch (chan_width) { |
| 883 | case CH_WIDTH_20MHZ: |
| 884 | phymode = vht_capable ? MODE_11AC_VHT20 : |
| 885 | MODE_11NA_HT20; |
| 886 | break; |
| 887 | case CH_WIDTH_40MHZ: |
| 888 | phymode = vht_capable ? MODE_11AC_VHT40 : |
| 889 | MODE_11NA_HT40; |
| 890 | break; |
| 891 | case CH_WIDTH_80MHZ: |
| 892 | phymode = MODE_11AC_VHT80; |
| 893 | break; |
| 894 | #if CONFIG_160MHZ_SUPPORT != 0 |
| 895 | case CH_WIDTH_160MHZ: |
| 896 | phymode = MODE_11AC_VHT160; |
| 897 | break; |
| 898 | case CH_WIDTH_80P80MHZ: |
| 899 | phymode = MODE_11AC_VHT80_80; |
| 900 | break; |
| 901 | #endif |
| 902 | |
| 903 | default: |
| 904 | break; |
| 905 | } |
| 906 | } |
| 907 | |
| 908 | /* 5.9 GHz Band */ |
| 909 | if ((chan >= WMA_11P_CHANNEL_BEGIN) && (chan <= WMA_11P_CHANNEL_END)) |
| 910 | /* Only Legacy Modulation Schemes are supported */ |
| 911 | phymode = MODE_11A; |
| 912 | |
| 913 | WMA_LOGD("%s: phymode %d channel %d ch_width %d vht_capable %d " |
| 914 | "dot11_mode %d", __func__, phymode, chan, |
| 915 | chan_width, vht_capable, dot11_mode); |
| 916 | |
| 917 | return phymode; |
| 918 | } |
| 919 | |
| 920 | /** |
| 921 | * wma_get_link_speed() -send command to get linkspeed |
| 922 | * @handle: wma handle |
| 923 | * @pLinkSpeed: link speed info |
| 924 | * |
| 925 | * Return: CDF status |
| 926 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 927 | QDF_STATUS wma_get_link_speed(WMA_HANDLE handle, tSirLinkSpeedInfo *pLinkSpeed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 928 | { |
| 929 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 930 | wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd; |
| 931 | wmi_buf_t wmi_buf; |
| 932 | uint32_t len; |
| 933 | uint8_t *buf_ptr; |
| 934 | |
| 935 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 936 | WMA_LOGE("%s: WMA is closed, can not issue get link speed cmd", |
| 937 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 938 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | } |
| 940 | if (!WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap, |
| 941 | WMI_SERVICE_ESTIMATE_LINKSPEED)) { |
| 942 | WMA_LOGE("%s: Linkspeed feature bit not enabled" |
| 943 | " Sending value 0 as link speed.", __func__); |
| 944 | wma_send_link_speed(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 945 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | } |
| 947 | len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param); |
| 948 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 949 | if (!wmi_buf) { |
| 950 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 951 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 952 | } |
| 953 | buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf); |
| 954 | |
| 955 | cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr; |
| 956 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 957 | WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param, |
| 958 | WMITLV_GET_STRUCT_TLVLEN |
| 959 | (wmi_peer_get_estimated_linkspeed_cmd_fixed_param)); |
| 960 | |
| 961 | /* Copy the peer macaddress to the wma buffer */ |
Srinivas Girigowda | dccab9a | 2015-11-19 14:31:14 -0800 | [diff] [blame] | 962 | WMI_CHAR_ARRAY_TO_MAC_ADDR(pLinkSpeed->peer_macaddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 963 | &cmd->peer_macaddr); |
| 964 | |
| 965 | WMA_LOGD("%s: pLinkSpeed->peerMacAddr: %pM, " |
| 966 | "peer_macaddr.mac_addr31to0: 0x%x, peer_macaddr.mac_addr47to32: 0x%x", |
Srinivas Girigowda | dccab9a | 2015-11-19 14:31:14 -0800 | [diff] [blame] | 967 | __func__, pLinkSpeed->peer_macaddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 968 | cmd->peer_macaddr.mac_addr31to0, |
| 969 | cmd->peer_macaddr.mac_addr47to32); |
| 970 | |
| 971 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 972 | WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) { |
| 973 | WMA_LOGE("%s: failed to send link speed command", __func__); |
| 974 | cdf_nbuf_free(wmi_buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 975 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 977 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | #ifdef FEATURE_GREEN_AP |
| 981 | |
| 982 | /** |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 983 | * wma_egap_info_status_event() - egap info status event |
| 984 | * @handle: pointer to wma handler |
| 985 | * @event: pointer to event |
| 986 | * @len: len of the event |
| 987 | * |
| 988 | * Return: 0 for success, otherwise appropriate error code |
| 989 | */ |
| 990 | static int wma_egap_info_status_event(void *handle, u_int8_t *event, |
| 991 | uint32_t len) |
| 992 | { |
| 993 | WMI_TX_PAUSE_EVENTID_param_tlvs *param_buf; |
| 994 | wmi_ap_ps_egap_info_event_fixed_param *egap_info_event; |
| 995 | wmi_ap_ps_egap_info_chainmask_list *chainmask_event; |
| 996 | u_int8_t *buf_ptr; |
| 997 | |
| 998 | param_buf = (WMI_TX_PAUSE_EVENTID_param_tlvs *)event; |
| 999 | if (!param_buf) { |
| 1000 | WMA_LOGE("Invalid EGAP Info status event buffer"); |
| 1001 | return -EINVAL; |
| 1002 | } |
| 1003 | |
| 1004 | egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *) |
| 1005 | param_buf->fixed_param; |
| 1006 | buf_ptr = (uint8_t *)egap_info_event; |
| 1007 | buf_ptr += sizeof(wmi_ap_ps_egap_info_event_fixed_param); |
| 1008 | chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)buf_ptr; |
| 1009 | |
| 1010 | WMA_LOGI("mac_id: %d, status: %d, tx_mask: %x, rx_mask: %d", |
| 1011 | chainmask_event->mac_id, |
| 1012 | egap_info_event->status, |
| 1013 | chainmask_event->tx_chainmask, |
| 1014 | chainmask_event->rx_chainmask); |
| 1015 | return 0; |
| 1016 | } |
| 1017 | |
| 1018 | /** |
| 1019 | * wma_send_egap_conf_params() - send wmi cmd of egap configuration params |
| 1020 | * @wma_handle: wma handler |
| 1021 | * @egap_params: pointer to egap_params |
| 1022 | * |
| 1023 | * Return: 0 for success, otherwise appropriate error code |
| 1024 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1025 | QDF_STATUS wma_send_egap_conf_params(WMA_HANDLE handle, |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1026 | struct egap_conf_params *egap_params) |
| 1027 | { |
| 1028 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 1029 | wmi_ap_ps_egap_param_cmd_fixed_param *cmd; |
| 1030 | wmi_buf_t buf; |
| 1031 | int32_t err; |
| 1032 | |
| 1033 | buf = wmi_buf_alloc(wma_handle->wmi_handle, sizeof(*cmd)); |
| 1034 | if (!buf) { |
| 1035 | WMA_LOGE("Failed to allocate buffer to send ap_ps_egap cmd"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1036 | return QDF_STATUS_E_NOMEM; |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1037 | } |
| 1038 | cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf); |
| 1039 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 1040 | WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param, |
| 1041 | WMITLV_GET_STRUCT_TLVLEN( |
| 1042 | wmi_ap_ps_egap_param_cmd_fixed_param)); |
| 1043 | |
| 1044 | cmd->enable = egap_params->enable; |
| 1045 | cmd->inactivity_time = egap_params->inactivity_time; |
| 1046 | cmd->wait_time = egap_params->wait_time; |
| 1047 | cmd->flags = egap_params->flags; |
| 1048 | err = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 1049 | sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID); |
| 1050 | if (err) { |
| 1051 | WMA_LOGE("Failed to send ap_ps_egap cmd"); |
| 1052 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1053 | return QDF_STATUS_E_FAILURE; |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1054 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1055 | return QDF_STATUS_SUCCESS; |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1056 | } |
| 1057 | |
| 1058 | /** |
| 1059 | * wma_setup_egap_support() - setup the EGAP support flag |
| 1060 | * @tgt_cfg: pointer to hdd target configuration |
| 1061 | * @egap_support: EGAP support flag |
| 1062 | * |
| 1063 | * Return: None |
| 1064 | */ |
| 1065 | void wma_setup_egap_support(struct wma_tgt_cfg *tgt_cfg, WMA_HANDLE handle) |
| 1066 | { |
| 1067 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 1068 | |
| 1069 | if (tgt_cfg && wma_handle) |
| 1070 | tgt_cfg->egap_support = wma_handle->egap_support; |
| 1071 | } |
| 1072 | |
| 1073 | /** |
| 1074 | * wma_register_egap_event_handle() - register the EGAP event handle |
| 1075 | * @wma_handle: wma handler |
| 1076 | * |
| 1077 | * Return: None |
| 1078 | */ |
| 1079 | void wma_register_egap_event_handle(WMA_HANDLE handle) |
| 1080 | { |
| 1081 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 1082 | int status; |
| 1083 | |
| 1084 | if (WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap, |
| 1085 | WMI_SERVICE_EGAP)) { |
| 1086 | status = wmi_unified_register_event_handler( |
| 1087 | wma_handle->wmi_handle, |
| 1088 | WMI_AP_PS_EGAP_INFO_EVENTID, |
| 1089 | wma_egap_info_status_event); |
| 1090 | if (status) { |
| 1091 | WMA_LOGE("Failed to register Enhance Green AP event"); |
| 1092 | wma_handle->egap_support = false; |
| 1093 | } else { |
| 1094 | WMA_LOGI("Set the Enhance Green AP event handler"); |
| 1095 | wma_handle->egap_support = true; |
| 1096 | } |
| 1097 | } else |
| 1098 | wma_handle->egap_support = false; |
| 1099 | } |
| 1100 | |
| 1101 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1102 | * wmi_unified_pdev_green_ap_ps_enable_cmd() - enable green ap powersave command |
| 1103 | * @wmi_handle: wmi handle |
| 1104 | * @value: value |
| 1105 | * |
| 1106 | * Return: 0 for success or error code |
| 1107 | */ |
| 1108 | int32_t wmi_unified_pdev_green_ap_ps_enable_cmd(wmi_unified_t wmi_handle, |
| 1109 | uint32_t value) |
| 1110 | { |
| 1111 | wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd; |
| 1112 | wmi_buf_t buf; |
| 1113 | int32_t len = sizeof(*cmd); |
| 1114 | |
| 1115 | WMA_LOGD("Set Green AP PS val %d", value); |
| 1116 | |
| 1117 | buf = wmi_buf_alloc(wmi_handle, len); |
| 1118 | if (!buf) { |
| 1119 | WMA_LOGP("%s: Green AP PS Mem Alloc Failed", __func__); |
| 1120 | return -ENOMEM; |
| 1121 | } |
| 1122 | |
| 1123 | cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf); |
| 1124 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 1125 | WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param, |
| 1126 | WMITLV_GET_STRUCT_TLVLEN |
| 1127 | (wmi_pdev_green_ap_ps_enable_cmd_fixed_param)); |
| 1128 | cmd->reserved0 = 0; |
| 1129 | cmd->enable = value; |
| 1130 | |
| 1131 | if (wmi_unified_cmd_send(wmi_handle, buf, len, |
| 1132 | WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) { |
| 1133 | WMA_LOGE("Set Green AP PS param Failed val %d", value); |
| 1134 | cdf_nbuf_free(buf); |
| 1135 | return -EIO; |
| 1136 | } |
| 1137 | return 0; |
| 1138 | } |
| 1139 | #endif /* FEATURE_GREEN_AP */ |
| 1140 | |
Govind Singh | a471e5e | 2015-10-12 17:11:14 +0530 | [diff] [blame] | 1141 | /** |
| 1142 | * wmi_unified_fw_profiling_cmd() - send FW profiling cmd to WLAN FW |
| 1143 | * @wma: wma handle |
| 1144 | * @cmd: Profiling command index |
| 1145 | * @value1: parameter1 value |
| 1146 | * @value2: parameter2 value |
| 1147 | * |
| 1148 | * Return: 0 for success else error code |
| 1149 | */ |
| 1150 | int32_t wmi_unified_fw_profiling_cmd(wmi_unified_t wmi_handle, |
| 1151 | uint32_t cmd, uint32_t value1, uint32_t value2) |
| 1152 | { |
| 1153 | wmi_buf_t buf; |
| 1154 | int32_t len = 0; |
| 1155 | int ret; |
| 1156 | wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd; |
| 1157 | wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd; |
| 1158 | wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd; |
| 1159 | wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd; |
| 1160 | |
| 1161 | switch (cmd) { |
| 1162 | case WMI_WLAN_PROFILE_TRIGGER_CMDID: |
| 1163 | len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param); |
| 1164 | buf = wmi_buf_alloc(wmi_handle, len); |
| 1165 | if (!buf) { |
| 1166 | WMA_LOGP("%s: wmi_buf_alloc Failed", __func__); |
| 1167 | return -ENOMEM; |
| 1168 | } |
| 1169 | prof_trig_cmd = |
| 1170 | (wmi_wlan_profile_trigger_cmd_fixed_param *) |
| 1171 | wmi_buf_data(buf); |
| 1172 | WMITLV_SET_HDR(&prof_trig_cmd->tlv_header, |
| 1173 | WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param, |
| 1174 | WMITLV_GET_STRUCT_TLVLEN |
| 1175 | (wmi_wlan_profile_trigger_cmd_fixed_param)); |
| 1176 | prof_trig_cmd->enable = value1; |
| 1177 | ret = wmi_unified_cmd_send(wmi_handle, buf, len, |
| 1178 | WMI_WLAN_PROFILE_TRIGGER_CMDID); |
| 1179 | if (ret) { |
| 1180 | WMA_LOGE("PROFILE_TRIGGER cmd Failed with value %d", |
| 1181 | value1); |
| 1182 | cdf_nbuf_free(buf); |
| 1183 | return ret; |
| 1184 | } |
| 1185 | break; |
| 1186 | |
| 1187 | case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID: |
| 1188 | len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param); |
| 1189 | buf = wmi_buf_alloc(wmi_handle, len); |
| 1190 | if (!buf) { |
| 1191 | WMA_LOGP("%s: wmi_buf_alloc Failed", __func__); |
| 1192 | return -ENOMEM; |
| 1193 | } |
| 1194 | profile_getdata_cmd = |
| 1195 | (wmi_wlan_profile_get_prof_data_cmd_fixed_param *) |
| 1196 | wmi_buf_data(buf); |
| 1197 | WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header, |
| 1198 | WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param, |
| 1199 | WMITLV_GET_STRUCT_TLVLEN |
| 1200 | (wmi_wlan_profile_get_prof_data_cmd_fixed_param)); |
| 1201 | ret = wmi_unified_cmd_send(wmi_handle, buf, len, |
| 1202 | WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID); |
| 1203 | if (ret) { |
| 1204 | WMA_LOGE("PROFILE_DATA cmd Failed for id %d value %d", |
| 1205 | value1, value2); |
| 1206 | cdf_nbuf_free(buf); |
| 1207 | return ret; |
| 1208 | } |
| 1209 | break; |
| 1210 | |
| 1211 | case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID: |
| 1212 | len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param); |
| 1213 | buf = wmi_buf_alloc(wmi_handle, len); |
| 1214 | if (!buf) { |
| 1215 | WMA_LOGP("%s: wmi_buf_alloc Failed", __func__); |
| 1216 | return -ENOMEM; |
| 1217 | } |
| 1218 | hist_intvl_cmd = |
| 1219 | (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *) |
| 1220 | wmi_buf_data(buf); |
| 1221 | WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header, |
| 1222 | WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param, |
| 1223 | WMITLV_GET_STRUCT_TLVLEN |
| 1224 | (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param)); |
| 1225 | hist_intvl_cmd->profile_id = value1; |
| 1226 | hist_intvl_cmd->value = value2; |
| 1227 | ret = wmi_unified_cmd_send(wmi_handle, buf, len, |
| 1228 | WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID); |
| 1229 | if (ret) { |
| 1230 | WMA_LOGE("HIST_INTVL cmd Failed for id %d value %d", |
| 1231 | value1, value2); |
| 1232 | cdf_nbuf_free(buf); |
| 1233 | return ret; |
| 1234 | } |
| 1235 | break; |
| 1236 | |
| 1237 | case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID: |
| 1238 | len = |
| 1239 | sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param); |
| 1240 | buf = wmi_buf_alloc(wmi_handle, len); |
| 1241 | if (!buf) { |
| 1242 | WMA_LOGP("%s: wmi_buf_alloc Failed", __func__); |
| 1243 | return -ENOMEM; |
| 1244 | } |
| 1245 | profile_enable_cmd = |
| 1246 | (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *) |
| 1247 | wmi_buf_data(buf); |
| 1248 | WMITLV_SET_HDR(&profile_enable_cmd->tlv_header, |
| 1249 | WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param, |
| 1250 | WMITLV_GET_STRUCT_TLVLEN |
| 1251 | (wmi_wlan_profile_enable_profile_id_cmd_fixed_param)); |
| 1252 | profile_enable_cmd->profile_id = value1; |
| 1253 | profile_enable_cmd->enable = value2; |
| 1254 | ret = wmi_unified_cmd_send(wmi_handle, buf, len, |
| 1255 | WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID); |
| 1256 | if (ret) { |
| 1257 | WMA_LOGE("enable cmd Failed for id %d value %d", |
| 1258 | value1, value2); |
| 1259 | cdf_nbuf_free(buf); |
| 1260 | return ret; |
| 1261 | } |
| 1262 | break; |
| 1263 | |
| 1264 | default: |
| 1265 | WMA_LOGD("%s: invalid profiling command", __func__); |
| 1266 | break; |
| 1267 | } |
| 1268 | |
| 1269 | return 0; |
| 1270 | } |
| 1271 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1272 | #ifdef FEATURE_WLAN_LPHB |
| 1273 | /** |
| 1274 | * wma_lphb_handler() - send LPHB indication to SME |
| 1275 | * @wma: wma handle |
| 1276 | * @event: event handler |
| 1277 | * |
| 1278 | * Return: 0 for success or error code |
| 1279 | */ |
| 1280 | static int wma_lphb_handler(tp_wma_handle wma, uint8_t *event) |
| 1281 | { |
| 1282 | wmi_hb_ind_event_fixed_param *hb_fp; |
| 1283 | tSirLPHBInd *slphb_indication; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1284 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1285 | cds_msg_t sme_msg = { 0 }; |
| 1286 | |
| 1287 | hb_fp = (wmi_hb_ind_event_fixed_param *) event; |
| 1288 | if (!hb_fp) { |
| 1289 | WMA_LOGE("Invalid wmi_hb_ind_event_fixed_param buffer"); |
| 1290 | return -EINVAL; |
| 1291 | } |
| 1292 | |
| 1293 | WMA_LOGD("lphb indication received with vdev_id=%d, session=%d, reason=%d", |
| 1294 | hb_fp->vdev_id, hb_fp->session, hb_fp->reason); |
| 1295 | |
| 1296 | slphb_indication = (tSirLPHBInd *) cdf_mem_malloc(sizeof(tSirLPHBInd)); |
| 1297 | |
| 1298 | if (!slphb_indication) { |
| 1299 | WMA_LOGE("Invalid LPHB indication buffer"); |
| 1300 | return -ENOMEM; |
| 1301 | } |
| 1302 | |
| 1303 | slphb_indication->sessionIdx = hb_fp->session; |
| 1304 | slphb_indication->protocolType = hb_fp->reason; |
| 1305 | slphb_indication->eventReason = hb_fp->reason; |
| 1306 | |
| 1307 | sme_msg.type = eWNI_SME_LPHB_IND; |
| 1308 | sme_msg.bodyptr = slphb_indication; |
| 1309 | sme_msg.bodyval = 0; |
| 1310 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1311 | qdf_status = cds_mq_post_message(CDF_MODULE_ID_SME, &sme_msg); |
| 1312 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1313 | WMA_LOGE("Fail to post eWNI_SME_LPHB_IND msg to SME"); |
| 1314 | cdf_mem_free(slphb_indication); |
| 1315 | return -EINVAL; |
| 1316 | } |
| 1317 | |
| 1318 | return 0; |
| 1319 | } |
| 1320 | #endif /* FEATURE_WLAN_LPHB */ |
| 1321 | |
| 1322 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 1323 | /** |
| 1324 | * wma_wow_sta_ra_filter() - set RA filter pattern in fw |
| 1325 | * @wma: wma handle |
| 1326 | * @vdev_id: vdev id |
| 1327 | * |
| 1328 | * Return: CDF status |
| 1329 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1330 | static QDF_STATUS wma_wow_sta_ra_filter(tp_wma_handle wma, uint8_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1331 | { |
| 1332 | |
| 1333 | WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd; |
| 1334 | struct wma_txrx_node *iface; |
| 1335 | wmi_buf_t buf; |
| 1336 | uint8_t *buf_ptr; |
| 1337 | int32_t len; |
| 1338 | int ret; |
| 1339 | |
| 1340 | iface = &wma->interfaces[vdev_id]; |
| 1341 | |
| 1342 | len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) + |
| 1343 | WMI_TLV_HDR_SIZE + |
| 1344 | 0 * sizeof(WOW_BITMAP_PATTERN_T) + |
| 1345 | WMI_TLV_HDR_SIZE + |
| 1346 | 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) + |
| 1347 | WMI_TLV_HDR_SIZE + |
| 1348 | 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) + |
| 1349 | WMI_TLV_HDR_SIZE + |
| 1350 | 0 * sizeof(WOW_MAGIC_PATTERN_CMD) + |
| 1351 | WMI_TLV_HDR_SIZE + |
| 1352 | 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32); |
| 1353 | |
| 1354 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 1355 | if (!buf) { |
| 1356 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1357 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf); |
| 1361 | buf_ptr = (uint8_t *) cmd; |
| 1362 | |
| 1363 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 1364 | WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param, |
| 1365 | WMITLV_GET_STRUCT_TLVLEN |
| 1366 | (WMI_WOW_ADD_PATTERN_CMD_fixed_param)); |
| 1367 | cmd->vdev_id = vdev_id; |
| 1368 | cmd->pattern_id = iface->num_wow_default_patterns++, |
| 1369 | cmd->pattern_type = WOW_IPV6_RA_PATTERN; |
| 1370 | buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param); |
| 1371 | |
| 1372 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */ |
| 1373 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 1374 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1375 | |
| 1376 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */ |
| 1377 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 1378 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1379 | |
| 1380 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */ |
| 1381 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 1382 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1383 | |
| 1384 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */ |
| 1385 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 1386 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1387 | |
| 1388 | /* Fill TLV for pattern_info_timeout but no data. */ |
| 1389 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0); |
| 1390 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1391 | |
| 1392 | /* Fill TLV for ra_ratelimit_interval. */ |
| 1393 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32)); |
| 1394 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 1395 | |
| 1396 | *((A_UINT32 *) buf_ptr) = wma->RArateLimitInterval; |
| 1397 | |
| 1398 | WMA_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__, |
| 1399 | wma->RArateLimitInterval, vdev_id); |
| 1400 | |
| 1401 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 1402 | WMI_WOW_ADD_WAKE_PATTERN_CMDID); |
| 1403 | if (ret) { |
| 1404 | WMA_LOGE("%s: Failed to send RA rate limit to fw", __func__); |
| 1405 | wmi_buf_free(buf); |
| 1406 | iface->num_wow_default_patterns--; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1407 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1408 | } |
| 1409 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1410 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | |
| 1412 | } |
| 1413 | #endif /* FEATURE_WLAN_RA_FILTERING */ |
| 1414 | |
| 1415 | /** |
| 1416 | * wmi_unified_nat_keepalive_enable() - enable NAT keepalive filter |
| 1417 | * @wma: wma handle |
| 1418 | * @vdev_id: vdev id |
| 1419 | * |
| 1420 | * Return: 0 for success or error code |
| 1421 | */ |
| 1422 | int wmi_unified_nat_keepalive_enable(tp_wma_handle wma, uint8_t vdev_id) |
| 1423 | { |
| 1424 | WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd; |
| 1425 | wmi_buf_t buf; |
| 1426 | int32_t len = sizeof(*cmd); |
| 1427 | |
| 1428 | WMA_LOGD("%s: vdev_id %d", __func__, vdev_id); |
| 1429 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 1430 | if (!buf) { |
| 1431 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 1432 | return -ENOMEM; |
| 1433 | } |
| 1434 | cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *) |
| 1435 | wmi_buf_data(buf); |
| 1436 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 1437 | WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param, |
| 1438 | WMITLV_GET_STRUCT_TLVLEN |
| 1439 | (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param)); |
| 1440 | cmd->vdev_id = vdev_id; |
| 1441 | cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE; |
| 1442 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 1443 | WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) { |
| 1444 | WMA_LOGP("%s: Failed to send NAT keepalive enable command", |
| 1445 | __func__); |
| 1446 | wmi_buf_free(buf); |
| 1447 | return -EIO; |
| 1448 | } |
| 1449 | return 0; |
| 1450 | } |
| 1451 | |
| 1452 | /** |
| 1453 | * wmi_unified_csa_offload_enable() - sen CSA offload enable command |
| 1454 | * @wma: wma handle |
| 1455 | * @vdev_id: vdev id |
| 1456 | * |
| 1457 | * Return: 0 for success or error code |
| 1458 | */ |
| 1459 | int wmi_unified_csa_offload_enable(tp_wma_handle wma, uint8_t vdev_id) |
| 1460 | { |
| 1461 | wmi_csa_offload_enable_cmd_fixed_param *cmd; |
| 1462 | wmi_buf_t buf; |
| 1463 | int32_t len = sizeof(*cmd); |
| 1464 | |
| 1465 | WMA_LOGD("%s: vdev_id %d", __func__, vdev_id); |
| 1466 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 1467 | if (!buf) { |
| 1468 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 1469 | return -ENOMEM; |
| 1470 | } |
| 1471 | cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf); |
| 1472 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 1473 | WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param, |
| 1474 | WMITLV_GET_STRUCT_TLVLEN |
| 1475 | (wmi_csa_offload_enable_cmd_fixed_param)); |
| 1476 | cmd->vdev_id = vdev_id; |
| 1477 | cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE; |
| 1478 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 1479 | WMI_CSA_OFFLOAD_ENABLE_CMDID)) { |
| 1480 | WMA_LOGP("%s: Failed to send CSA offload enable command", |
| 1481 | __func__); |
| 1482 | wmi_buf_free(buf); |
| 1483 | return -EIO; |
| 1484 | } |
| 1485 | return 0; |
| 1486 | } |
| 1487 | |
| 1488 | #ifdef WLAN_FEATURE_NAN |
| 1489 | /** |
| 1490 | * wma_nan_rsp_event_handler() - Function is used to handle nan response |
| 1491 | * @handle: wma handle |
| 1492 | * @event_buf: event buffer |
| 1493 | * @len: length of buffer |
| 1494 | * |
| 1495 | * Return: 0 for success or error code |
| 1496 | */ |
| 1497 | int wma_nan_rsp_event_handler(void *handle, uint8_t *event_buf, |
| 1498 | uint32_t len) |
| 1499 | { |
| 1500 | WMI_NAN_EVENTID_param_tlvs *param_buf; |
| 1501 | tSirNanEvent *nan_rsp_event; |
| 1502 | wmi_nan_event_hdr *nan_rsp_event_hdr; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1503 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | cds_msg_t cds_msg; |
| 1505 | uint8_t *buf_ptr; |
| 1506 | uint32_t alloc_len; |
| 1507 | |
| 1508 | /* |
| 1509 | * This is how received event_buf looks like |
| 1510 | * |
| 1511 | * <-------------------- event_buf -----------------------------------> |
| 1512 | * |
| 1513 | * <--wmi_nan_event_hdr--><---WMI_TLV_HDR_SIZE---><----- data --------> |
| 1514 | * |
| 1515 | * +-----------+---------+-----------------------+--------------------+ |
| 1516 | * | tlv_header| data_len| WMITLV_TAG_ARRAY_BYTE | nan_rsp_event_data | |
| 1517 | * +-----------+---------+-----------------------+--------------------+ |
| 1518 | */ |
| 1519 | |
| 1520 | WMA_LOGD("%s: Posting NaN response event to SME", __func__); |
| 1521 | param_buf = (WMI_NAN_EVENTID_param_tlvs *) event_buf; |
| 1522 | if (!param_buf) { |
| 1523 | WMA_LOGE("%s: Invalid nan response event buf", __func__); |
| 1524 | return -EINVAL; |
| 1525 | } |
| 1526 | nan_rsp_event_hdr = param_buf->fixed_param; |
| 1527 | buf_ptr = (uint8_t *) nan_rsp_event_hdr; |
| 1528 | alloc_len = sizeof(tSirNanEvent); |
| 1529 | alloc_len += nan_rsp_event_hdr->data_len; |
| 1530 | nan_rsp_event = (tSirNanEvent *) cdf_mem_malloc(alloc_len); |
| 1531 | if (NULL == nan_rsp_event) { |
| 1532 | WMA_LOGE("%s: Memory allocation failure", __func__); |
| 1533 | return -ENOMEM; |
| 1534 | } |
| 1535 | |
| 1536 | nan_rsp_event->event_data_len = nan_rsp_event_hdr->data_len; |
| 1537 | cdf_mem_copy(nan_rsp_event->event_data, buf_ptr + |
| 1538 | sizeof(wmi_nan_event_hdr) + WMI_TLV_HDR_SIZE, |
| 1539 | nan_rsp_event->event_data_len); |
| 1540 | cds_msg.type = eWNI_SME_NAN_EVENT; |
| 1541 | cds_msg.bodyptr = (void *)nan_rsp_event; |
| 1542 | cds_msg.bodyval = 0; |
| 1543 | |
| 1544 | status = cds_mq_post_message(CDS_MQ_ID_SME, &cds_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 1545 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | WMA_LOGE("%s: Failed to post NaN response event to SME", |
| 1547 | __func__); |
| 1548 | cdf_mem_free(nan_rsp_event); |
| 1549 | return -EFAULT; |
| 1550 | } |
| 1551 | WMA_LOGD("%s: NaN response event Posted to SME", __func__); |
| 1552 | return 0; |
| 1553 | } |
| 1554 | #endif /* WLAN_FEATURE_NAN */ |
| 1555 | |
| 1556 | /** |
| 1557 | * wma_csa_offload_handler() - CSA event handler |
| 1558 | * @handle: wma handle |
| 1559 | * @event: event buffer |
| 1560 | * @len: buffer length |
| 1561 | * |
| 1562 | * This event is sent by firmware when it receives CSA IE. |
| 1563 | * |
| 1564 | * Return: 0 for success or error code |
| 1565 | */ |
| 1566 | int wma_csa_offload_handler(void *handle, uint8_t *event, uint32_t len) |
| 1567 | { |
| 1568 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1569 | WMI_CSA_HANDLING_EVENTID_param_tlvs *param_buf; |
| 1570 | wmi_csa_event_fixed_param *csa_event; |
| 1571 | uint8_t bssid[IEEE80211_ADDR_LEN]; |
| 1572 | uint8_t vdev_id = 0; |
| 1573 | uint8_t cur_chan = 0; |
| 1574 | struct ieee80211_channelswitch_ie *csa_ie; |
| 1575 | tpCSAOffloadParams csa_offload_event; |
| 1576 | struct ieee80211_extendedchannelswitch_ie *xcsa_ie; |
| 1577 | struct ieee80211_ie_wide_bw_switch *wb_ie; |
| 1578 | struct wma_txrx_node *intr = wma->interfaces; |
| 1579 | |
| 1580 | param_buf = (WMI_CSA_HANDLING_EVENTID_param_tlvs *) event; |
| 1581 | |
| 1582 | WMA_LOGD("%s: Enter", __func__); |
| 1583 | if (!param_buf) { |
| 1584 | WMA_LOGE("Invalid csa event buffer"); |
| 1585 | return -EINVAL; |
| 1586 | } |
| 1587 | csa_event = param_buf->fixed_param; |
| 1588 | WMI_MAC_ADDR_TO_CHAR_ARRAY(&csa_event->i_addr2, &bssid[0]); |
| 1589 | |
| 1590 | if (wma_find_vdev_by_bssid(wma, bssid, &vdev_id) == NULL) { |
| 1591 | WMA_LOGE("Invalid bssid received %s:%d", __func__, __LINE__); |
| 1592 | return -EINVAL; |
| 1593 | } |
| 1594 | |
| 1595 | csa_offload_event = cdf_mem_malloc(sizeof(*csa_offload_event)); |
| 1596 | if (!csa_offload_event) { |
| 1597 | WMA_LOGE("CDF MEM Alloc Failed for csa_offload_event"); |
| 1598 | return -EINVAL; |
| 1599 | } |
| 1600 | |
| 1601 | cdf_mem_zero(csa_offload_event, sizeof(*csa_offload_event)); |
| 1602 | cdf_mem_copy(csa_offload_event->bssId, &bssid, IEEE80211_ADDR_LEN); |
| 1603 | |
| 1604 | if (csa_event->ies_present_flag & WMI_CSA_IE_PRESENT) { |
| 1605 | csa_ie = (struct ieee80211_channelswitch_ie *) |
| 1606 | (&csa_event->csa_ie[0]); |
| 1607 | csa_offload_event->channel = csa_ie->newchannel; |
| 1608 | csa_offload_event->switchmode = csa_ie->switchmode; |
| 1609 | } else if (csa_event->ies_present_flag & WMI_XCSA_IE_PRESENT) { |
| 1610 | xcsa_ie = (struct ieee80211_extendedchannelswitch_ie *) |
| 1611 | (&csa_event->xcsa_ie[0]); |
| 1612 | csa_offload_event->channel = xcsa_ie->newchannel; |
| 1613 | csa_offload_event->switchmode = xcsa_ie->switchmode; |
Gupta, Kapil | 121bf21 | 2015-11-25 19:21:29 +0530 | [diff] [blame] | 1614 | csa_offload_event->new_op_class = xcsa_ie->newClass; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | } else { |
| 1616 | WMA_LOGE("CSA Event error: No CSA IE present"); |
| 1617 | cdf_mem_free(csa_offload_event); |
| 1618 | return -EINVAL; |
| 1619 | } |
| 1620 | |
| 1621 | if (csa_event->ies_present_flag & WMI_WBW_IE_PRESENT) { |
| 1622 | wb_ie = (struct ieee80211_ie_wide_bw_switch *) |
| 1623 | (&csa_event->wb_ie[0]); |
| 1624 | csa_offload_event->new_ch_width = wb_ie->new_ch_width; |
| 1625 | csa_offload_event->new_ch_freq_seg1 = wb_ie->new_ch_freq_seg1; |
| 1626 | csa_offload_event->new_ch_freq_seg2 = wb_ie->new_ch_freq_seg2; |
| 1627 | } |
| 1628 | |
| 1629 | csa_offload_event->ies_present_flag = csa_event->ies_present_flag; |
| 1630 | |
| 1631 | WMA_LOGD("CSA: New Channel = %d BSSID:%pM", |
| 1632 | csa_offload_event->channel, csa_offload_event->bssId); |
| 1633 | |
| 1634 | cur_chan = cds_freq_to_chan(intr[vdev_id].mhz); |
| 1635 | /* |
| 1636 | * basic sanity check: requested channel should not be 0 |
| 1637 | * and equal to home channel |
| 1638 | */ |
| 1639 | if ((0 == csa_offload_event->channel) || |
| 1640 | (cur_chan == csa_offload_event->channel)) { |
| 1641 | WMA_LOGE("CSA Event with channel %d. Ignore !!", |
| 1642 | csa_offload_event->channel); |
| 1643 | cdf_mem_free(csa_offload_event); |
| 1644 | return -EINVAL; |
| 1645 | } |
| 1646 | wma->interfaces[vdev_id].is_channel_switch = true; |
| 1647 | wma_send_msg(wma, WMA_CSA_OFFLOAD_EVENT, (void *)csa_offload_event, 0); |
| 1648 | return 0; |
| 1649 | } |
| 1650 | |
| 1651 | #ifdef FEATURE_OEM_DATA_SUPPORT |
| 1652 | |
| 1653 | /** |
| 1654 | * wma_oem_capability_event_callback() - OEM capability event handler |
| 1655 | * @handle: wma handle |
| 1656 | * @datap: data ptr |
| 1657 | * @len: data length |
| 1658 | * |
| 1659 | * Return: 0 for success or error code |
| 1660 | */ |
| 1661 | int wma_oem_capability_event_callback(void *handle, |
| 1662 | uint8_t *datap, uint32_t len) |
| 1663 | { |
| 1664 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1665 | WMI_OEM_CAPABILITY_EVENTID_param_tlvs *param_buf; |
| 1666 | uint8_t *data; |
| 1667 | uint32_t datalen; |
| 1668 | uint32_t *msg_subtype; |
| 1669 | tStartOemDataRsp *pStartOemDataRsp; |
| 1670 | |
| 1671 | param_buf = (WMI_OEM_CAPABILITY_EVENTID_param_tlvs *) datap; |
| 1672 | if (!param_buf) { |
| 1673 | WMA_LOGE("%s: Received NULL buf ptr from FW", __func__); |
| 1674 | return -ENOMEM; |
| 1675 | } |
| 1676 | |
| 1677 | data = param_buf->data; |
| 1678 | datalen = param_buf->num_data; |
| 1679 | |
| 1680 | if (!data) { |
| 1681 | WMA_LOGE("%s: Received NULL data from FW", __func__); |
| 1682 | return -EINVAL; |
| 1683 | } |
| 1684 | |
| 1685 | /* wma puts 4 bytes prefix for msg subtype, so length |
| 1686 | * of data received from target should be 4 bytes less |
| 1687 | * then max allowed |
| 1688 | */ |
| 1689 | if (datalen > (OEM_DATA_RSP_SIZE - 4)) { |
| 1690 | WMA_LOGE("%s: Received data len (%d) exceeds max value (%d)", |
| 1691 | __func__, datalen, (OEM_DATA_RSP_SIZE - 4)); |
| 1692 | return -EINVAL; |
| 1693 | } |
| 1694 | |
| 1695 | pStartOemDataRsp = cdf_mem_malloc(sizeof(*pStartOemDataRsp)); |
| 1696 | if (!pStartOemDataRsp) { |
| 1697 | WMA_LOGE("%s: Failed to alloc pStartOemDataRsp", __func__); |
| 1698 | return -ENOMEM; |
| 1699 | } |
| 1700 | |
| 1701 | cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 1702 | pStartOemDataRsp->target_rsp = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1703 | msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); |
| 1704 | *msg_subtype = WMI_OEM_CAPABILITY_RSP; |
| 1705 | cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); |
| 1706 | |
| 1707 | WMA_LOGI("%s: Sending WMA_START_OEM_DATA_RSP, data len (%d)", |
| 1708 | __func__, datalen); |
| 1709 | |
| 1710 | wma_send_msg(wma, WMA_START_OEM_DATA_RSP, (void *)pStartOemDataRsp, 0); |
| 1711 | return 0; |
| 1712 | } |
| 1713 | |
| 1714 | /** |
| 1715 | * wma_oem_measurement_report_event_callback() - OEM measurement report handler |
| 1716 | * @handle: wma handle |
| 1717 | * @datap: data ptr |
| 1718 | * @len: data length |
| 1719 | * |
| 1720 | * Return: 0 for success or error code |
| 1721 | */ |
| 1722 | int wma_oem_measurement_report_event_callback(void *handle, |
| 1723 | uint8_t *datap, |
| 1724 | uint32_t len) |
| 1725 | { |
| 1726 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1727 | WMI_OEM_MEASUREMENT_REPORT_EVENTID_param_tlvs *param_buf; |
| 1728 | uint8_t *data; |
| 1729 | uint32_t datalen; |
| 1730 | uint32_t *msg_subtype; |
| 1731 | tStartOemDataRsp *pStartOemDataRsp; |
| 1732 | |
| 1733 | param_buf = (WMI_OEM_MEASUREMENT_REPORT_EVENTID_param_tlvs *) datap; |
| 1734 | if (!param_buf) { |
| 1735 | WMA_LOGE("%s: Received NULL buf ptr from FW", __func__); |
| 1736 | return -ENOMEM; |
| 1737 | } |
| 1738 | |
| 1739 | data = param_buf->data; |
| 1740 | datalen = param_buf->num_data; |
| 1741 | |
| 1742 | if (!data) { |
| 1743 | WMA_LOGE("%s: Received NULL data from FW", __func__); |
| 1744 | return -EINVAL; |
| 1745 | } |
| 1746 | |
| 1747 | /* wma puts 4 bytes prefix for msg subtype, so length |
| 1748 | * of data received from target should be 4 bytes less |
| 1749 | * then max allowed |
| 1750 | */ |
| 1751 | if (datalen > (OEM_DATA_RSP_SIZE - 4)) { |
| 1752 | WMA_LOGE("%s: Received data len (%d) exceeds max value (%d)", |
| 1753 | __func__, datalen, (OEM_DATA_RSP_SIZE - 4)); |
| 1754 | return -EINVAL; |
| 1755 | } |
| 1756 | |
| 1757 | pStartOemDataRsp = cdf_mem_malloc(sizeof(*pStartOemDataRsp)); |
| 1758 | if (!pStartOemDataRsp) { |
| 1759 | WMA_LOGE("%s: Failed to alloc pStartOemDataRsp", __func__); |
| 1760 | return -ENOMEM; |
| 1761 | } |
| 1762 | |
| 1763 | cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 1764 | pStartOemDataRsp->target_rsp = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1765 | msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); |
| 1766 | *msg_subtype = WMI_OEM_MEASUREMENT_RSP; |
| 1767 | cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); |
| 1768 | |
| 1769 | WMA_LOGI("%s: Sending WMA_START_OEM_DATA_RSP, data len (%d)", |
| 1770 | __func__, datalen); |
| 1771 | |
| 1772 | wma_send_msg(wma, WMA_START_OEM_DATA_RSP, (void *)pStartOemDataRsp, 0); |
| 1773 | return 0; |
| 1774 | } |
| 1775 | |
| 1776 | /** |
| 1777 | * wma_oem_error_report_event_callback() - OEM error report handler |
| 1778 | * @handle: wma handle |
| 1779 | * @datap: data ptr |
| 1780 | * @len: data length |
| 1781 | * |
| 1782 | * Return: 0 for success or error code |
| 1783 | */ |
| 1784 | int wma_oem_error_report_event_callback(void *handle, |
| 1785 | uint8_t *datap, uint32_t len) |
| 1786 | { |
| 1787 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1788 | WMI_OEM_ERROR_REPORT_EVENTID_param_tlvs *param_buf; |
| 1789 | uint8_t *data; |
| 1790 | uint32_t datalen; |
| 1791 | uint32_t *msg_subtype; |
| 1792 | tStartOemDataRsp *pStartOemDataRsp; |
| 1793 | |
| 1794 | param_buf = (WMI_OEM_ERROR_REPORT_EVENTID_param_tlvs *) datap; |
| 1795 | if (!param_buf) { |
| 1796 | WMA_LOGE("%s: Received NULL buf ptr from FW", __func__); |
| 1797 | return -ENOMEM; |
| 1798 | } |
| 1799 | |
| 1800 | data = param_buf->data; |
| 1801 | datalen = param_buf->num_data; |
| 1802 | |
| 1803 | if (!data) { |
| 1804 | WMA_LOGE("%s: Received NULL data from FW", __func__); |
| 1805 | return -EINVAL; |
| 1806 | } |
| 1807 | |
| 1808 | /* wma puts 4 bytes prefix for msg subtype, so length |
| 1809 | * of data received from target should be 4 bytes less |
| 1810 | * then max allowed |
| 1811 | */ |
| 1812 | if (datalen > (OEM_DATA_RSP_SIZE - 4)) { |
| 1813 | WMA_LOGE("%s: Received data len (%d) exceeds max value (%d)", |
| 1814 | __func__, datalen, (OEM_DATA_RSP_SIZE - 4)); |
| 1815 | return -EINVAL; |
| 1816 | } |
| 1817 | |
| 1818 | pStartOemDataRsp = cdf_mem_malloc(sizeof(*pStartOemDataRsp)); |
| 1819 | if (!pStartOemDataRsp) { |
| 1820 | WMA_LOGE("%s: Failed to alloc pStartOemDataRsp", __func__); |
| 1821 | return -ENOMEM; |
| 1822 | } |
| 1823 | |
| 1824 | cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 1825 | pStartOemDataRsp->target_rsp = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1826 | msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); |
| 1827 | *msg_subtype = WMI_OEM_ERROR_REPORT_RSP; |
| 1828 | cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); |
| 1829 | |
| 1830 | WMA_LOGI("%s: Sending WMA_START_OEM_DATA_RSP, data len (%d)", |
| 1831 | __func__, datalen); |
| 1832 | |
| 1833 | wma_send_msg(wma, WMA_START_OEM_DATA_RSP, (void *)pStartOemDataRsp, 0); |
| 1834 | return 0; |
| 1835 | } |
| 1836 | |
| 1837 | /** |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 1838 | * wma_oem_data_response_handler() - OEM data response event handler |
| 1839 | * @handle: wma handle |
| 1840 | * @datap: data ptr |
| 1841 | * @len: data length |
| 1842 | * |
| 1843 | * Return: 0 for success or error code |
| 1844 | */ |
| 1845 | int wma_oem_data_response_handler(void *handle, |
| 1846 | uint8_t *datap, uint32_t len) |
| 1847 | { |
| 1848 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1849 | WMI_OEM_RESPONSE_EVENTID_param_tlvs *param_buf; |
| 1850 | uint8_t *data; |
| 1851 | uint32_t datalen; |
| 1852 | tStartOemDataRsp *oem_data_rsp; |
| 1853 | |
| 1854 | param_buf = (WMI_OEM_RESPONSE_EVENTID_param_tlvs *) datap; |
| 1855 | if (!param_buf) { |
| 1856 | WMA_LOGE(FL("Received NULL buf ptr from FW")); |
| 1857 | return -ENOMEM; |
| 1858 | } |
| 1859 | |
| 1860 | data = param_buf->data; |
| 1861 | datalen = param_buf->num_data; |
| 1862 | |
| 1863 | if (!data) { |
| 1864 | WMA_LOGE(FL("Received NULL data from FW")); |
| 1865 | return -EINVAL; |
| 1866 | } |
| 1867 | |
| 1868 | if (datalen > OEM_DATA_RSP_SIZE) { |
| 1869 | WMA_LOGE(FL("Received data len %d exceeds max value %d"), |
| 1870 | datalen, OEM_DATA_RSP_SIZE); |
| 1871 | return -EINVAL; |
| 1872 | } |
| 1873 | |
| 1874 | oem_data_rsp = cdf_mem_malloc(sizeof(*oem_data_rsp)); |
| 1875 | if (!oem_data_rsp) { |
| 1876 | WMA_LOGE(FL("Failed to alloc oem_data_rsp")); |
| 1877 | return -ENOMEM; |
| 1878 | } |
| 1879 | |
| 1880 | cdf_mem_zero(oem_data_rsp, sizeof(tStartOemDataRsp)); |
| 1881 | oem_data_rsp->target_rsp = true; |
| 1882 | cdf_mem_copy(&oem_data_rsp->oemDataRsp[0], data, datalen); |
| 1883 | |
| 1884 | WMA_LOGI(FL("Sending WMA_START_OEM_DATA_RSP, data len %d"), datalen); |
| 1885 | |
| 1886 | wma_send_msg(wma, WMA_START_OEM_DATA_RSP, (void *)oem_data_rsp, 0); |
| 1887 | return 0; |
| 1888 | } |
| 1889 | |
| 1890 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1891 | * wma_start_oem_data_req() - start OEM data request to target |
| 1892 | * @wma_handle: wma handle |
| 1893 | * @startOemDataReq: start request params |
| 1894 | * |
| 1895 | * Return: none |
| 1896 | */ |
| 1897 | void wma_start_oem_data_req(tp_wma_handle wma_handle, |
| 1898 | tStartOemDataReq *startOemDataReq) |
| 1899 | { |
| 1900 | wmi_buf_t buf; |
| 1901 | uint8_t *cmd; |
| 1902 | int ret = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1903 | tStartOemDataRsp *pStartOemDataRsp; |
| 1904 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1905 | WMA_LOGD(FL("Send OEM Data Request to target")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1907 | if (!startOemDataReq && !startOemDataReq->data) { |
| 1908 | WMA_LOGE(FL("startOemDataReq is null")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | goto out; |
| 1910 | } |
| 1911 | |
| 1912 | if (!wma_handle || !wma_handle->wmi_handle) { |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1913 | WMA_LOGE(FL("WMA - closed, can not send Oem data request cmd")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | return; |
| 1915 | } |
| 1916 | |
| 1917 | buf = wmi_buf_alloc(wma_handle->wmi_handle, |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1918 | (startOemDataReq->data_len + WMI_TLV_HDR_SIZE)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | if (!buf) { |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1920 | WMA_LOGE(FL("wmi_buf_alloc failed")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | goto out; |
| 1922 | } |
| 1923 | |
| 1924 | cmd = (uint8_t *) wmi_buf_data(buf); |
| 1925 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1926 | WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, startOemDataReq->data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1927 | cmd += WMI_TLV_HDR_SIZE; |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1928 | cdf_mem_copy(cmd, startOemDataReq->data, |
| 1929 | startOemDataReq->data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1931 | WMA_LOGI(FL("Sending OEM Data Request to target, data len %d"), |
| 1932 | startOemDataReq->data_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1933 | |
| 1934 | ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1935 | (startOemDataReq->data_len + |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID); |
| 1937 | |
| 1938 | if (ret != EOK) { |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1939 | WMA_LOGE(FL(":wmi cmd send failed")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1940 | cdf_nbuf_free(buf); |
| 1941 | } |
| 1942 | |
| 1943 | out: |
| 1944 | /* free oem data req buffer received from UMAC */ |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1945 | if (startOemDataReq) { |
| 1946 | if (startOemDataReq->data) |
| 1947 | cdf_mem_free(startOemDataReq->data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1948 | cdf_mem_free(startOemDataReq); |
Krishna Kumaar Natarajan | 9ac8efd | 2015-11-20 13:40:24 -0800 | [diff] [blame] | 1949 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1950 | |
| 1951 | /* Now send data resp back to PE/SME with message sub-type of |
| 1952 | * WMI_OEM_INTERNAL_RSP. This is required so that PE/SME clears |
| 1953 | * up pending active command. Later when desired oem response(s) |
| 1954 | * comes as wmi event from target then those shall be passed |
| 1955 | * to oem application |
| 1956 | */ |
| 1957 | pStartOemDataRsp = cdf_mem_malloc(sizeof(*pStartOemDataRsp)); |
| 1958 | if (!pStartOemDataRsp) { |
| 1959 | WMA_LOGE("%s:failed to allocate memory for OEM Data Resp to PE", |
| 1960 | __func__); |
| 1961 | return; |
| 1962 | } |
| 1963 | cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); |
Krishna Kumaar Natarajan | 4e9cf39 | 2015-11-20 13:35:05 -0800 | [diff] [blame] | 1964 | pStartOemDataRsp->target_rsp = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1965 | |
| 1966 | WMA_LOGI("%s: Sending WMA_START_OEM_DATA_RSP to clear up PE/SME pending cmd", |
| 1967 | __func__); |
| 1968 | |
| 1969 | wma_send_msg(wma_handle, WMA_START_OEM_DATA_RSP, |
| 1970 | (void *)pStartOemDataRsp, 0); |
| 1971 | |
| 1972 | return; |
| 1973 | } |
| 1974 | #endif /* FEATURE_OEM_DATA_SUPPORT */ |
| 1975 | |
| 1976 | |
| 1977 | /** |
| 1978 | * wma_unified_dfs_radar_rx_event_handler() - dfs radar rx event handler |
| 1979 | * @handle: wma handle |
| 1980 | * @data: data buffer |
| 1981 | * @datalen: data length |
| 1982 | * |
| 1983 | * WMI handler for WMI_DFS_RADAR_EVENTID |
| 1984 | * This handler is registered for handling |
| 1985 | * filtered DFS Phyerror. This handler is |
| 1986 | * will be invoked only when DFS Phyerr |
| 1987 | * filtering offload is enabled. |
| 1988 | * |
| 1989 | * Return: 1 for Success and 0 for error |
| 1990 | */ |
| 1991 | static int wma_unified_dfs_radar_rx_event_handler(void *handle, |
| 1992 | uint8_t *data, |
| 1993 | uint32_t datalen) |
| 1994 | { |
| 1995 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 1996 | struct ieee80211com *ic; |
| 1997 | struct ath_dfs *dfs; |
| 1998 | struct dfs_event *event; |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 1999 | struct dfs_ieee80211_channel *chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2000 | int empty; |
| 2001 | int do_check_chirp = 0; |
| 2002 | int is_hw_chirp = 0; |
| 2003 | int is_sw_chirp = 0; |
| 2004 | int is_pri = 0; |
| 2005 | |
| 2006 | WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlvs; |
| 2007 | wmi_dfs_radar_event_fixed_param *radar_event; |
| 2008 | |
| 2009 | ic = wma->dfs_ic; |
| 2010 | if (NULL == ic) { |
| 2011 | WMA_LOGE("%s: dfs_ic is NULL ", __func__); |
| 2012 | return 0; |
| 2013 | } |
| 2014 | |
| 2015 | dfs = (struct ath_dfs *)ic->ic_dfs; |
| 2016 | param_tlvs = (WMI_DFS_RADAR_EVENTID_param_tlvs *) data; |
| 2017 | |
| 2018 | if (NULL == dfs) { |
| 2019 | WMA_LOGE("%s: dfs is NULL ", __func__); |
| 2020 | return 0; |
| 2021 | } |
| 2022 | /* |
| 2023 | * This parameter holds the number |
| 2024 | * of phyerror interrupts to the host |
| 2025 | * after the phyerrors have passed through |
| 2026 | * false detect filters in the firmware. |
| 2027 | */ |
| 2028 | dfs->dfs_phyerr_count++; |
| 2029 | |
| 2030 | if (!param_tlvs) { |
| 2031 | WMA_LOGE("%s: Received NULL data from FW", __func__); |
| 2032 | return 0; |
| 2033 | } |
| 2034 | |
| 2035 | radar_event = param_tlvs->fixed_param; |
| 2036 | |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 2037 | cdf_spin_lock_bh(&ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2038 | chan = ic->ic_curchan; |
Edhar, Mahesh Kumar | 35d9b2e | 2015-10-26 17:06:23 +0530 | [diff] [blame] | 2039 | if (ic->disable_phy_err_processing) { |
| 2040 | WMA_LOGD("%s: radar indication done,drop phyerror event", |
| 2041 | __func__); |
| 2042 | cdf_spin_unlock_bh(&ic->chan_lock); |
| 2043 | return 0; |
| 2044 | } |
| 2045 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2046 | if (CHANNEL_STATE_DFS != cds_get_channel_state(chan->ic_ieee)) { |
| 2047 | WMA_LOGE |
| 2048 | ("%s: Invalid DFS Phyerror event. Channel=%d is Non-DFS", |
| 2049 | __func__, chan->ic_ieee); |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 2050 | cdf_spin_unlock_bh(&ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | return 0; |
| 2052 | } |
| 2053 | |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 2054 | cdf_spin_unlock_bh(&ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2055 | dfs->ath_dfs_stats.total_phy_errors++; |
| 2056 | |
| 2057 | if (dfs->dfs_caps.ath_chip_is_bb_tlv) { |
| 2058 | do_check_chirp = 1; |
| 2059 | is_pri = 1; |
| 2060 | is_hw_chirp = radar_event->pulse_is_chirp; |
| 2061 | |
| 2062 | if ((uint32_t) dfs->dfs_phyerr_freq_min > |
| 2063 | radar_event->pulse_center_freq) { |
| 2064 | dfs->dfs_phyerr_freq_min = |
| 2065 | (int)radar_event->pulse_center_freq; |
| 2066 | } |
| 2067 | |
| 2068 | if (dfs->dfs_phyerr_freq_max < |
| 2069 | (int)radar_event->pulse_center_freq) { |
| 2070 | dfs->dfs_phyerr_freq_max = |
| 2071 | (int)radar_event->pulse_center_freq; |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | /* |
| 2076 | * Now, add the parsed, checked and filtered |
| 2077 | * radar phyerror event radar pulse event list. |
| 2078 | * This event will then be processed by |
| 2079 | * dfs_radar_processevent() to see if the pattern |
| 2080 | * of pulses in radar pulse list match any radar |
| 2081 | * singnature in the current regulatory domain. |
| 2082 | */ |
| 2083 | |
| 2084 | ATH_DFSEVENTQ_LOCK(dfs); |
| 2085 | empty = STAILQ_EMPTY(&(dfs->dfs_eventq)); |
| 2086 | ATH_DFSEVENTQ_UNLOCK(dfs); |
| 2087 | if (empty) { |
| 2088 | return 0; |
| 2089 | } |
| 2090 | /* |
| 2091 | * Add the event to the list, if there's space. |
| 2092 | */ |
| 2093 | ATH_DFSEVENTQ_LOCK(dfs); |
| 2094 | event = STAILQ_FIRST(&(dfs->dfs_eventq)); |
| 2095 | if (event == NULL) { |
| 2096 | ATH_DFSEVENTQ_UNLOCK(dfs); |
| 2097 | WMA_LOGE("%s: No more space left for queuing DFS Phyerror events", |
| 2098 | __func__); |
| 2099 | return 0; |
| 2100 | } |
| 2101 | STAILQ_REMOVE_HEAD(&(dfs->dfs_eventq), re_list); |
| 2102 | ATH_DFSEVENTQ_UNLOCK(dfs); |
| 2103 | dfs->dfs_phyerr_queued_count++; |
| 2104 | dfs->dfs_phyerr_w53_counter++; |
| 2105 | event->re_dur = (uint8_t) radar_event->pulse_duration; |
| 2106 | event->re_rssi = radar_event->rssi; |
| 2107 | event->re_ts = radar_event->pulse_detect_ts & DFS_TSMASK; |
| 2108 | event->re_full_ts = (((uint64_t) radar_event->upload_fullts_high) << 32) |
| 2109 | | radar_event->upload_fullts_low; |
| 2110 | |
| 2111 | /* |
| 2112 | * Index of peak magnitude |
| 2113 | */ |
| 2114 | event->sidx = radar_event->peak_sidx; |
| 2115 | |
| 2116 | /* |
| 2117 | * Handle chirp flags. |
| 2118 | */ |
| 2119 | if (do_check_chirp) { |
| 2120 | event->re_flags |= DFS_EVENT_CHECKCHIRP; |
| 2121 | if (is_hw_chirp) { |
| 2122 | event->re_flags |= DFS_EVENT_HW_CHIRP; |
| 2123 | } |
| 2124 | if (is_sw_chirp) { |
| 2125 | event->re_flags |= DFS_EVENT_SW_CHIRP; |
| 2126 | } |
| 2127 | } |
| 2128 | /* |
| 2129 | * Correctly set which channel is being reported on |
| 2130 | */ |
| 2131 | if (is_pri) { |
| 2132 | event->re_chanindex = (uint8_t) dfs->dfs_curchan_radindex; |
| 2133 | } else { |
| 2134 | if (dfs->dfs_extchan_radindex == -1) { |
| 2135 | WMA_LOGI("%s phyerr on ext channel", __func__); |
| 2136 | } |
| 2137 | event->re_chanindex = (uint8_t) dfs->dfs_extchan_radindex; |
| 2138 | WMA_LOGI("%s:New extension channel event is added to queue", |
| 2139 | __func__); |
| 2140 | } |
| 2141 | |
| 2142 | ATH_DFSQ_LOCK(dfs); |
| 2143 | |
| 2144 | STAILQ_INSERT_TAIL(&(dfs->dfs_radarq), event, re_list); |
| 2145 | |
| 2146 | empty = STAILQ_EMPTY(&dfs->dfs_radarq); |
| 2147 | |
| 2148 | ATH_DFSQ_UNLOCK(dfs); |
| 2149 | |
| 2150 | if (!empty && !dfs->ath_radar_tasksched) { |
| 2151 | dfs->ath_radar_tasksched = 1; |
| 2152 | OS_SET_TIMER(&dfs->ath_dfs_task_timer, 0); |
| 2153 | } |
| 2154 | |
| 2155 | return 1; |
| 2156 | |
| 2157 | } |
| 2158 | |
| 2159 | /** |
| 2160 | * wma_unified_phyerr_rx_event_handler() - phyerr event handler |
| 2161 | * @handle: wma handle |
| 2162 | * @data: data buffer |
| 2163 | * @datalen: buffer length |
| 2164 | * |
| 2165 | * WMI Handler for WMI_PHYERR_EVENTID event from firmware. |
| 2166 | * This handler is currently handling only DFS phy errors. |
| 2167 | * This handler will be invoked only when the DFS phyerror |
| 2168 | * filtering offload is disabled. |
| 2169 | * |
| 2170 | * Return: 1:Success, 0:Failure |
| 2171 | */ |
| 2172 | static int wma_unified_phyerr_rx_event_handler(void *handle, |
| 2173 | uint8_t *data, uint32_t datalen) |
| 2174 | { |
| 2175 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 2176 | WMI_PHYERR_EVENTID_param_tlvs *param_tlvs; |
| 2177 | wmi_comb_phyerr_rx_hdr *pe_hdr; |
| 2178 | uint8_t *bufp; |
| 2179 | wmi_single_phyerr_rx_event *ev; |
| 2180 | struct ieee80211com *ic = wma->dfs_ic; |
| 2181 | cdf_size_t n; |
| 2182 | A_UINT64 tsf64 = 0; |
| 2183 | int phy_err_code = 0; |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2184 | A_UINT32 phy_err_mask = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2185 | int error = 0; |
| 2186 | tpAniSirGlobal mac_ctx = |
| 2187 | (tpAniSirGlobal)cds_get_context(CDF_MODULE_ID_PE); |
| 2188 | bool enable_log = false; |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2189 | int max_dfs_buf_length = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2190 | |
| 2191 | if (NULL == mac_ctx) { |
| 2192 | WMA_LOGE("%s: mac_ctx is NULL", __func__); |
| 2193 | return 0; |
| 2194 | } |
| 2195 | enable_log = mac_ctx->sap.enable_dfs_phy_error_logs; |
| 2196 | |
| 2197 | param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *) data; |
| 2198 | |
| 2199 | if (!param_tlvs) { |
| 2200 | WMA_LOGE("%s: Received NULL data from FW", __func__); |
| 2201 | return 0; |
| 2202 | } |
| 2203 | |
| 2204 | pe_hdr = param_tlvs->hdr; |
| 2205 | if (pe_hdr == NULL) { |
| 2206 | WMA_LOGE("%s: Received Data PE Header is NULL", __func__); |
| 2207 | return 0; |
| 2208 | } |
| 2209 | |
| 2210 | /* Ensure it's at least the size of the header */ |
| 2211 | if (datalen < sizeof(*pe_hdr)) { |
| 2212 | WMA_LOGE("%s: Expected minimum size %zu, received %d", |
| 2213 | __func__, sizeof(*pe_hdr), datalen); |
| 2214 | return 0; |
| 2215 | } |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2216 | /* |
| 2217 | * The max buffer lenght is larger for DFS-3 than DFS-2. |
| 2218 | * So, accordingly use the correct max buffer size. |
| 2219 | */ |
| 2220 | if (wma->hw_bd_id != WMI_HWBD_QCA6174) |
| 2221 | max_dfs_buf_length = DFS3_MAX_BUF_LENGTH; |
| 2222 | else |
| 2223 | max_dfs_buf_length = DFS_MAX_BUF_LENGTH; |
| 2224 | |
| 2225 | if (pe_hdr->buf_len > max_dfs_buf_length) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2226 | WMA_LOGE("%s: Received Invalid Phyerror event buffer length = %d" |
| 2227 | "Maximum allowed buf length = %d", __func__, |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2228 | pe_hdr->buf_len, max_dfs_buf_length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2229 | |
| 2230 | return 0; |
| 2231 | } |
| 2232 | |
| 2233 | /* |
| 2234 | * Reconstruct the 64 bit event TSF. This isn't from the MAC, it's |
| 2235 | * at the time the event was sent to us, the TSF value will be |
| 2236 | * in the future. |
| 2237 | */ |
| 2238 | tsf64 = pe_hdr->tsf_l32; |
| 2239 | tsf64 |= (((uint64_t) pe_hdr->tsf_u32) << 32); |
| 2240 | |
| 2241 | /* |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2242 | * Check the HW board ID to figure out |
| 2243 | * if DFS-3 is supported. In DFS-3 |
| 2244 | * phyerror mask indicates the type of |
| 2245 | * phyerror, whereas in DFS-2 phyerrorcode |
| 2246 | * indicates the type of phyerror. If the |
| 2247 | * board is NOT WMI_HWBD_QCA6174, for now |
| 2248 | * assume that it supports DFS-3. |
| 2249 | */ |
| 2250 | if (wma->hw_bd_id != WMI_HWBD_QCA6174) { |
| 2251 | phy_err_mask = pe_hdr->rsPhyErrMask0; |
| 2252 | WMA_LOGD("%s: DFS-3 phyerror mask = 0x%x", |
| 2253 | __func__, phy_err_mask); |
| 2254 | } |
| 2255 | |
| 2256 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2257 | * Loop over the bufp, extracting out phyerrors |
| 2258 | * wmi_unified_comb_phyerr_rx_event.bufp is a char pointer, |
| 2259 | * which isn't correct here - what we have received here |
| 2260 | * is an array of TLV-style PHY errors. |
| 2261 | */ |
| 2262 | n = 0; /* Start just after the header */ |
| 2263 | bufp = param_tlvs->bufp; |
| 2264 | while (n < pe_hdr->buf_len) { |
| 2265 | /* ensure there's at least space for the header */ |
| 2266 | if ((pe_hdr->buf_len - n) < sizeof(ev->hdr)) { |
| 2267 | WMA_LOGE("%s: Not enough space.(datalen=%d, n=%zu, hdr=%zu bytes", |
| 2268 | __func__, pe_hdr->buf_len, n, sizeof(ev->hdr)); |
| 2269 | error = 1; |
| 2270 | break; |
| 2271 | } |
| 2272 | /* |
| 2273 | * Obtain a pointer to the beginning of the current event. |
| 2274 | * data[0] is the beginning of the WMI payload. |
| 2275 | */ |
| 2276 | ev = (wmi_single_phyerr_rx_event *) &bufp[n]; |
| 2277 | |
| 2278 | /* |
| 2279 | * Sanity check the buffer length of the event against |
| 2280 | * what we currently have. |
| 2281 | * Since buf_len is 32 bits, we check if it overflows |
| 2282 | * a large 32 bit value. It's not 0x7fffffff because |
| 2283 | * we increase n by (buf_len + sizeof(hdr)), which would |
| 2284 | * in itself cause n to overflow. |
| 2285 | * If "int" is 64 bits then this becomes a moot point. |
| 2286 | */ |
| 2287 | if (ev->hdr.buf_len > 0x7f000000) { |
| 2288 | WMA_LOGE("%s:buf_len is garbage (0x%x)", __func__, |
| 2289 | ev->hdr.buf_len); |
| 2290 | error = 1; |
| 2291 | break; |
| 2292 | } |
| 2293 | if (n + ev->hdr.buf_len > pe_hdr->buf_len) { |
| 2294 | WMA_LOGE("%s: buf_len exceeds available space n=%zu," |
| 2295 | "buf_len=%d, datalen=%d", |
| 2296 | __func__, n, ev->hdr.buf_len, pe_hdr->buf_len); |
| 2297 | error = 1; |
| 2298 | break; |
| 2299 | } |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2300 | /* |
| 2301 | * If the board id is WMI_HWBD_QCA6174 |
| 2302 | * then it supports only DFS-2. So, fetch |
| 2303 | * phyerror code in order to know the type |
| 2304 | * of phyerror. |
| 2305 | */ |
| 2306 | if (wma->hw_bd_id == WMI_HWBD_QCA6174) { |
| 2307 | phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr); |
| 2308 | WMA_LOGD("%s: DFS-2 phyerror code = 0x%x", |
| 2309 | __func__, phy_err_code); |
| 2310 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2311 | |
| 2312 | /* |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2313 | * phy_err_code is set for DFS-2 and phy_err_mask |
| 2314 | * is set for DFS-3. Checking both to support |
| 2315 | * compatability for older platforms. |
| 2316 | * If the phyerror or phyerrmask category matches, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2317 | * pass radar events to the dfs pattern matching code. |
| 2318 | * Don't pass radar events with no buffer payload. |
| 2319 | */ |
Rakesh Sunki | 8641f8a | 2015-12-10 15:11:19 -0800 | [diff] [blame] | 2320 | if (((phy_err_mask & WMI_PHY_ERROR_MASK0_RADAR) || |
| 2321 | (phy_err_mask & WMI_PHY_ERROR_MASK0_FALSE_RADAR_EXT)) || |
| 2322 | (phy_err_code == WMA_DFS2_PHYERROR_CODE || |
| 2323 | phy_err_code == WMA_DFS2_FALSE_RADAR_EXT)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2324 | if (ev->hdr.buf_len > 0) { |
| 2325 | /* Calling in to the DFS module to process the phyerr */ |
| 2326 | dfs_process_phyerr(ic, &ev->bufp[0], |
| 2327 | ev->hdr.buf_len, |
| 2328 | WMI_UNIFIED_RSSI_COMB_GET |
| 2329 | (&ev->hdr) & 0xff, |
| 2330 | /* Extension RSSI */ |
| 2331 | WMI_UNIFIED_RSSI_COMB_GET |
| 2332 | (&ev->hdr) & 0xff, |
| 2333 | ev->hdr.tsf_timestamp, |
| 2334 | tsf64, enable_log); |
| 2335 | } |
| 2336 | } |
| 2337 | |
| 2338 | /* |
| 2339 | * Advance the buffer pointer to the next PHY error. |
| 2340 | * buflen is the length of this payload, so we need to |
| 2341 | * advance past the current header _AND_ the payload. |
| 2342 | */ |
| 2343 | n += sizeof(*ev) + ev->hdr.buf_len; |
| 2344 | |
| 2345 | } /*end while() */ |
| 2346 | if (error) |
| 2347 | return 0; |
| 2348 | else |
| 2349 | return 1; |
| 2350 | } |
| 2351 | |
| 2352 | /** |
| 2353 | * wma_register_dfs_event_handler() - register dfs event handler |
| 2354 | * @wma_handle: wma handle |
| 2355 | * |
| 2356 | * Register appropriate dfs phyerror event handler |
| 2357 | * based on phyerror filtering offload is enabled |
| 2358 | * or disabled. |
| 2359 | * |
| 2360 | * Return: none |
| 2361 | */ |
| 2362 | void wma_register_dfs_event_handler(tp_wma_handle wma_handle) |
| 2363 | { |
| 2364 | if (NULL == wma_handle) { |
| 2365 | WMA_LOGE("%s:wma_handle is NULL", __func__); |
| 2366 | return; |
| 2367 | } |
| 2368 | |
| 2369 | if (false == wma_handle->dfs_phyerr_filter_offload) { |
| 2370 | /* |
| 2371 | * Register the wma_unified_phyerr_rx_event_handler |
| 2372 | * for filtering offload disabled case to handle |
| 2373 | * the DFS phyerrors. |
| 2374 | */ |
| 2375 | WMA_LOGD("%s:Phyerror Filtering offload is Disabled in ini", |
| 2376 | __func__); |
| 2377 | wmi_unified_register_event_handler(wma_handle->wmi_handle, |
| 2378 | WMI_PHYERR_EVENTID, |
| 2379 | wma_unified_phyerr_rx_event_handler); |
| 2380 | WMA_LOGD("%s: WMI_PHYERR_EVENTID event handler registered", |
| 2381 | __func__); |
| 2382 | } else { |
| 2383 | WMA_LOGD("%s:Phyerror Filtering offload is Enabled in ini", |
| 2384 | __func__); |
| 2385 | wmi_unified_register_event_handler(wma_handle->wmi_handle, |
| 2386 | WMI_DFS_RADAR_EVENTID, |
| 2387 | wma_unified_dfs_radar_rx_event_handler); |
| 2388 | WMA_LOGD("%s:WMI_DFS_RADAR_EVENTID event handler registered", |
| 2389 | __func__); |
| 2390 | } |
| 2391 | |
| 2392 | return; |
| 2393 | } |
| 2394 | |
| 2395 | |
| 2396 | /** |
| 2397 | * wma_unified_dfs_phyerr_filter_offload_enable() - enable dfs phyerr filter |
| 2398 | * @wma_handle: wma handle |
| 2399 | * |
| 2400 | * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or |
| 2401 | * WMI_DFS_PHYERR_FILTER_DIS_CMDID command |
| 2402 | * to firmware based on phyerr filtering |
| 2403 | * offload status. |
| 2404 | * |
| 2405 | * Return: 1 success, 0 failure |
| 2406 | */ |
| 2407 | int |
| 2408 | wma_unified_dfs_phyerr_filter_offload_enable(tp_wma_handle wma_handle) |
| 2409 | { |
| 2410 | wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd; |
| 2411 | wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd; |
| 2412 | wmi_buf_t buf; |
| 2413 | uint16_t len; |
| 2414 | int ret; |
| 2415 | |
| 2416 | if (NULL == wma_handle) { |
| 2417 | WMA_LOGE("%s:wma_handle is NULL", __func__); |
| 2418 | return 0; |
| 2419 | } |
| 2420 | |
| 2421 | if (false == wma_handle->dfs_phyerr_filter_offload) { |
| 2422 | WMA_LOGD("%s:Phyerror Filtering offload is Disabled in ini", |
| 2423 | __func__); |
| 2424 | len = sizeof(*disable_phyerr_offload_cmd); |
| 2425 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 2426 | if (!buf) { |
| 2427 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
| 2428 | return 0; |
| 2429 | } |
| 2430 | disable_phyerr_offload_cmd = |
| 2431 | (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *) |
| 2432 | wmi_buf_data(buf); |
| 2433 | |
| 2434 | WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header, |
| 2435 | WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param, |
| 2436 | WMITLV_GET_STRUCT_TLVLEN |
| 2437 | (wmi_dfs_phyerr_filter_dis_cmd_fixed_param)); |
| 2438 | |
| 2439 | /* |
| 2440 | * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID |
| 2441 | * to the firmware to disable the phyerror |
| 2442 | * filtering offload. |
| 2443 | */ |
| 2444 | ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 2445 | WMI_DFS_PHYERR_FILTER_DIS_CMDID); |
| 2446 | if (ret < 0) { |
| 2447 | WMA_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d", |
| 2448 | __func__, ret); |
| 2449 | wmi_buf_free(buf); |
| 2450 | return 0; |
| 2451 | } |
| 2452 | WMA_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success", |
| 2453 | __func__); |
| 2454 | } else { |
| 2455 | WMA_LOGD("%s:Phyerror Filtering offload is Enabled in ini", |
| 2456 | __func__); |
| 2457 | |
| 2458 | len = sizeof(*enable_phyerr_offload_cmd); |
| 2459 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 2460 | if (!buf) { |
| 2461 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
| 2462 | return 0; |
| 2463 | } |
| 2464 | |
| 2465 | enable_phyerr_offload_cmd = |
| 2466 | (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *) |
| 2467 | wmi_buf_data(buf); |
| 2468 | |
| 2469 | WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header, |
| 2470 | WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param, |
| 2471 | WMITLV_GET_STRUCT_TLVLEN |
| 2472 | (wmi_dfs_phyerr_filter_ena_cmd_fixed_param)); |
| 2473 | |
| 2474 | /* |
| 2475 | * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID |
| 2476 | * to the firmware to enable the phyerror |
| 2477 | * filtering offload. |
| 2478 | */ |
| 2479 | ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 2480 | WMI_DFS_PHYERR_FILTER_ENA_CMDID); |
| 2481 | |
| 2482 | if (ret < 0) { |
| 2483 | WMA_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_ENA_CMDID ret=%d", |
| 2484 | __func__, ret); |
| 2485 | wmi_buf_free(buf); |
| 2486 | return 0; |
| 2487 | } |
| 2488 | WMA_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success", |
| 2489 | __func__); |
| 2490 | } |
| 2491 | |
| 2492 | return 1; |
| 2493 | } |
| 2494 | |
| 2495 | #if !defined(REMOVE_PKT_LOG) |
| 2496 | /** |
| 2497 | * wma_pktlog_wmi_send_cmd() - send pktlog enable/disable command to target |
| 2498 | * @handle: wma handle |
| 2499 | * @params: pktlog params |
| 2500 | * |
| 2501 | * Return: CDF status |
| 2502 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2503 | QDF_STATUS wma_pktlog_wmi_send_cmd(WMA_HANDLE handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2504 | struct ath_pktlog_wmi_params *params) |
| 2505 | { |
| 2506 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 2507 | WMI_PKTLOG_EVENT PKTLOG_EVENT; |
| 2508 | WMI_CMD_ID CMD_ID; |
| 2509 | wmi_pdev_pktlog_enable_cmd_fixed_param *cmd; |
| 2510 | wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd; |
| 2511 | int len = 0; |
| 2512 | wmi_buf_t buf; |
| 2513 | |
| 2514 | /*Check if packet log is enabled in cfg.ini */ |
| 2515 | if (!cds_is_packet_log_enabled()) { |
| 2516 | WMA_LOGE("%s:pkt log is not enabled in cfg.ini", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2517 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2518 | } |
| 2519 | |
| 2520 | PKTLOG_EVENT = params->pktlog_event; |
| 2521 | CMD_ID = params->cmd_id; |
| 2522 | |
| 2523 | switch (CMD_ID) { |
| 2524 | case WMI_PDEV_PKTLOG_ENABLE_CMDID: |
| 2525 | len = sizeof(*cmd); |
| 2526 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 2527 | if (!buf) { |
| 2528 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2529 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2530 | } |
| 2531 | cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *) |
| 2532 | wmi_buf_data(buf); |
| 2533 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 2534 | WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param, |
| 2535 | WMITLV_GET_STRUCT_TLVLEN |
| 2536 | (wmi_pdev_pktlog_enable_cmd_fixed_param)); |
| 2537 | cmd->evlist = PKTLOG_EVENT; |
| 2538 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 2539 | WMI_PDEV_PKTLOG_ENABLE_CMDID)) { |
| 2540 | WMA_LOGE("failed to send pktlog enable cmdid"); |
| 2541 | goto wmi_send_failed; |
| 2542 | } |
| 2543 | break; |
| 2544 | case WMI_PDEV_PKTLOG_DISABLE_CMDID: |
| 2545 | len = sizeof(*disable_cmd); |
| 2546 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 2547 | if (!buf) { |
| 2548 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2549 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2550 | } |
| 2551 | disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *) |
| 2552 | wmi_buf_data(buf); |
| 2553 | WMITLV_SET_HDR(&disable_cmd->tlv_header, |
| 2554 | WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param, |
| 2555 | WMITLV_GET_STRUCT_TLVLEN |
| 2556 | (wmi_pdev_pktlog_disable_cmd_fixed_param)); |
| 2557 | disable_cmd->reserved0 = 0; |
| 2558 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 2559 | WMI_PDEV_PKTLOG_DISABLE_CMDID)) { |
| 2560 | WMA_LOGE("failed to send pktlog disable cmdid"); |
| 2561 | goto wmi_send_failed; |
| 2562 | } |
| 2563 | break; |
| 2564 | default: |
| 2565 | WMA_LOGD("%s: invalid PKTLOG command", __func__); |
| 2566 | break; |
| 2567 | } |
| 2568 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2569 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2570 | |
| 2571 | wmi_send_failed: |
| 2572 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2573 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2574 | } |
| 2575 | #endif /* REMOVE_PKT_LOG */ |
| 2576 | |
| 2577 | static void wma_send_status_to_suspend_ind(tp_wma_handle wma, bool suspended) |
| 2578 | { |
| 2579 | tSirReadyToSuspendInd *ready_to_suspend; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2580 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2581 | cds_msg_t cds_msg; |
| 2582 | uint8_t len; |
| 2583 | |
| 2584 | WMA_LOGD("Posting ready to suspend indication to umac"); |
| 2585 | |
| 2586 | len = sizeof(tSirReadyToSuspendInd); |
| 2587 | ready_to_suspend = (tSirReadyToSuspendInd *) cdf_mem_malloc(len); |
| 2588 | |
| 2589 | if (NULL == ready_to_suspend) { |
| 2590 | WMA_LOGE("%s: Memory allocation failure", __func__); |
| 2591 | return; |
| 2592 | } |
| 2593 | |
| 2594 | ready_to_suspend->mesgType = eWNI_SME_READY_TO_SUSPEND_IND; |
| 2595 | ready_to_suspend->mesgLen = len; |
| 2596 | ready_to_suspend->suspended = suspended; |
| 2597 | |
| 2598 | cds_msg.type = eWNI_SME_READY_TO_SUSPEND_IND; |
| 2599 | cds_msg.bodyptr = (void *)ready_to_suspend; |
| 2600 | cds_msg.bodyval = 0; |
| 2601 | |
| 2602 | status = cds_mq_post_message(CDS_MQ_ID_SME, &cds_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 2603 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2604 | WMA_LOGE("Failed to post ready to suspend"); |
| 2605 | cdf_mem_free(ready_to_suspend); |
| 2606 | } |
| 2607 | } |
| 2608 | |
| 2609 | /** |
| 2610 | * wma_wow_wake_reason_str() - Converts wow wakeup reason code to text format |
| 2611 | * @wake_reason - WOW wake reason |
| 2612 | * |
| 2613 | * Return: reason code in string format |
| 2614 | */ |
| 2615 | static const u8 *wma_wow_wake_reason_str(A_INT32 wake_reason) |
| 2616 | { |
| 2617 | switch (wake_reason) { |
| 2618 | case WOW_REASON_UNSPECIFIED: |
| 2619 | return "UNSPECIFIED"; |
| 2620 | case WOW_REASON_NLOD: |
| 2621 | return "NLOD"; |
| 2622 | case WOW_REASON_AP_ASSOC_LOST: |
| 2623 | return "AP_ASSOC_LOST"; |
| 2624 | case WOW_REASON_LOW_RSSI: |
| 2625 | return "LOW_RSSI"; |
| 2626 | case WOW_REASON_DEAUTH_RECVD: |
| 2627 | return "DEAUTH_RECVD"; |
| 2628 | case WOW_REASON_DISASSOC_RECVD: |
| 2629 | return "DISASSOC_RECVD"; |
| 2630 | case WOW_REASON_GTK_HS_ERR: |
| 2631 | return "GTK_HS_ERR"; |
| 2632 | case WOW_REASON_EAP_REQ: |
| 2633 | return "EAP_REQ"; |
| 2634 | case WOW_REASON_FOURWAY_HS_RECV: |
| 2635 | return "FOURWAY_HS_RECV"; |
| 2636 | case WOW_REASON_TIMER_INTR_RECV: |
| 2637 | return "TIMER_INTR_RECV"; |
| 2638 | case WOW_REASON_PATTERN_MATCH_FOUND: |
| 2639 | return "PATTERN_MATCH_FOUND"; |
| 2640 | case WOW_REASON_RECV_MAGIC_PATTERN: |
| 2641 | return "RECV_MAGIC_PATTERN"; |
| 2642 | case WOW_REASON_P2P_DISC: |
| 2643 | return "P2P_DISC"; |
| 2644 | #ifdef FEATURE_WLAN_LPHB |
| 2645 | case WOW_REASON_WLAN_HB: |
| 2646 | return "WLAN_HB"; |
| 2647 | #endif /* FEATURE_WLAN_LPHB */ |
| 2648 | |
| 2649 | case WOW_REASON_CSA_EVENT: |
| 2650 | return "CSA_EVENT"; |
| 2651 | case WOW_REASON_PROBE_REQ_WPS_IE_RECV: |
| 2652 | return "PROBE_REQ_RECV"; |
| 2653 | case WOW_REASON_AUTH_REQ_RECV: |
| 2654 | return "AUTH_REQ_RECV"; |
| 2655 | case WOW_REASON_ASSOC_REQ_RECV: |
| 2656 | return "ASSOC_REQ_RECV"; |
| 2657 | case WOW_REASON_HTT_EVENT: |
| 2658 | return "WOW_REASON_HTT_EVENT"; |
| 2659 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 2660 | case WOW_REASON_RA_MATCH: |
| 2661 | return "WOW_REASON_RA_MATCH"; |
| 2662 | #endif /* FEATURE_WLAN_RA_FILTERING */ |
| 2663 | case WOW_REASON_BEACON_RECV: |
| 2664 | return "WOW_REASON_IBSS_BEACON_RECV"; |
| 2665 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 2666 | case WOW_REASON_HOST_AUTO_SHUTDOWN: |
| 2667 | return "WOW_REASON_HOST_AUTO_SHUTDOWN"; |
| 2668 | #endif /* FEATURE_WLAN_AUTO_SHUTDOWN */ |
| 2669 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 2670 | case WOW_REASON_ROAM_HO: |
| 2671 | return "WOW_REASON_ROAM_HO"; |
| 2672 | #endif /* WLAN_FEATURE_ROAM_OFFLOAD */ |
| 2673 | #ifdef FEATURE_WLAN_EXTSCAN |
| 2674 | case WOW_REASON_EXTSCAN: |
| 2675 | return "WOW_REASON_EXTSCAN"; |
| 2676 | #endif |
| 2677 | case WOW_REASON_RSSI_BREACH_EVENT: |
| 2678 | return "WOW_REASON_RSSI_BREACH_EVENT"; |
Srinivas Girigowda | e80cea9 | 2015-11-23 11:33:57 -0800 | [diff] [blame] | 2679 | case WOW_REASON_NLO_SCAN_COMPLETE: |
| 2680 | return "WOW_REASON_NLO_SCAN_COMPLETE"; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2681 | } |
| 2682 | return "unknown"; |
| 2683 | } |
| 2684 | |
| 2685 | /** |
| 2686 | * wma_wow_wake_up_stats_display() - display wow wake up stats |
| 2687 | * @wma: Pointer to wma handle |
| 2688 | * |
| 2689 | * Return: none |
| 2690 | */ |
| 2691 | static void wma_wow_wake_up_stats_display(tp_wma_handle wma) |
| 2692 | { |
| 2693 | WMA_LOGA("uc %d bc %d v4_mc %d v6_mc %d ra %d ns %d na %d pno_match %d pno_complete %d gscan %d low_rssi %d rssi_breach %d", |
| 2694 | wma->wow_ucast_wake_up_count, |
| 2695 | wma->wow_bcast_wake_up_count, |
| 2696 | wma->wow_ipv4_mcast_wake_up_count, |
| 2697 | wma->wow_ipv6_mcast_wake_up_count, |
| 2698 | wma->wow_ipv6_mcast_ra_stats, |
| 2699 | wma->wow_ipv6_mcast_ns_stats, |
| 2700 | wma->wow_ipv6_mcast_na_stats, |
| 2701 | wma->wow_pno_match_wake_up_count, |
| 2702 | wma->wow_pno_complete_wake_up_count, |
| 2703 | wma->wow_gscan_wake_up_count, |
| 2704 | wma->wow_low_rssi_wake_up_count, |
| 2705 | wma->wow_rssi_breach_wake_up_count); |
| 2706 | |
| 2707 | return; |
| 2708 | } |
| 2709 | |
| 2710 | /** |
| 2711 | * wma_wow_ipv6_mcast_stats() - ipv6 mcast wake up stats |
| 2712 | * @wma: Pointer to wma handle |
| 2713 | * @data: Pointer to pattern match data |
| 2714 | * |
| 2715 | * Return: none |
| 2716 | */ |
| 2717 | static void wma_wow_ipv6_mcast_stats(tp_wma_handle wma, uint8_t *data) |
| 2718 | { |
| 2719 | static const uint8_t ipv6_mcast[] = {0x86, 0xDD}; |
| 2720 | |
| 2721 | if (!memcmp(ipv6_mcast, (data + WMA_ETHER_TYPE_OFFSET), |
| 2722 | sizeof(ipv6_mcast))) { |
| 2723 | if (WMA_ICMP_V6_HEADER_TYPE == |
| 2724 | *(data + WMA_ICMP_V6_HEADER_OFFSET)) { |
| 2725 | if (WMA_ICMP_V6_RA_TYPE == |
| 2726 | *(data + WMA_ICMP_V6_TYPE_OFFSET)) |
| 2727 | wma->wow_ipv6_mcast_ra_stats++; |
| 2728 | else if (WMA_ICMP_V6_NS_TYPE == |
| 2729 | *(data + WMA_ICMP_V6_TYPE_OFFSET)) |
| 2730 | wma->wow_ipv6_mcast_ns_stats++; |
| 2731 | else if (WMA_ICMP_V6_NA_TYPE == |
| 2732 | *(data + WMA_ICMP_V6_TYPE_OFFSET)) |
| 2733 | wma->wow_ipv6_mcast_na_stats++; |
| 2734 | else |
| 2735 | WMA_LOGA("ICMP V6 type : 0x%x", |
| 2736 | *(data + WMA_ICMP_V6_TYPE_OFFSET)); |
| 2737 | } else { |
| 2738 | WMA_LOGA("ICMP_V6 header 0x%x", |
| 2739 | *(data + WMA_ICMP_V6_HEADER_OFFSET)); |
| 2740 | } |
| 2741 | } else { |
| 2742 | WMA_LOGA("Ethertype x%x:0x%x", |
| 2743 | *(data + WMA_ETHER_TYPE_OFFSET), |
| 2744 | *(data + WMA_ETHER_TYPE_OFFSET + 1)); |
| 2745 | } |
| 2746 | |
| 2747 | return; |
| 2748 | } |
| 2749 | |
| 2750 | /** |
| 2751 | * wma_wow_wake_up_stats() - maintain wow pattern match wake up stats |
| 2752 | * @wma: Pointer to wma handle |
| 2753 | * @data: Pointer to pattern match data |
| 2754 | * @len: Pattern match data length |
| 2755 | * @event: Wake up event |
| 2756 | * |
| 2757 | * Return: none |
| 2758 | */ |
| 2759 | static void wma_wow_wake_up_stats(tp_wma_handle wma, uint8_t *data, |
| 2760 | int32_t len, WOW_WAKE_REASON_TYPE event) |
| 2761 | { |
| 2762 | switch (event) { |
| 2763 | |
| 2764 | case WOW_REASON_PATTERN_MATCH_FOUND: |
| 2765 | if (WMA_BCAST_MAC_ADDR == *data) { |
| 2766 | wma->wow_bcast_wake_up_count++; |
| 2767 | } else if (WMA_MCAST_IPV4_MAC_ADDR == *data) { |
| 2768 | wma->wow_ipv4_mcast_wake_up_count++; |
| 2769 | } else if (WMA_MCAST_IPV6_MAC_ADDR == *data) { |
| 2770 | wma->wow_ipv6_mcast_wake_up_count++; |
| 2771 | if (len > WMA_ICMP_V6_TYPE_OFFSET) |
| 2772 | wma_wow_ipv6_mcast_stats(wma, data); |
| 2773 | else |
| 2774 | WMA_LOGA("ICMP_V6 data len %d", len); |
| 2775 | } else { |
| 2776 | wma->wow_ucast_wake_up_count++; |
| 2777 | } |
| 2778 | break; |
| 2779 | |
| 2780 | case WOW_REASON_RA_MATCH: |
| 2781 | wma->wow_ipv6_mcast_ra_stats++; |
| 2782 | break; |
| 2783 | |
| 2784 | case WOW_REASON_NLOD: |
| 2785 | wma->wow_pno_match_wake_up_count++; |
| 2786 | break; |
| 2787 | |
| 2788 | case WOW_REASON_NLO_SCAN_COMPLETE: |
| 2789 | wma->wow_pno_complete_wake_up_count++; |
| 2790 | break; |
| 2791 | |
| 2792 | case WOW_REASON_LOW_RSSI: |
| 2793 | wma->wow_low_rssi_wake_up_count++; |
| 2794 | break; |
| 2795 | |
| 2796 | case WOW_REASON_EXTSCAN: |
| 2797 | wma->wow_gscan_wake_up_count++; |
| 2798 | break; |
| 2799 | |
| 2800 | case WOW_REASON_RSSI_BREACH_EVENT: |
| 2801 | wma->wow_rssi_breach_wake_up_count++; |
| 2802 | break; |
| 2803 | |
| 2804 | default: |
| 2805 | WMA_LOGE("Unknown wake up reason"); |
| 2806 | break; |
| 2807 | } |
| 2808 | |
| 2809 | wma_wow_wake_up_stats_display(wma); |
| 2810 | return; |
| 2811 | } |
| 2812 | |
| 2813 | /** |
| 2814 | * wma_wow_wakeup_host_event() - wakeup host event handler |
| 2815 | * @handle: wma handle |
| 2816 | * @event: event data |
| 2817 | * @len: buffer length |
| 2818 | * |
| 2819 | * Handler to catch wow wakeup host event. This event will have |
| 2820 | * reason why the firmware has woken the host. |
| 2821 | * |
| 2822 | * Return: 0 for success or error |
| 2823 | */ |
| 2824 | int wma_wow_wakeup_host_event(void *handle, uint8_t *event, |
| 2825 | uint32_t len) |
| 2826 | { |
| 2827 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 2828 | WMI_WOW_WAKEUP_HOST_EVENTID_param_tlvs *param_buf; |
| 2829 | WOW_EVENT_INFO_fixed_param *wake_info; |
| 2830 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 2831 | struct wma_txrx_node *node; |
| 2832 | #endif /* FEATURE_WLAN_SCAN_PNO */ |
| 2833 | uint32_t wake_lock_duration = 0; |
| 2834 | uint32_t wow_buf_pkt_len = 0; |
| 2835 | |
| 2836 | param_buf = (WMI_WOW_WAKEUP_HOST_EVENTID_param_tlvs *) event; |
| 2837 | if (!param_buf) { |
| 2838 | WMA_LOGE("Invalid wow wakeup host event buf"); |
| 2839 | return -EINVAL; |
| 2840 | } |
| 2841 | |
| 2842 | wake_info = param_buf->fixed_param; |
| 2843 | |
| 2844 | WMA_LOGA("WOW wakeup host event received (reason: %s(%d)) for vdev %d", |
| 2845 | wma_wow_wake_reason_str(wake_info->wake_reason), |
| 2846 | wake_info->wake_reason, wake_info->vdev_id); |
| 2847 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 2848 | qdf_event_set(&wma->wma_resume_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2849 | |
| 2850 | switch (wake_info->wake_reason) { |
| 2851 | case WOW_REASON_AUTH_REQ_RECV: |
| 2852 | wake_lock_duration = WMA_AUTH_REQ_RECV_WAKE_LOCK_TIMEOUT; |
| 2853 | break; |
| 2854 | |
| 2855 | case WOW_REASON_ASSOC_REQ_RECV: |
| 2856 | wake_lock_duration = WMA_ASSOC_REQ_RECV_WAKE_LOCK_DURATION; |
| 2857 | break; |
| 2858 | |
| 2859 | case WOW_REASON_DEAUTH_RECVD: |
| 2860 | wake_lock_duration = WMA_DEAUTH_RECV_WAKE_LOCK_DURATION; |
| 2861 | break; |
| 2862 | |
| 2863 | case WOW_REASON_DISASSOC_RECVD: |
| 2864 | wake_lock_duration = WMA_DISASSOC_RECV_WAKE_LOCK_DURATION; |
| 2865 | break; |
| 2866 | |
| 2867 | case WOW_REASON_AP_ASSOC_LOST: |
| 2868 | wake_lock_duration = WMA_BMISS_EVENT_WAKE_LOCK_DURATION; |
| 2869 | WMA_LOGA("Beacon miss indication on vdev %x", |
| 2870 | wake_info->vdev_id); |
| 2871 | wma_beacon_miss_handler(wma, wake_info->vdev_id); |
| 2872 | break; |
| 2873 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 2874 | case WOW_REASON_RA_MATCH: |
| 2875 | wma_wow_wake_up_stats(wma, NULL, 0, WOW_REASON_RA_MATCH); |
| 2876 | break; |
| 2877 | #endif /* FEATURE_WLAN_RA_FILTERING */ |
| 2878 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 2879 | case WOW_REASON_HOST_AUTO_SHUTDOWN: |
| 2880 | wake_lock_duration = WMA_AUTO_SHUTDOWN_WAKE_LOCK_DURATION; |
| 2881 | WMA_LOGA("Received WOW Auto Shutdown trigger in suspend"); |
| 2882 | if (wma_post_auto_shutdown_msg()) |
| 2883 | return -EINVAL; |
| 2884 | break; |
| 2885 | #endif /* FEATURE_WLAN_AUTO_SHUTDOWN */ |
| 2886 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 2887 | case WOW_REASON_NLOD: |
| 2888 | wma_wow_wake_up_stats(wma, NULL, 0, WOW_REASON_NLOD); |
| 2889 | node = &wma->interfaces[wake_info->vdev_id]; |
| 2890 | if (node) { |
| 2891 | WMA_LOGD("NLO match happened"); |
| 2892 | node->nlo_match_evt_received = true; |
| 2893 | cdf_wake_lock_timeout_acquire(&wma->pno_wake_lock, |
| 2894 | WMA_PNO_MATCH_WAKE_LOCK_TIMEOUT, |
| 2895 | WIFI_POWER_EVENT_WAKELOCK_PNO); |
Srinivas Girigowda | e80cea9 | 2015-11-23 11:33:57 -0800 | [diff] [blame] | 2896 | } |
| 2897 | break; |
| 2898 | |
| 2899 | case WOW_REASON_NLO_SCAN_COMPLETE: |
| 2900 | { |
| 2901 | WMI_NLO_SCAN_COMPLETE_EVENTID_param_tlvs param; |
| 2902 | |
| 2903 | WMA_LOGD("Host woken up due to pno scan complete reason"); |
| 2904 | |
| 2905 | /* First 4-bytes of wow_packet_buffer is the length */ |
| 2906 | if (param_buf->wow_packet_buffer) { |
| 2907 | param.fixed_param = (wmi_nlo_event *) |
| 2908 | (param_buf->wow_packet_buffer + 4); |
| 2909 | wma_nlo_scan_cmp_evt_handler(handle, |
| 2910 | (u_int8_t *)¶m, sizeof(param)); |
| 2911 | } else |
| 2912 | WMA_LOGD("No wow_packet_buffer present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | } |
| 2914 | break; |
| 2915 | #endif /* FEATURE_WLAN_SCAN_PNO */ |
| 2916 | |
| 2917 | case WOW_REASON_CSA_EVENT: |
| 2918 | { |
| 2919 | WMI_CSA_HANDLING_EVENTID_param_tlvs param; |
| 2920 | WMA_LOGD("Host woken up because of CSA IE"); |
| 2921 | param.fixed_param = (wmi_csa_event_fixed_param *) |
| 2922 | (((uint8_t *) wake_info) |
| 2923 | + sizeof(WOW_EVENT_INFO_fixed_param) |
| 2924 | + WOW_CSA_EVENT_OFFSET); |
| 2925 | wma_csa_offload_handler(handle, (uint8_t *) ¶m, |
| 2926 | sizeof(param)); |
| 2927 | } |
| 2928 | break; |
| 2929 | |
| 2930 | #ifdef FEATURE_WLAN_LPHB |
| 2931 | case WOW_REASON_WLAN_HB: |
| 2932 | wma_lphb_handler(wma, (uint8_t *) param_buf->hb_indevt); |
| 2933 | break; |
| 2934 | #endif /* FEATURE_WLAN_LPHB */ |
| 2935 | |
| 2936 | case WOW_REASON_HTT_EVENT: |
| 2937 | break; |
| 2938 | case WOW_REASON_PATTERN_MATCH_FOUND: |
| 2939 | wma_wow_wake_up_stats_display(wma); |
| 2940 | WMA_LOGD("Wake up for Rx packet, dump starting from ethernet hdr"); |
| 2941 | if (param_buf->wow_packet_buffer) { |
| 2942 | /* First 4-bytes of wow_packet_buffer is the length */ |
| 2943 | cdf_mem_copy((uint8_t *) &wow_buf_pkt_len, |
| 2944 | param_buf->wow_packet_buffer, 4); |
| 2945 | wma_wow_wake_up_stats(wma, |
| 2946 | param_buf->wow_packet_buffer + 4, |
| 2947 | wow_buf_pkt_len, |
| 2948 | WOW_REASON_PATTERN_MATCH_FOUND); |
| 2949 | cdf_trace_hex_dump(CDF_MODULE_ID_WMA, |
| 2950 | CDF_TRACE_LEVEL_DEBUG, |
| 2951 | param_buf->wow_packet_buffer + 4, |
| 2952 | wow_buf_pkt_len); |
| 2953 | } else { |
| 2954 | WMA_LOGE("No wow packet buffer present"); |
| 2955 | } |
| 2956 | break; |
| 2957 | |
| 2958 | case WOW_REASON_LOW_RSSI: |
| 2959 | { |
| 2960 | /* WOW_REASON_LOW_RSSI is used for all roaming events. |
| 2961 | * WMI_ROAM_REASON_BETTER_AP, WMI_ROAM_REASON_BMISS, |
| 2962 | * WMI_ROAM_REASON_SUITABLE_AP will be handled by |
| 2963 | * wma_roam_event_callback(). |
| 2964 | */ |
| 2965 | WMI_ROAM_EVENTID_param_tlvs param; |
| 2966 | wma_wow_wake_up_stats(wma, NULL, 0, WOW_REASON_LOW_RSSI); |
| 2967 | if (param_buf->wow_packet_buffer) { |
| 2968 | /* Roam event is embedded in wow_packet_buffer */ |
| 2969 | WMA_LOGD("Host woken up because of roam event"); |
| 2970 | cdf_mem_copy((uint8_t *) &wow_buf_pkt_len, |
| 2971 | param_buf->wow_packet_buffer, 4); |
| 2972 | WMA_LOGD("wow_packet_buffer dump"); |
| 2973 | cdf_trace_hex_dump(CDF_MODULE_ID_WMA, |
| 2974 | CDF_TRACE_LEVEL_DEBUG, |
| 2975 | param_buf->wow_packet_buffer, |
| 2976 | wow_buf_pkt_len); |
| 2977 | if (wow_buf_pkt_len >= sizeof(param)) { |
| 2978 | param.fixed_param = |
| 2979 | (wmi_roam_event_fixed_param *) |
| 2980 | (param_buf->wow_packet_buffer + 4); |
| 2981 | wma_roam_event_callback(handle, |
| 2982 | (uint8_t *) & |
| 2983 | param, |
| 2984 | sizeof(param)); |
| 2985 | } else { |
| 2986 | WMA_LOGE("Wrong length for roam event = %d bytes", |
| 2987 | wow_buf_pkt_len); |
| 2988 | } |
| 2989 | } else { |
| 2990 | /* No wow_packet_buffer means a better AP beacon |
| 2991 | * will follow in a later event. |
| 2992 | */ |
| 2993 | WMA_LOGD("Host woken up because of better AP beacon"); |
| 2994 | } |
| 2995 | break; |
| 2996 | } |
| 2997 | case WOW_REASON_CLIENT_KICKOUT_EVENT: |
| 2998 | { |
| 2999 | WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs param; |
| 3000 | if (param_buf->wow_packet_buffer) { |
| 3001 | /* station kickout event embedded in wow_packet_buffer */ |
| 3002 | WMA_LOGD("Host woken up because of sta_kickout event"); |
| 3003 | cdf_mem_copy((u_int8_t *) &wow_buf_pkt_len, |
| 3004 | param_buf->wow_packet_buffer, 4); |
| 3005 | WMA_LOGD("wow_packet_buffer dump"); |
| 3006 | cdf_trace_hex_dump(CDF_MODULE_ID_WMA, |
| 3007 | CDF_TRACE_LEVEL_DEBUG, |
| 3008 | param_buf->wow_packet_buffer, wow_buf_pkt_len); |
| 3009 | if (wow_buf_pkt_len >= sizeof(param)) { |
| 3010 | param.fixed_param = (wmi_peer_sta_kickout_event_fixed_param *) |
| 3011 | (param_buf->wow_packet_buffer + 4); |
| 3012 | wma_peer_sta_kickout_event_handler(handle, |
| 3013 | (u_int8_t *)¶m, sizeof(param)); |
| 3014 | } else { |
| 3015 | WMA_LOGE("Wrong length for sta_kickout event = %d bytes", |
| 3016 | wow_buf_pkt_len); |
| 3017 | } |
| 3018 | } else { |
| 3019 | WMA_LOGD("No wow_packet_buffer present"); |
| 3020 | } |
| 3021 | break; |
| 3022 | } |
| 3023 | #ifdef FEATURE_WLAN_EXTSCAN |
| 3024 | case WOW_REASON_EXTSCAN: |
| 3025 | WMA_LOGD("Host woken up because of extscan reason"); |
| 3026 | wma_wow_wake_up_stats(wma, NULL, 0, WOW_REASON_EXTSCAN); |
| 3027 | if (param_buf->wow_packet_buffer) { |
| 3028 | wow_buf_pkt_len = |
| 3029 | *(uint32_t *)param_buf->wow_packet_buffer; |
| 3030 | wma_extscan_wow_event_callback(handle, |
| 3031 | (u_int8_t *)(param_buf->wow_packet_buffer + 4), |
| 3032 | wow_buf_pkt_len); |
| 3033 | } else |
| 3034 | WMA_LOGE("wow_packet_buffer is empty"); |
| 3035 | break; |
| 3036 | #endif |
| 3037 | case WOW_REASON_RSSI_BREACH_EVENT: |
| 3038 | { |
| 3039 | WMI_RSSI_BREACH_EVENTID_param_tlvs param; |
| 3040 | |
| 3041 | wma_wow_wake_up_stats(wma, NULL, 0, |
| 3042 | WOW_REASON_RSSI_BREACH_EVENT); |
| 3043 | WMA_LOGD("Host woken up because of rssi breach reason"); |
| 3044 | /* rssi breach event is embedded in wow_packet_buffer */ |
| 3045 | if (param_buf->wow_packet_buffer) { |
| 3046 | cdf_mem_copy((u_int8_t *) &wow_buf_pkt_len, |
| 3047 | param_buf->wow_packet_buffer, 4); |
| 3048 | if (wow_buf_pkt_len >= sizeof(param)) { |
| 3049 | param.fixed_param = |
| 3050 | (wmi_rssi_breach_event_fixed_param *) |
| 3051 | (param_buf->wow_packet_buffer + 4); |
| 3052 | wma_rssi_breached_event_handler(handle, |
| 3053 | (u_int8_t *)¶m, |
| 3054 | sizeof(param)); |
| 3055 | } else { |
| 3056 | WMA_LOGE("%s: Wrong length: %d bytes", |
| 3057 | __func__, wow_buf_pkt_len); |
| 3058 | } |
| 3059 | } else |
| 3060 | WMA_LOGD("No wow_packet_buffer present"); |
| 3061 | } |
| 3062 | break; |
| 3063 | default: |
| 3064 | break; |
| 3065 | } |
| 3066 | |
| 3067 | if (wake_lock_duration) { |
| 3068 | cdf_wake_lock_timeout_acquire(&wma->wow_wake_lock, |
| 3069 | wake_lock_duration, |
| 3070 | WIFI_POWER_EVENT_WAKELOCK_WOW); |
| 3071 | WMA_LOGA("Holding %d msec wake_lock", wake_lock_duration); |
| 3072 | } |
| 3073 | |
| 3074 | return 0; |
| 3075 | } |
| 3076 | |
| 3077 | /** |
| 3078 | * wma_pdev_resume_event_handler() - PDEV resume event handler |
| 3079 | * @handle: wma handle |
| 3080 | * @event: event data |
| 3081 | * @len: buffer length |
| 3082 | * |
| 3083 | * Return: 0 for success or error |
| 3084 | */ |
| 3085 | int wma_pdev_resume_event_handler(void *handle, uint8_t *event, uint32_t len) |
| 3086 | { |
| 3087 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 3088 | |
| 3089 | WMA_LOGA("Received PDEV resume event"); |
| 3090 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3091 | qdf_event_set(&wma->wma_resume_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3092 | |
| 3093 | return 0; |
| 3094 | } |
| 3095 | /** |
| 3096 | * wma_set_wow_bus_suspend() - set suspend flag |
| 3097 | * @wma: wma handle |
| 3098 | * @val: value |
| 3099 | * |
| 3100 | * Return: none |
| 3101 | */ |
| 3102 | static inline void wma_set_wow_bus_suspend(tp_wma_handle wma, int val) |
| 3103 | { |
| 3104 | |
| 3105 | cdf_atomic_set(&wma->is_wow_bus_suspended, val); |
| 3106 | } |
| 3107 | |
| 3108 | |
| 3109 | |
| 3110 | /** |
| 3111 | * wma_add_wow_wakeup_event() - Configures wow wakeup events. |
| 3112 | * @wma: wma handle |
| 3113 | * @vdev_id: vdev id |
| 3114 | * @bitmap: Event bitmap |
| 3115 | * @enable: enable/disable |
| 3116 | * |
| 3117 | * Return: CDF status |
| 3118 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3119 | static QDF_STATUS wma_add_wow_wakeup_event(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3120 | uint32_t vdev_id, |
| 3121 | uint32_t bitmap, |
| 3122 | bool enable) |
| 3123 | { |
| 3124 | WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd; |
| 3125 | uint16_t len; |
| 3126 | wmi_buf_t buf; |
| 3127 | int ret; |
| 3128 | |
| 3129 | len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param); |
| 3130 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 3131 | if (!buf) { |
| 3132 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3133 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3134 | } |
| 3135 | cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf); |
| 3136 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 3137 | WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param, |
| 3138 | WMITLV_GET_STRUCT_TLVLEN |
| 3139 | (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param)); |
| 3140 | cmd->vdev_id = vdev_id; |
| 3141 | cmd->is_add = enable; |
| 3142 | cmd->event_bitmap = bitmap; |
| 3143 | |
| 3144 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 3145 | WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID); |
| 3146 | if (ret) { |
| 3147 | WMA_LOGE("Failed to config wow wakeup event"); |
| 3148 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3149 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | } |
| 3151 | |
| 3152 | WMA_LOGD("Wakeup pattern 0x%x %s in fw", bitmap, |
| 3153 | enable ? "enabled" : "disabled"); |
| 3154 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3155 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | } |
| 3157 | |
| 3158 | /** |
| 3159 | * wma_send_wow_patterns_to_fw() - Sends WOW patterns to FW. |
| 3160 | * @wma: wma handle |
| 3161 | * @vdev_id: vdev id |
| 3162 | * @ptrn_id: pattern id |
| 3163 | * @ptrn: pattern |
| 3164 | * @ptrn_len: pattern length |
| 3165 | * @ptrn_offset: pattern offset |
| 3166 | * @mask: mask |
| 3167 | * @mask_len: mask length |
| 3168 | * @user: true for user configured pattern and false for default pattern |
| 3169 | * |
| 3170 | * Return: CDF status |
| 3171 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3172 | static QDF_STATUS wma_send_wow_patterns_to_fw(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | uint8_t vdev_id, uint8_t ptrn_id, |
| 3174 | const uint8_t *ptrn, uint8_t ptrn_len, |
| 3175 | uint8_t ptrn_offset, const uint8_t *mask, |
| 3176 | uint8_t mask_len, bool user) |
| 3177 | { |
| 3178 | WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd; |
| 3179 | WOW_BITMAP_PATTERN_T *bitmap_pattern; |
| 3180 | struct wma_txrx_node *iface; |
| 3181 | wmi_buf_t buf; |
| 3182 | uint8_t *buf_ptr; |
| 3183 | int32_t len; |
| 3184 | int ret; |
| 3185 | |
| 3186 | iface = &wma->interfaces[vdev_id]; |
| 3187 | |
| 3188 | len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) + |
| 3189 | WMI_TLV_HDR_SIZE + |
| 3190 | 1 * sizeof(WOW_BITMAP_PATTERN_T) + |
| 3191 | WMI_TLV_HDR_SIZE + |
| 3192 | 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) + |
| 3193 | WMI_TLV_HDR_SIZE + |
| 3194 | 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) + |
| 3195 | WMI_TLV_HDR_SIZE + |
| 3196 | 0 * sizeof(WOW_MAGIC_PATTERN_CMD) + |
| 3197 | WMI_TLV_HDR_SIZE + |
| 3198 | 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32); |
| 3199 | |
| 3200 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 3201 | if (!buf) { |
| 3202 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3203 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | } |
| 3205 | |
| 3206 | cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf); |
| 3207 | buf_ptr = (uint8_t *) cmd; |
| 3208 | |
| 3209 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 3210 | WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param, |
| 3211 | WMITLV_GET_STRUCT_TLVLEN |
| 3212 | (WMI_WOW_ADD_PATTERN_CMD_fixed_param)); |
| 3213 | cmd->vdev_id = vdev_id; |
| 3214 | /* |
| 3215 | * For user configured wow pattern use pattern id sent by HDD |
| 3216 | * and for default wow patterns generate pattern id internally |
| 3217 | */ |
| 3218 | if (user) |
| 3219 | cmd->pattern_id = ptrn_id; |
| 3220 | else |
| 3221 | cmd->pattern_id = iface->num_wow_default_patterns++; |
| 3222 | |
| 3223 | cmd->pattern_type = WOW_BITMAP_PATTERN; |
| 3224 | buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param); |
| 3225 | |
| 3226 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, |
| 3227 | sizeof(WOW_BITMAP_PATTERN_T)); |
| 3228 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3229 | bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr; |
| 3230 | |
| 3231 | WMITLV_SET_HDR(&bitmap_pattern->tlv_header, |
| 3232 | WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T, |
| 3233 | WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T)); |
| 3234 | |
| 3235 | cdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len); |
| 3236 | cdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len); |
| 3237 | |
| 3238 | bitmap_pattern->pattern_offset = ptrn_offset; |
| 3239 | bitmap_pattern->pattern_len = ptrn_len; |
| 3240 | |
| 3241 | if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE) |
| 3242 | bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE; |
| 3243 | |
| 3244 | if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE) |
| 3245 | bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE; |
| 3246 | |
| 3247 | bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len; |
| 3248 | bitmap_pattern->pattern_id = ptrn_id; |
| 3249 | |
| 3250 | WMA_LOGI("vdev id : %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d", |
| 3251 | cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len, |
| 3252 | bitmap_pattern->pattern_offset, user); |
| 3253 | |
| 3254 | WMA_LOGI("Pattern : "); |
| 3255 | CDF_TRACE_HEX_DUMP(CDF_MODULE_ID_WMA, CDF_TRACE_LEVEL_INFO, |
| 3256 | &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len); |
| 3257 | |
| 3258 | WMA_LOGI("Mask : "); |
| 3259 | CDF_TRACE_HEX_DUMP(CDF_MODULE_ID_WMA, CDF_TRACE_LEVEL_INFO, |
| 3260 | &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len); |
| 3261 | |
| 3262 | buf_ptr += sizeof(WOW_BITMAP_PATTERN_T); |
| 3263 | |
| 3264 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */ |
| 3265 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 3266 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3267 | |
| 3268 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */ |
| 3269 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 3270 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3271 | |
| 3272 | /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */ |
| 3273 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0); |
| 3274 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3275 | |
| 3276 | /* Fill TLV for pattern_info_timeout but no data. */ |
| 3277 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0); |
| 3278 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3279 | |
| 3280 | /* Fill TLV for ra_ratelimit_interval with dummy data as this fix elem */ |
| 3281 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32)); |
| 3282 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 3283 | *(A_UINT32 *) buf_ptr = 0; |
| 3284 | |
| 3285 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 3286 | WMI_WOW_ADD_WAKE_PATTERN_CMDID); |
| 3287 | if (ret) { |
| 3288 | WMA_LOGE("%s: Failed to send wow ptrn to fw", __func__); |
| 3289 | wmi_buf_free(buf); |
| 3290 | if (!user) |
| 3291 | iface->num_wow_default_patterns--; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3292 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3293 | } |
| 3294 | |
| 3295 | if (user) |
| 3296 | iface->num_wow_user_patterns++; |
| 3297 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3298 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3299 | } |
| 3300 | |
| 3301 | /** |
| 3302 | * wma_wow_ap() - set WOW patterns in ap mode |
| 3303 | * @wma: wma handle |
| 3304 | * @vdev_id: vdev id |
| 3305 | * |
| 3306 | * Configures default WOW pattern for the given vdev_id which is in AP mode. |
| 3307 | * |
| 3308 | * Return: CDF status |
| 3309 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3310 | static QDF_STATUS wma_wow_ap(tp_wma_handle wma, uint8_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3311 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3312 | QDF_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | uint8_t arp_offset = 20; |
| 3314 | uint8_t mac_mask[IEEE80211_ADDR_LEN]; |
| 3315 | |
| 3316 | /* Setup unicast pkt pattern */ |
| 3317 | cdf_mem_set(&mac_mask, IEEE80211_ADDR_LEN, 0xFF); |
| 3318 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3319 | wma->interfaces[vdev_id].addr, |
| 3320 | IEEE80211_ADDR_LEN, 0, mac_mask, |
| 3321 | IEEE80211_ADDR_LEN, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3322 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | WMA_LOGE("Failed to add WOW unicast pattern ret %d", ret); |
| 3324 | return ret; |
| 3325 | } |
| 3326 | |
| 3327 | /* |
| 3328 | * Setup all ARP pkt pattern. This is dummy pattern hence the length |
| 3329 | * is zero |
| 3330 | */ |
| 3331 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3332 | arp_ptrn, 0, arp_offset, arp_mask, 0, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3333 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | WMA_LOGE("Failed to add WOW ARP pattern ret %d", ret); |
| 3335 | return ret; |
| 3336 | } |
| 3337 | |
| 3338 | return ret; |
| 3339 | } |
| 3340 | |
| 3341 | /** |
| 3342 | * wma_wow_sta() - set WOW patterns in sta mode |
| 3343 | * @wma: wma handle |
| 3344 | * @vdev_id: vdev id |
| 3345 | * |
| 3346 | * Configures default WOW pattern for the given vdev_id which is in sta mode. |
| 3347 | * |
| 3348 | * Return: CDF status |
| 3349 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3350 | static QDF_STATUS wma_wow_sta(tp_wma_handle wma, uint8_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3351 | { |
| 3352 | uint8_t arp_offset = 12; |
| 3353 | uint8_t discvr_offset = 30; |
| 3354 | uint8_t mac_mask[IEEE80211_ADDR_LEN]; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3355 | QDF_STATUS ret = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3356 | |
| 3357 | /* Setup unicast pkt pattern */ |
| 3358 | cdf_mem_set(&mac_mask, IEEE80211_ADDR_LEN, 0xFF); |
| 3359 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3360 | wma->interfaces[vdev_id].addr, |
| 3361 | IEEE80211_ADDR_LEN, 0, mac_mask, |
| 3362 | IEEE80211_ADDR_LEN, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3363 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | WMA_LOGE("Failed to add WOW unicast pattern ret %d", ret); |
| 3365 | return ret; |
| 3366 | } |
| 3367 | |
| 3368 | /* |
| 3369 | * Setup multicast pattern for mDNS 224.0.0.251, |
| 3370 | * SSDP 239.255.255.250 and LLMNR 224.0.0.252 |
| 3371 | */ |
| 3372 | if (wma->ssdp) { |
| 3373 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3374 | discvr_ptrn, sizeof(discvr_ptrn), discvr_offset, |
| 3375 | discvr_mask, sizeof(discvr_ptrn), false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3376 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3377 | WMA_LOGE("Failed to add WOW mDNS/SSDP/LLMNR pattern"); |
| 3378 | return ret; |
| 3379 | } |
| 3380 | } else |
| 3381 | WMA_LOGD("mDNS, SSDP, LLMNR patterns are disabled from ini"); |
| 3382 | |
| 3383 | /* when arp offload or ns offloaded is disabled |
| 3384 | * from ini file, configure broad cast arp pattern |
| 3385 | * to fw, so that host can wake up |
| 3386 | */ |
| 3387 | if (!(wma->ol_ini_info & 0x1)) { |
| 3388 | /* Setup all ARP pkt pattern */ |
| 3389 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3390 | arp_ptrn, sizeof(arp_ptrn), arp_offset, |
| 3391 | arp_mask, sizeof(arp_mask), false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3392 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | WMA_LOGE("Failed to add WOW ARP pattern"); |
| 3394 | return ret; |
| 3395 | } |
| 3396 | } |
| 3397 | |
| 3398 | /* for NS or NDP offload packets */ |
| 3399 | if (!(wma->ol_ini_info & 0x2)) { |
| 3400 | /* Setup all NS pkt pattern */ |
| 3401 | ret = wma_send_wow_patterns_to_fw(wma, vdev_id, 0, |
| 3402 | ns_ptrn, sizeof(arp_ptrn), arp_offset, |
| 3403 | arp_mask, sizeof(arp_mask), false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3404 | if (ret != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3405 | WMA_LOGE("Failed to add WOW NS pattern"); |
| 3406 | return ret; |
| 3407 | } |
| 3408 | } |
| 3409 | |
| 3410 | return ret; |
| 3411 | } |
| 3412 | |
| 3413 | /** |
| 3414 | * wma_register_wow_default_patterns() - register default wow patterns with fw |
| 3415 | * @handle: Pointer to wma handle |
| 3416 | * @vdev_id: vdev id |
| 3417 | * |
| 3418 | * WoW default wake up pattern rule is: |
| 3419 | * - For STA & P2P CLI mode register for same STA specific wow patterns |
| 3420 | * - For SAP/P2P GO & IBSS mode register for same SAP specific wow patterns |
| 3421 | * |
| 3422 | * Return: none |
| 3423 | */ |
| 3424 | void wma_register_wow_default_patterns(WMA_HANDLE handle, uint8_t vdev_id) |
| 3425 | { |
| 3426 | tp_wma_handle wma = handle; |
| 3427 | struct wma_txrx_node *iface; |
| 3428 | |
| 3429 | if (vdev_id > wma->max_bssid) { |
| 3430 | WMA_LOGE("Invalid vdev id %d", vdev_id); |
| 3431 | return; |
| 3432 | } |
| 3433 | iface = &wma->interfaces[vdev_id]; |
| 3434 | |
| 3435 | if (iface->ptrn_match_enable) { |
Houston Hoffman | 79b4af2 | 2015-10-06 12:01:08 -0700 | [diff] [blame] | 3436 | if (wma_is_vdev_in_beaconning_mode(wma, vdev_id)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | /* Configure SAP/GO/IBSS mode default wow patterns */ |
| 3438 | WMA_LOGI("Config SAP specific default wow patterns vdev_id %d", |
| 3439 | vdev_id); |
| 3440 | wma_wow_ap(wma, vdev_id); |
| 3441 | } else { |
| 3442 | /* Configure STA/P2P CLI mode default wow patterns */ |
| 3443 | WMA_LOGI("Config STA specific default wow patterns vdev_id %d", |
| 3444 | vdev_id); |
| 3445 | wma_wow_sta(wma, vdev_id); |
| 3446 | if (wma->IsRArateLimitEnabled) { |
| 3447 | WMA_LOGI("Config STA RA limit wow patterns vdev_id %d", |
| 3448 | vdev_id); |
| 3449 | wma_wow_sta_ra_filter(wma, vdev_id); |
| 3450 | } |
| 3451 | } |
| 3452 | } |
| 3453 | |
| 3454 | return; |
| 3455 | } |
| 3456 | |
| 3457 | /** |
| 3458 | * wma_register_wow_wakeup_events() - register vdev specific wake events with fw |
| 3459 | * @handle: Pointer to wma handle |
| 3460 | * @vdev_id: vdev Id |
| 3461 | * @vdev_type: vdev type |
| 3462 | * @vdev_subtype: vdev sub type |
| 3463 | * |
| 3464 | * WoW wake up event rule is following: |
| 3465 | * 1) STA mode and P2P CLI mode wake up events are same |
| 3466 | * 2) SAP mode and P2P GO mode wake up events are same |
| 3467 | * 3) IBSS mode wake events are same as STA mode plus WOW_BEACON_EVENT |
| 3468 | * |
| 3469 | * Return: none |
| 3470 | */ |
| 3471 | void wma_register_wow_wakeup_events(WMA_HANDLE handle, |
| 3472 | uint8_t vdev_id, |
| 3473 | uint8_t vdev_type, |
| 3474 | uint8_t vdev_subtype) |
| 3475 | { |
| 3476 | tp_wma_handle wma = handle; |
| 3477 | uint32_t event_bitmap; |
| 3478 | |
| 3479 | WMA_LOGI("vdev_type %d vdev_subtype %d vdev_id %d", vdev_type, |
| 3480 | vdev_subtype, vdev_id); |
| 3481 | |
| 3482 | if ((WMI_VDEV_TYPE_STA == vdev_type) || |
| 3483 | ((WMI_VDEV_TYPE_AP == vdev_type) && |
| 3484 | (WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == vdev_subtype))) { |
| 3485 | /* Configure STA/P2P CLI mode specific default wake up events */ |
| 3486 | event_bitmap = WMA_WOW_STA_WAKE_UP_EVENTS; |
| 3487 | WMA_LOGI("STA specific default wake up event 0x%x vdev id %d", |
| 3488 | event_bitmap, vdev_id); |
| 3489 | } else if (WMI_VDEV_TYPE_IBSS == vdev_type) { |
| 3490 | /* Configure IBSS mode specific default wake up events */ |
| 3491 | event_bitmap = (WMA_WOW_STA_WAKE_UP_EVENTS | |
| 3492 | (1 << WOW_BEACON_EVENT)); |
| 3493 | WMA_LOGI("IBSS specific default wake up event 0x%x vdev id %d", |
| 3494 | event_bitmap, vdev_id); |
| 3495 | } else if (WMI_VDEV_TYPE_AP == vdev_type) { |
| 3496 | /* Configure SAP/GO mode specific default wake up events */ |
| 3497 | event_bitmap = WMA_WOW_SAP_WAKE_UP_EVENTS; |
| 3498 | WMA_LOGI("SAP specific default wake up event 0x%x vdev id %d", |
| 3499 | event_bitmap, vdev_id); |
| 3500 | } else { |
| 3501 | WMA_LOGE("unknown type %d subtype %d", vdev_type, vdev_subtype); |
| 3502 | return; |
| 3503 | } |
| 3504 | |
| 3505 | wma_add_wow_wakeup_event(wma, vdev_id, event_bitmap, true); |
| 3506 | |
| 3507 | return; |
| 3508 | } |
| 3509 | |
| 3510 | /** |
| 3511 | * wma_enable_disable_wakeup_event() - Configures wow wakeup events |
| 3512 | * @wma: wma handle |
| 3513 | * @vdev_id: vdev id |
| 3514 | * @bitmap: Event bitmap |
| 3515 | * @enable: enable/disable |
| 3516 | * |
| 3517 | * Return: none |
| 3518 | */ |
| 3519 | void wma_enable_disable_wakeup_event(WMA_HANDLE handle, |
| 3520 | uint32_t vdev_id, |
| 3521 | uint32_t bitmap, |
| 3522 | bool enable) |
| 3523 | { |
| 3524 | tp_wma_handle wma = handle; |
| 3525 | |
| 3526 | WMA_LOGI("vdev_id %d wake up event 0x%x enable %d", |
| 3527 | vdev_id, bitmap, enable); |
| 3528 | wma_add_wow_wakeup_event(wma, vdev_id, bitmap, enable); |
| 3529 | } |
| 3530 | |
| 3531 | /** |
| 3532 | * wma_enable_wow_in_fw() - wnable wow in fw |
| 3533 | * @wma: wma handle |
| 3534 | * |
| 3535 | * Return: CDF status |
| 3536 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3537 | QDF_STATUS wma_enable_wow_in_fw(WMA_HANDLE handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | { |
| 3539 | tp_wma_handle wma = handle; |
| 3540 | wmi_wow_enable_cmd_fixed_param *cmd; |
| 3541 | wmi_buf_t buf; |
| 3542 | int32_t len; |
| 3543 | int ret; |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 3544 | struct hif_opaque_softc *scn; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3545 | int host_credits; |
| 3546 | int wmi_pending_cmds; |
| 3547 | #ifdef CONFIG_CNSS |
| 3548 | tpAniSirGlobal pMac = cds_get_context(CDF_MODULE_ID_PE); |
| 3549 | |
| 3550 | if (NULL == pMac) { |
| 3551 | WMA_LOGE("%s: Unable to get PE context", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3552 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | } |
| 3554 | #endif /* CONFIG_CNSS */ |
| 3555 | |
| 3556 | len = sizeof(wmi_wow_enable_cmd_fixed_param); |
| 3557 | |
| 3558 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 3559 | if (!buf) { |
| 3560 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3561 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | } |
| 3563 | |
| 3564 | cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf); |
| 3565 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 3566 | WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param, |
| 3567 | WMITLV_GET_STRUCT_TLVLEN |
| 3568 | (wmi_wow_enable_cmd_fixed_param)); |
| 3569 | cmd->enable = true; |
Komal Seelam | c12e675 | 2016-02-02 18:17:13 +0530 | [diff] [blame] | 3570 | if (htc_can_suspend_link(wma->htc_handle)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3571 | cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED; |
| 3572 | else |
| 3573 | cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED; |
| 3574 | |
| 3575 | WMA_LOGI("suspend type: %s", |
| 3576 | cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ? |
| 3577 | "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED"); |
| 3578 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3579 | qdf_event_reset(&wma->target_suspend); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | wma->wow_nack = 0; |
| 3581 | |
| 3582 | host_credits = wmi_get_host_credits(wma->wmi_handle); |
| 3583 | wmi_pending_cmds = wmi_get_pending_cmds(wma->wmi_handle); |
| 3584 | |
| 3585 | WMA_LOGD("Credits:%d; Pending_Cmds: %d", |
| 3586 | host_credits, wmi_pending_cmds); |
| 3587 | |
| 3588 | if (host_credits < WMI_WOW_REQUIRED_CREDITS) { |
| 3589 | WMA_LOGE("%s: Host Doesn't have enough credits to Post WMI_WOW_ENABLE_CMDID! " |
| 3590 | "Credits:%d, pending_cmds:%d\n", __func__, host_credits, |
| 3591 | wmi_pending_cmds); |
| 3592 | #ifndef QCA_WIFI_3_0_EMU |
| 3593 | goto error; |
| 3594 | #endif |
| 3595 | } |
| 3596 | |
| 3597 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 3598 | WMI_WOW_ENABLE_CMDID); |
| 3599 | if (ret) { |
| 3600 | WMA_LOGE("Failed to enable wow in fw"); |
| 3601 | goto error; |
| 3602 | } |
| 3603 | |
| 3604 | wmi_set_target_suspend(wma->wmi_handle, true); |
| 3605 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3606 | if (qdf_wait_single_event(&wma->target_suspend, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | WMA_TGT_SUSPEND_COMPLETE_TIMEOUT) |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3608 | != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3609 | WMA_LOGE("Failed to receive WoW Enable Ack from FW"); |
| 3610 | WMA_LOGE("Credits:%d; Pending_Cmds: %d", |
| 3611 | wmi_get_host_credits(wma->wmi_handle), |
| 3612 | wmi_get_pending_cmds(wma->wmi_handle)); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 3613 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | #ifdef CONFIG_CNSS |
Yue Ma | 455aff6 | 2015-10-20 18:29:16 -0700 | [diff] [blame] | 3615 | if (pMac->sme.enableSelfRecovery) { |
| 3616 | cds_trigger_recovery(); |
| 3617 | } else { |
| 3618 | CDF_BUG(0); |
| 3619 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | #else |
Yue Ma | 455aff6 | 2015-10-20 18:29:16 -0700 | [diff] [blame] | 3621 | CDF_BUG(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | #endif /* CONFIG_CNSS */ |
Yue Ma | 455aff6 | 2015-10-20 18:29:16 -0700 | [diff] [blame] | 3623 | } else { |
| 3624 | WMA_LOGE("%s: LOGP is in progress, ignore!", __func__); |
| 3625 | } |
| 3626 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3627 | wmi_set_target_suspend(wma->wmi_handle, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3628 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3629 | } |
| 3630 | |
| 3631 | if (wma->wow_nack) { |
| 3632 | WMA_LOGE("FW not ready to WOW"); |
| 3633 | wmi_set_target_suspend(wma->wmi_handle, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3634 | return QDF_STATUS_E_AGAIN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | } |
| 3636 | |
| 3637 | host_credits = wmi_get_host_credits(wma->wmi_handle); |
| 3638 | wmi_pending_cmds = wmi_get_pending_cmds(wma->wmi_handle); |
| 3639 | |
| 3640 | if (host_credits < WMI_WOW_REQUIRED_CREDITS) { |
| 3641 | WMA_LOGE("%s: No Credits after HTC ACK:%d, pending_cmds:%d, " |
| 3642 | "cannot resume back", __func__, host_credits, |
| 3643 | wmi_pending_cmds); |
| 3644 | htc_dump_counter_info(wma->htc_handle); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 3645 | if (!cds_is_driver_recovering()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3646 | CDF_BUG(0); |
| 3647 | else |
| 3648 | WMA_LOGE("%s: SSR in progress, ignore no credit issue", |
| 3649 | __func__); |
| 3650 | } |
| 3651 | |
| 3652 | WMA_LOGD("WOW enabled successfully in fw: credits:%d" |
| 3653 | "pending_cmds: %d", host_credits, wmi_pending_cmds); |
| 3654 | |
| 3655 | scn = cds_get_context(CDF_MODULE_ID_HIF); |
| 3656 | |
| 3657 | if (scn == NULL) { |
| 3658 | WMA_LOGE("%s: Failed to get HIF context", __func__); |
| 3659 | CDF_ASSERT(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3660 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3661 | } |
| 3662 | |
| 3663 | htc_cancel_deferred_target_sleep(scn); |
| 3664 | |
| 3665 | wma->wow.wow_enable_cmd_sent = true; |
| 3666 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3667 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3668 | |
| 3669 | error: |
| 3670 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3671 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | /** |
| 3675 | * wma_resume_req() - clear configured wow patterns in fw |
| 3676 | * @wma: wma handle |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 3677 | * @type: type of suspend |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3678 | * |
| 3679 | * Return: CDF status |
| 3680 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3681 | QDF_STATUS wma_resume_req(tp_wma_handle wma, enum cdf_suspend_type type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | { |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 3683 | if (type == CDF_SYSTEM_SUSPEND) { |
| 3684 | wma->no_of_resume_ind++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 3686 | if (wma->no_of_resume_ind < wma_get_vdev_count(wma)) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3687 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 3689 | wma->no_of_resume_ind = 0; |
| 3690 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | |
| 3692 | /* Reset the DTIM Parameters */ |
| 3693 | wma_set_resume_dtim(wma); |
| 3694 | /* need to reset if hif_pci_suspend_fails */ |
| 3695 | wma_set_wow_bus_suspend(wma, 0); |
| 3696 | /* unpause the vdev if left paused and hif_pci_suspend fails */ |
| 3697 | wma_unpause_vdev(wma); |
| 3698 | |
Houston Hoffman | 1460fa3 | 2015-11-18 02:36:30 -0800 | [diff] [blame] | 3699 | wmi_set_runtime_pm_inprogress(wma->wmi_handle, false); |
| 3700 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3701 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | /** |
| 3705 | * wma_wow_delete_pattern() - delete wow pattern in target |
| 3706 | * @wma: wma handle |
| 3707 | * @ptrn_id: pattern id |
| 3708 | * @vdev_id: vdev id |
| 3709 | * @user: true for user pattern and false for default pattern |
| 3710 | * |
| 3711 | * Return: CDF status |
| 3712 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3713 | static QDF_STATUS wma_wow_delete_pattern(tp_wma_handle wma, uint8_t ptrn_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3714 | uint8_t vdev_id, bool user) |
| 3715 | { |
| 3716 | WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd; |
| 3717 | struct wma_txrx_node *iface; |
| 3718 | wmi_buf_t buf; |
| 3719 | int32_t len; |
| 3720 | int ret; |
| 3721 | |
| 3722 | len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param); |
| 3723 | |
| 3724 | iface = &wma->interfaces[vdev_id]; |
| 3725 | |
| 3726 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 3727 | if (!buf) { |
| 3728 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3729 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3730 | } |
| 3731 | |
| 3732 | cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf); |
| 3733 | |
| 3734 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 3735 | WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param, |
| 3736 | WMITLV_GET_STRUCT_TLVLEN( |
| 3737 | WMI_WOW_DEL_PATTERN_CMD_fixed_param)); |
| 3738 | cmd->vdev_id = vdev_id; |
| 3739 | cmd->pattern_id = ptrn_id; |
| 3740 | cmd->pattern_type = WOW_BITMAP_PATTERN; |
| 3741 | |
| 3742 | WMA_LOGI("Deleting pattern id: %d vdev id %d in fw", |
| 3743 | cmd->pattern_id, vdev_id); |
| 3744 | |
| 3745 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 3746 | WMI_WOW_DEL_WAKE_PATTERN_CMDID); |
| 3747 | if (ret) { |
| 3748 | WMA_LOGE("%s: Failed to delete wow ptrn from fw", __func__); |
| 3749 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3750 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | } |
| 3752 | |
| 3753 | if (user) |
| 3754 | iface->num_wow_user_patterns--; |
| 3755 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3756 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3757 | } |
| 3758 | |
| 3759 | /** |
| 3760 | * wma_wow_add_pattern() - add wow pattern in target |
| 3761 | * @wma: wma handle |
| 3762 | * @ptrn: wow pattern |
| 3763 | * |
| 3764 | * This function does following: |
| 3765 | * 1) Delete all default patterns of the vdev |
| 3766 | * 2) Add received wow patterns for given vdev in target. |
| 3767 | * |
| 3768 | * Target is responsible for caching wow patterns accross multiple |
| 3769 | * suspend/resumes until the pattern is deleted by user |
| 3770 | * |
| 3771 | * Return: CDF status |
| 3772 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3773 | QDF_STATUS wma_wow_add_pattern(tp_wma_handle wma, struct wow_add_pattern *ptrn) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3774 | { |
| 3775 | uint8_t id; |
| 3776 | uint8_t bit_to_check, pos; |
| 3777 | struct wma_txrx_node *iface; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3778 | QDF_STATUS ret = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3779 | uint8_t new_mask[SIR_WOWL_BCAST_PATTERN_MAX_SIZE]; |
| 3780 | |
| 3781 | if (ptrn->session_id > wma->max_bssid) { |
| 3782 | WMA_LOGE("Invalid vdev id (%d)", ptrn->session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3783 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | } |
| 3785 | |
| 3786 | iface = &wma->interfaces[ptrn->session_id]; |
| 3787 | |
| 3788 | /* clear all default patterns cofigured by wma */ |
| 3789 | for (id = 0; id < iface->num_wow_default_patterns; id++) |
| 3790 | wma_wow_delete_pattern(wma, id, ptrn->session_id, false); |
| 3791 | |
| 3792 | iface->num_wow_default_patterns = 0; |
| 3793 | |
| 3794 | WMA_LOGI("Add user passed wow pattern id %d vdev id %d", |
| 3795 | ptrn->pattern_id, ptrn->session_id); |
| 3796 | /* |
| 3797 | * Convert received pattern mask value from bit representation |
| 3798 | * to byte representation. |
| 3799 | * |
| 3800 | * For example, received value from umac, |
| 3801 | * |
| 3802 | * Mask value : A1 (equivalent binary is "1010 0001") |
| 3803 | * Pattern value : 12:00:13:00:00:00:00:44 |
| 3804 | * |
| 3805 | * The value which goes to FW after the conversion from this |
| 3806 | * function (1 in mask value will become FF and 0 will |
| 3807 | * become 00), |
| 3808 | * |
| 3809 | * Mask value : FF:00:FF:00:0:00:00:FF |
| 3810 | * Pattern value : 12:00:13:00:00:00:00:44 |
| 3811 | */ |
| 3812 | cdf_mem_zero(new_mask, sizeof(new_mask)); |
| 3813 | for (pos = 0; pos < ptrn->pattern_size; pos++) { |
| 3814 | bit_to_check = (WMA_NUM_BITS_IN_BYTE - 1) - |
| 3815 | (pos % WMA_NUM_BITS_IN_BYTE); |
| 3816 | bit_to_check = 0x1 << bit_to_check; |
| 3817 | if (ptrn->pattern_mask[pos / WMA_NUM_BITS_IN_BYTE] & |
| 3818 | bit_to_check) |
| 3819 | new_mask[pos] = WMA_WOW_PTRN_MASK_VALID; |
| 3820 | } |
| 3821 | |
| 3822 | ret = wma_send_wow_patterns_to_fw(wma, ptrn->session_id, |
| 3823 | ptrn->pattern_id, |
| 3824 | ptrn->pattern, ptrn->pattern_size, |
| 3825 | ptrn->pattern_byte_offset, new_mask, |
| 3826 | ptrn->pattern_size, true); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3827 | if (ret != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3828 | WMA_LOGE("Failed to add wow pattern %d", ptrn->pattern_id); |
| 3829 | |
| 3830 | return ret; |
| 3831 | } |
| 3832 | |
| 3833 | /** |
| 3834 | * wma_wow_delete_user_pattern() - delete user configured wow pattern in target |
| 3835 | * @wma: wma handle |
| 3836 | * @ptrn: wow pattern |
| 3837 | * |
| 3838 | * This function does following: |
| 3839 | * 1) Deletes a particular user configured wow pattern in target |
| 3840 | * 2) After deleting all user wow patterns add default wow patterns |
| 3841 | * specific to that vdev. |
| 3842 | * |
| 3843 | * Return: CDF status |
| 3844 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3845 | QDF_STATUS wma_wow_delete_user_pattern(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3846 | struct wow_delete_pattern *pattern) |
| 3847 | { |
| 3848 | struct wma_txrx_node *iface; |
| 3849 | |
| 3850 | if (pattern->session_id > wma->max_bssid) { |
| 3851 | WMA_LOGE("Invalid vdev id %d", pattern->session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3852 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | } |
| 3854 | |
| 3855 | iface = &wma->interfaces[pattern->session_id]; |
| 3856 | if (iface->num_wow_user_patterns <= 0) { |
| 3857 | WMA_LOGE("No valid user pattern. Num user pattern %u vdev %d", |
| 3858 | iface->num_wow_user_patterns, pattern->session_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3859 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3860 | } |
| 3861 | |
| 3862 | WMA_LOGI("Delete user passed wow pattern id %d total user pattern %d", |
| 3863 | pattern->pattern_id, iface->num_wow_user_patterns); |
| 3864 | |
| 3865 | wma_wow_delete_pattern(wma, pattern->pattern_id, |
| 3866 | pattern->session_id, true); |
| 3867 | |
| 3868 | /* configure default patterns once all user patterns are deleted */ |
| 3869 | if (!iface->num_wow_user_patterns) |
| 3870 | wma_register_wow_default_patterns(wma, pattern->session_id); |
| 3871 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3872 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3873 | } |
| 3874 | |
| 3875 | /** |
| 3876 | * wma_wow_enter() - store enable/disable status for pattern |
| 3877 | * @wma: wma handle |
| 3878 | * @info: wow parameters |
| 3879 | * |
| 3880 | * Records pattern enable/disable status locally. This choice will |
| 3881 | * take effect when the driver enter into suspend state. |
| 3882 | * |
| 3883 | * Return: CDF status |
| 3884 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3885 | QDF_STATUS wma_wow_enter(tp_wma_handle wma, tpSirHalWowlEnterParams info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | { |
| 3887 | struct wma_txrx_node *iface; |
| 3888 | |
| 3889 | WMA_LOGD("wow enable req received for vdev id: %d", info->sessionId); |
| 3890 | |
| 3891 | if (info->sessionId > wma->max_bssid) { |
| 3892 | WMA_LOGE("Invalid vdev id (%d)", info->sessionId); |
| 3893 | cdf_mem_free(info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3894 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3895 | } |
| 3896 | |
| 3897 | iface = &wma->interfaces[info->sessionId]; |
| 3898 | iface->ptrn_match_enable = info->ucPatternFilteringEnable ? |
| 3899 | true : false; |
| 3900 | wma->wow.magic_ptrn_enable = info->ucMagicPktEnable ? true : false; |
| 3901 | wma->wow.deauth_enable = info->ucWowDeauthRcv ? true : false; |
| 3902 | wma->wow.disassoc_enable = info->ucWowDeauthRcv ? true : false; |
| 3903 | wma->wow.bmiss_enable = info->ucWowMaxMissedBeacons ? true : false; |
| 3904 | |
| 3905 | cdf_mem_free(info); |
| 3906 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3907 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3908 | } |
| 3909 | |
| 3910 | /** |
| 3911 | * wma_wow_exit() - clear all wma states |
| 3912 | * @wma: wma handle |
| 3913 | * @info: wow params |
| 3914 | * |
| 3915 | * Return: CDF status |
| 3916 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3917 | QDF_STATUS wma_wow_exit(tp_wma_handle wma, tpSirHalWowlExitParams info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3918 | { |
| 3919 | struct wma_txrx_node *iface; |
| 3920 | |
| 3921 | WMA_LOGD("wow disable req received for vdev id: %d", info->sessionId); |
| 3922 | |
| 3923 | if (info->sessionId > wma->max_bssid) { |
| 3924 | WMA_LOGE("Invalid vdev id (%d)", info->sessionId); |
| 3925 | cdf_mem_free(info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3926 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3927 | } |
| 3928 | |
| 3929 | iface = &wma->interfaces[info->sessionId]; |
| 3930 | iface->ptrn_match_enable = false; |
| 3931 | wma->wow.magic_ptrn_enable = false; |
| 3932 | cdf_mem_free(info); |
| 3933 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 3934 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3935 | } |
| 3936 | |
| 3937 | /** |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 3938 | * wma_calculate_and_update_conn_state(): calculate each interfaces conn state |
| 3939 | * @wma: validated wma handle |
| 3940 | * |
| 3941 | * Identifies any vdev that is up and not in ap mode as connected. |
| 3942 | * stores this in the interfaces conn_state varible. |
| 3943 | */ |
| 3944 | void wma_calculate_and_update_conn_state(tp_wma_handle wma) |
| 3945 | { |
| 3946 | int i; |
| 3947 | for (i = 0; i < wma->max_bssid; i++) { |
| 3948 | wma->interfaces[i].conn_state = |
| 3949 | !!(wma->interfaces[i].vdev_up && |
| 3950 | !wma_is_vdev_in_ap_mode(wma, i)); |
| 3951 | } |
| 3952 | } |
| 3953 | |
| 3954 | /** |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3955 | * wma_update_conn_state(): synchronize wma & hdd |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3956 | * @wma: wma handle |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3957 | * @conn_state: boolean array to populate |
| 3958 | * @len: validation parameter |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | * |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3960 | * populate interfaces conn_state with true if the interface |
| 3961 | * is a connected client and wow will configure a pattern. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3962 | */ |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3963 | void wma_update_conn_state(tp_wma_handle wma, uint32_t conn_mask) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3964 | { |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3965 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3966 | for (i = 0; i < wma->max_bssid; i++) { |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3967 | if (conn_mask & (1 << i)) |
| 3968 | wma->interfaces[i].conn_state = true; |
| 3969 | else |
| 3970 | wma->interfaces[i].conn_state = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3971 | } |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3972 | |
| 3973 | if (wma->wow.magic_ptrn_enable) |
| 3974 | return; |
| 3975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3976 | for (i = 0; i < wma->max_bssid; i++) { |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 3977 | if (!wma->interfaces[i].ptrn_match_enable) |
| 3978 | wma->interfaces[i].conn_state = false; |
| 3979 | } |
| 3980 | } |
| 3981 | |
| 3982 | /** |
| 3983 | * wma_is_beaconning_vdev_up(): check if a beaconning vdev is up |
| 3984 | * @wma: wma handle |
| 3985 | * |
| 3986 | * Return TRUE if beaconning vdev is up |
| 3987 | */ |
| 3988 | static inline |
| 3989 | bool wma_is_beaconning_vdev_up(tp_wma_handle wma) |
| 3990 | { |
| 3991 | int i; |
| 3992 | for (i = 0; i < wma->max_bssid; i++) { |
| 3993 | if (wma_is_vdev_in_beaconning_mode(wma, i) |
| 3994 | && wma->interfaces[i].vdev_up) |
| 3995 | return true; |
| 3996 | } |
| 3997 | return false; |
| 3998 | } |
| 3999 | |
| 4000 | /** |
| 4001 | * wma_support_wow_for_beaconing: wow query for beaconning |
| 4002 | * @wma: wma handle |
| 4003 | * |
| 4004 | * Need to configure wow to enable beaconning offload when |
| 4005 | * a beaconing vdev is up and beaonning offload is configured. |
| 4006 | * |
| 4007 | * Return: true if we need to enable wow for beaconning offload |
| 4008 | */ |
| 4009 | static inline |
| 4010 | bool wma_support_wow_for_beaconing(tp_wma_handle wma) |
| 4011 | { |
| 4012 | if (WMI_SERVICE_IS_ENABLED(wma->wmi_service_bitmap, |
| 4013 | WMI_SERVICE_BEACON_OFFLOAD)) { |
| 4014 | if (wma_is_beaconning_vdev_up(wma)) |
| 4015 | return true; |
| 4016 | } |
| 4017 | return false; |
| 4018 | } |
| 4019 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4020 | #ifdef FEATURE_WLAN_SCAN_PNO |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4021 | /** |
| 4022 | * wma_is_pnoscan_in_progress(): check if a pnoscan is in progress |
| 4023 | * @wma: wma handle |
| 4024 | * @vdev_id: vdev_id |
| 4025 | * |
| 4026 | * Return: TRUE/FALSE |
| 4027 | */ |
| 4028 | static inline |
| 4029 | bool wma_is_pnoscan_in_progress(tp_wma_handle wma, int vdev_id) |
| 4030 | { |
| 4031 | return wma->interfaces[vdev_id].pno_in_progress; |
| 4032 | } |
Houston Hoffman | 345fa40 | 2015-12-16 11:28:51 -0800 | [diff] [blame] | 4033 | |
| 4034 | /** |
| 4035 | * wma_is_pnoscan_match_found(): check if a scan match was found |
| 4036 | * @wma: wma handle |
| 4037 | * @vdev_id: vdev_id |
| 4038 | * |
| 4039 | * Return: TRUE/FALSE |
| 4040 | */ |
| 4041 | static inline |
| 4042 | bool wma_is_pnoscan_match_found(tp_wma_handle wma, int vdev_id) |
| 4043 | { |
| 4044 | return wma->interfaces[vdev_id].nlo_match_evt_received; |
| 4045 | } |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4046 | #else |
| 4047 | /** |
| 4048 | * wma_is_pnoscan_in_progress(): dummy |
| 4049 | * |
Houston Hoffman | 345fa40 | 2015-12-16 11:28:51 -0800 | [diff] [blame] | 4050 | * Return: False since no pnoscan cannot be in progress |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4051 | * when feature flag is not defined. |
| 4052 | */ |
| 4053 | bool wma_is_pnoscan_in_progress(tp_wma_handle wma, int vdev_id) |
| 4054 | { |
| 4055 | return FALSE; |
| 4056 | } |
Houston Hoffman | 345fa40 | 2015-12-16 11:28:51 -0800 | [diff] [blame] | 4057 | |
| 4058 | /** |
| 4059 | * wma_is_pnoscan_match_found(): dummy |
| 4060 | * @wma: wma handle |
| 4061 | * @vdev_id: vdev_id |
| 4062 | * |
| 4063 | * Return: False since no pnoscan cannot occur |
| 4064 | * when feature flag is not defined. |
| 4065 | */ |
| 4066 | static inline |
| 4067 | bool wma_is_pnoscan_match_found(tp_wma_handle wma, int vdev_id) |
| 4068 | { |
| 4069 | return FALSE; |
| 4070 | } |
Houston Hoffman | 6166796 | 2015-12-15 20:15:41 -0800 | [diff] [blame] | 4071 | #endif |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4072 | |
| 4073 | #ifdef FEATURE_WLAN_EXTSCAN |
| 4074 | static inline |
| 4075 | /** |
| 4076 | * wma_is_extscan_in_progress(): check if an extscan is in progress |
| 4077 | * @wma: wma handle |
| 4078 | * @vdev_id: vdev_id |
| 4079 | * |
| 4080 | * Return: TRUE/FALSvE |
| 4081 | */ |
| 4082 | bool wma_is_extscan_in_progress(tp_wma_handle wma, int vdev_id) |
| 4083 | { |
| 4084 | return wma->interfaces[vdev_id].extscan_in_progress; |
| 4085 | } |
| 4086 | #else |
| 4087 | /** |
| 4088 | * wma_is_extscan_in_progress(): dummy |
| 4089 | * |
| 4090 | * Return: False since no extscan can be in progress |
| 4091 | * when feature flag is not defined. |
| 4092 | */ |
| 4093 | bool wma_is_extscan_in_progress(tp_wma_handle wma, int vdev_id) |
| 4094 | { |
| 4095 | return false; |
| 4096 | } |
| 4097 | #endif |
| 4098 | |
| 4099 | /** |
| 4100 | * wma_is_wow_applicable(): should enable wow |
| 4101 | * @wma: wma handle |
| 4102 | * |
| 4103 | * Enable WOW if any one of the condition meets, |
| 4104 | * 1) Is any one of vdev in beaconning mode (in AP mode) ? |
| 4105 | * 2) Is any one of vdev in connected state (in STA mode) ? |
| 4106 | * 3) Is PNO in progress in any one of vdev ? |
| 4107 | * 4) Is Extscan in progress in any one of vdev ? |
| 4108 | * |
| 4109 | * Return: true if wma needs to configure wow. |
| 4110 | */ |
| 4111 | bool wma_is_wow_applicable(tp_wma_handle wma) |
| 4112 | { |
| 4113 | int vdev_id; |
| 4114 | if (wma_support_wow_for_beaconing(wma)) { |
| 4115 | WMA_LOGD("vdev is in beaconning mode, enabling wow"); |
| 4116 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4117 | } |
| 4118 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4119 | for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) { |
| 4120 | if (wma->interfaces[vdev_id].conn_state) { |
| 4121 | WMA_LOGD("STA is connected, enabling wow"); |
| 4122 | return true; |
| 4123 | } else if (wma_is_pnoscan_in_progress(wma, vdev_id)) { |
| 4124 | WMA_LOGD("PNO is in progress, enabling wow"); |
| 4125 | return true; |
| 4126 | } else if (wma_is_extscan_in_progress(wma, vdev_id)) { |
| 4127 | WMA_LOGD("EXT is in progress, enabling wow"); |
| 4128 | return true; |
| 4129 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4130 | } |
| 4131 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4132 | WMA_LOGD("All vdev are in disconnected state and pno/extscan is not in progress, skipping wow"); |
| 4133 | return true; |
| 4134 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | |
Houston Hoffman | 345fa40 | 2015-12-16 11:28:51 -0800 | [diff] [blame] | 4136 | /** |
| 4137 | * wma_configure_dynamic_wake_events(): configure dyanmic wake events |
| 4138 | * @wma: wma handle |
| 4139 | * |
| 4140 | * Some wake events need to be enabled dynamically. Controll those here. |
| 4141 | * |
| 4142 | * Return: none |
| 4143 | */ |
| 4144 | void wma_configure_dynamic_wake_events(tp_wma_handle wma) |
| 4145 | { |
| 4146 | int vdev_id; |
| 4147 | int enable_mask; |
| 4148 | int disable_mask; |
| 4149 | |
| 4150 | for (vdev_id = 0; vdev_id < wma->max_bssid; vdev_id++) { |
| 4151 | enable_mask = 0; |
| 4152 | disable_mask = 0; |
| 4153 | |
| 4154 | if (wma_is_pnoscan_in_progress(wma, vdev_id)) { |
| 4155 | if (wma_is_pnoscan_match_found(wma, vdev_id)) |
| 4156 | enable_mask |= |
| 4157 | (1 << WOW_NLO_SCAN_COMPLETE_EVENT); |
| 4158 | else |
| 4159 | disable_mask |= |
| 4160 | (1 << WOW_NLO_SCAN_COMPLETE_EVENT); |
| 4161 | } |
| 4162 | |
| 4163 | if (enable_mask != 0) |
| 4164 | wma_enable_disable_wakeup_event(wma, vdev_id, |
| 4165 | enable_mask, true); |
| 4166 | if (disable_mask != 0) |
| 4167 | wma_enable_disable_wakeup_event(wma, vdev_id, |
| 4168 | disable_mask, false); |
| 4169 | } |
| 4170 | } |
| 4171 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4172 | #ifdef FEATURE_WLAN_LPHB |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4173 | /** |
| 4174 | * wma_apply_lphb(): apply cached LPHB settings |
| 4175 | * @wma: wma handle |
| 4176 | * |
| 4177 | * LPHB cache, if any item was enabled, should be |
| 4178 | * applied. |
| 4179 | */ |
| 4180 | static inline |
| 4181 | void wma_apply_lphb(tp_wma_handle wma) |
| 4182 | { |
| 4183 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4184 | WMA_LOGD("%s: checking LPHB cache", __func__); |
| 4185 | for (i = 0; i < 2; i++) { |
| 4186 | if (wma->wow.lphb_cache[i].params.lphbEnableReq.enable) { |
| 4187 | WMA_LOGD("%s: LPHB cache for item %d is marked as enable", |
| 4188 | __func__, i + 1); |
| 4189 | wma_lphb_conf_hbenable(wma, &(wma->wow.lphb_cache[i]), |
| 4190 | false); |
| 4191 | } |
| 4192 | } |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4193 | } |
| 4194 | #else |
| 4195 | void wma_apply_lphb(tp_wma_handle wma) {} |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4196 | #endif /* FEATURE_WLAN_LPHB */ |
| 4197 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 4198 | static void wma_notify_suspend_req_procesed(tp_wma_handle wma, |
| 4199 | enum cdf_suspend_type type) |
| 4200 | { |
| 4201 | if (type == CDF_SYSTEM_SUSPEND) |
| 4202 | wma_send_status_to_suspend_ind(wma, true); |
| 4203 | else if (type == CDF_RUNTIME_SUSPEND) |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4204 | qdf_event_set(&wma->runtime_suspend); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 4205 | } |
| 4206 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4207 | /** |
| 4208 | * wma_suspend_req() - Handles suspend indication request received from umac. |
| 4209 | * @wma: wma handle |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 4210 | * @type: type of suspend |
| 4211 | * |
| 4212 | * The type controlls how we notify the indicator that the indication has |
| 4213 | * been processed |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4214 | * |
| 4215 | * Return: CDF status |
| 4216 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4217 | QDF_STATUS wma_suspend_req(tp_wma_handle wma, enum cdf_suspend_type type) |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4218 | { |
Houston Hoffman | 1460fa3 | 2015-11-18 02:36:30 -0800 | [diff] [blame] | 4219 | if (type == CDF_RUNTIME_SUSPEND) |
| 4220 | wmi_set_runtime_pm_inprogress(wma->wmi_handle, true); |
| 4221 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4222 | if (wma_is_wow_applicable(wma)) { |
| 4223 | WMA_LOGE("WOW Suspend"); |
| 4224 | wma_apply_lphb(wma); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4225 | |
Houston Hoffman | 345fa40 | 2015-12-16 11:28:51 -0800 | [diff] [blame] | 4226 | wma_configure_dynamic_wake_events(wma); |
| 4227 | |
Houston Hoffman | 7260ecb | 2015-10-05 18:43:07 -0700 | [diff] [blame] | 4228 | wma->wow.wow_enable = true; |
| 4229 | wma->wow.wow_enable_cmd_sent = false; |
| 4230 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | /* Set the Suspend DTIM Parameters */ |
| 4233 | wma_set_suspend_dtim(wma); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 4234 | |
| 4235 | wma_notify_suspend_req_procesed(wma, type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4236 | |
| 4237 | /* to handle race between hif_pci_suspend and |
| 4238 | * unpause/pause tx handler |
| 4239 | */ |
| 4240 | wma_set_wow_bus_suspend(wma, 1); |
| 4241 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4242 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4243 | } |
| 4244 | |
| 4245 | /** |
| 4246 | * wma_send_host_wakeup_ind_to_fw() - send wakeup ind to fw |
| 4247 | * @wma: wma handle |
| 4248 | * |
| 4249 | * Sends host wakeup indication to FW. On receiving this indication, |
| 4250 | * FW will come out of WOW. |
| 4251 | * |
| 4252 | * Return: CDF status |
| 4253 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4254 | static QDF_STATUS wma_send_host_wakeup_ind_to_fw(tp_wma_handle wma) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4255 | { |
| 4256 | wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd; |
| 4257 | wmi_buf_t buf; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4258 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | int32_t len; |
| 4260 | int ret; |
| 4261 | #ifdef CONFIG_CNSS |
| 4262 | tpAniSirGlobal pMac = cds_get_context(CDF_MODULE_ID_PE); |
| 4263 | if (NULL == pMac) { |
| 4264 | WMA_LOGE("%s: Unable to get PE context", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4265 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4266 | } |
| 4267 | #endif /* CONFIG_CNSS */ |
| 4268 | |
| 4269 | len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param); |
| 4270 | |
| 4271 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4272 | if (!buf) { |
| 4273 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4274 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4275 | } |
| 4276 | |
| 4277 | cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *) |
| 4278 | wmi_buf_data(buf); |
| 4279 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4280 | WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param, |
| 4281 | WMITLV_GET_STRUCT_TLVLEN |
| 4282 | (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param)); |
| 4283 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4284 | qdf_event_reset(&wma->wma_resume_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4285 | |
| 4286 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 4287 | WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID); |
| 4288 | if (ret) { |
| 4289 | WMA_LOGE("Failed to send host wakeup indication to fw"); |
| 4290 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4291 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4292 | } |
| 4293 | |
| 4294 | WMA_LOGD("Host wakeup indication sent to fw"); |
| 4295 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4296 | qdf_status = qdf_wait_single_event(&(wma->wma_resume_event), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4297 | WMA_RESUME_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4298 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4299 | WMA_LOGP("%s: Timeout waiting for resume event from FW", |
| 4300 | __func__); |
| 4301 | WMA_LOGP("%s: Pending commands %d credits %d", __func__, |
| 4302 | wmi_get_pending_cmds(wma->wmi_handle), |
| 4303 | wmi_get_host_credits(wma->wmi_handle)); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 4304 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | #ifdef CONFIG_CNSS |
| 4306 | if (pMac->sme.enableSelfRecovery) { |
| 4307 | cds_trigger_recovery(); |
| 4308 | } else { |
| 4309 | CDF_BUG(0); |
| 4310 | } |
| 4311 | #else |
| 4312 | CDF_BUG(0); |
| 4313 | #endif /* CONFIG_CNSS */ |
| 4314 | } else { |
| 4315 | WMA_LOGE("%s: SSR in progress, ignore resume timeout", |
| 4316 | __func__); |
| 4317 | } |
| 4318 | } else { |
| 4319 | WMA_LOGD("Host wakeup received"); |
| 4320 | } |
| 4321 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4322 | if (QDF_STATUS_SUCCESS == qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4323 | wmi_set_target_suspend(wma->wmi_handle, false); |
| 4324 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4325 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | } |
| 4327 | |
| 4328 | /** |
| 4329 | * wma_disable_wow_in_fw() - Disable wow in PCIe resume context. |
| 4330 | * @handle: wma handle |
| 4331 | * |
| 4332 | * Return: 0 for success or error code |
| 4333 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4334 | QDF_STATUS wma_disable_wow_in_fw(WMA_HANDLE handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4335 | { |
| 4336 | tp_wma_handle wma = handle; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4337 | QDF_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4338 | |
| 4339 | if (!wma->wow.wow_enable || !wma->wow.wow_enable_cmd_sent) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4340 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | |
| 4342 | ret = wma_send_host_wakeup_ind_to_fw(wma); |
| 4343 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4344 | if (ret != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4345 | return ret; |
| 4346 | |
| 4347 | wma->wow.wow_enable = false; |
| 4348 | wma->wow.wow_enable_cmd_sent = false; |
| 4349 | |
| 4350 | /* To allow the tx pause/unpause events */ |
| 4351 | wma_set_wow_bus_suspend(wma, 0); |
| 4352 | /* Unpause the vdev as we are resuming */ |
| 4353 | wma_unpause_vdev(wma); |
| 4354 | |
| 4355 | return ret; |
| 4356 | } |
| 4357 | |
| 4358 | #ifdef WLAN_FEATURE_LPSS |
| 4359 | /** |
| 4360 | * wma_is_lpass_enabled() - check if lpass is enabled |
| 4361 | * @handle: Pointer to wma handle |
| 4362 | * |
| 4363 | * WoW is needed if LPASS or NaN feature is enabled in INI because |
| 4364 | * target can't wake up itself if its put in PDEV suspend when LPASS |
| 4365 | * or NaN features are supported |
| 4366 | * |
| 4367 | * Return: true if lpass is enabled else false |
| 4368 | */ |
| 4369 | bool static wma_is_lpass_enabled(tp_wma_handle wma) |
| 4370 | { |
| 4371 | if (wma->is_lpass_enabled) |
| 4372 | return true; |
| 4373 | else |
| 4374 | return false; |
| 4375 | } |
| 4376 | #else |
| 4377 | bool static wma_is_lpass_enabled(tp_wma_handle wma) |
| 4378 | { |
| 4379 | return false; |
| 4380 | } |
| 4381 | #endif |
| 4382 | |
| 4383 | #ifdef WLAN_FEATURE_NAN |
| 4384 | /** |
| 4385 | * wma_is_nan_enabled() - check if NaN is enabled |
| 4386 | * @handle: Pointer to wma handle |
| 4387 | * |
| 4388 | * WoW is needed if LPASS or NaN feature is enabled in INI because |
| 4389 | * target can't wake up itself if its put in PDEV suspend when LPASS |
| 4390 | * or NaN features are supported |
| 4391 | * |
| 4392 | * Return: true if NaN is enabled else false |
| 4393 | */ |
| 4394 | bool static wma_is_nan_enabled(tp_wma_handle wma) |
| 4395 | { |
| 4396 | if (wma->is_nan_enabled) |
| 4397 | return true; |
| 4398 | else |
| 4399 | return false; |
| 4400 | } |
| 4401 | #else |
| 4402 | bool static wma_is_nan_enabled(tp_wma_handle wma) |
| 4403 | { |
| 4404 | return false; |
| 4405 | } |
| 4406 | #endif |
| 4407 | |
| 4408 | /** |
| 4409 | * wma_is_wow_mode_selected() - check if wow needs to be enabled in fw |
| 4410 | * @handle: Pointer to wma handle |
| 4411 | * |
| 4412 | * If lpass is enabled then always do wow else check wow_enable config |
| 4413 | * |
| 4414 | * Return: true is wow mode is needed else false |
| 4415 | */ |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 4416 | bool wma_is_wow_mode_selected(WMA_HANDLE handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4417 | { |
| 4418 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 4419 | |
| 4420 | if (wma_is_lpass_enabled(wma)) { |
| 4421 | WMA_LOGD("LPASS is enabled select WoW"); |
| 4422 | return true; |
| 4423 | } else if (wma_is_nan_enabled(wma)) { |
| 4424 | WMA_LOGD("NAN is enabled select WoW"); |
| 4425 | return true; |
| 4426 | } else { |
| 4427 | WMA_LOGD("WoW enable %d", wma->wow.wow_enable); |
| 4428 | return wma->wow.wow_enable; |
| 4429 | } |
| 4430 | } |
| 4431 | |
| 4432 | /** |
| 4433 | * wma_del_ts_req() - send DELTS request to fw |
| 4434 | * @wma: wma handle |
| 4435 | * @msg: delts params |
| 4436 | * |
| 4437 | * Return: none |
| 4438 | */ |
| 4439 | void wma_del_ts_req(tp_wma_handle wma, tDelTsParams *msg) |
| 4440 | { |
| 4441 | wmi_vdev_wmm_delts_cmd_fixed_param *cmd; |
| 4442 | wmi_buf_t buf; |
| 4443 | int32_t len = sizeof(*cmd); |
| 4444 | |
| 4445 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4446 | if (!buf) { |
| 4447 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 4448 | goto err; |
| 4449 | } |
| 4450 | cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf); |
| 4451 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4452 | WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param, |
| 4453 | WMITLV_GET_STRUCT_TLVLEN |
| 4454 | (wmi_vdev_wmm_delts_cmd_fixed_param)); |
| 4455 | cmd->vdev_id = msg->sessionId; |
| 4456 | cmd->ac = TID_TO_WME_AC(msg->userPrio); |
| 4457 | |
| 4458 | WMA_LOGD("Delts vdev:%d, ac:%d, %s:%d", |
| 4459 | cmd->vdev_id, cmd->ac, __FUNCTION__, __LINE__); |
| 4460 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 4461 | WMI_VDEV_WMM_DELTS_CMDID)) { |
| 4462 | WMA_LOGP("%s: Failed to send vdev DELTS command", __func__); |
| 4463 | cdf_nbuf_free(buf); |
| 4464 | } |
| 4465 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 4466 | if (msg->setRICparams == true) |
| 4467 | wma_set_ric_req(wma, msg, false); |
| 4468 | #endif /* WLAN_FEATURE_ROAM_OFFLOAD */ |
| 4469 | |
| 4470 | err: |
| 4471 | cdf_mem_free(msg); |
| 4472 | } |
| 4473 | |
| 4474 | /** |
| 4475 | * wma_aggr_qos_req() - send aggr qos request to fw |
| 4476 | * @wma: handle to wma |
| 4477 | * @pAggrQosRspMsg - combined struct for all ADD_TS requests. |
| 4478 | * |
| 4479 | * A function to handle WMA_AGGR_QOS_REQ. This will send out |
| 4480 | * ADD_TS requestes to firmware in loop for all the ACs with |
| 4481 | * active flow. |
| 4482 | * |
| 4483 | * Return: none |
| 4484 | */ |
| 4485 | void wma_aggr_qos_req(tp_wma_handle wma, |
| 4486 | tAggrAddTsParams *pAggrQosRspMsg) |
| 4487 | { |
| 4488 | int i = 0; |
| 4489 | wmi_vdev_wmm_addts_cmd_fixed_param *cmd; |
| 4490 | wmi_buf_t buf; |
| 4491 | int32_t len = sizeof(*cmd); |
| 4492 | |
| 4493 | for (i = 0; i < HAL_QOS_NUM_AC_MAX; i++) { |
| 4494 | /* if flow in this AC is active */ |
| 4495 | if (((1 << i) & pAggrQosRspMsg->tspecIdx)) { |
| 4496 | /* |
| 4497 | * as per implementation of wma_add_ts_req() we |
| 4498 | * are not waiting any response from firmware so |
| 4499 | * apart from sending ADDTS to firmware just send |
| 4500 | * success to upper layers |
| 4501 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4502 | pAggrQosRspMsg->status[i] = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4503 | |
| 4504 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4505 | if (!buf) { |
| 4506 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 4507 | goto aggr_qos_exit; |
| 4508 | } |
| 4509 | cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) |
| 4510 | wmi_buf_data(buf); |
| 4511 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4512 | WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param, |
| 4513 | WMITLV_GET_STRUCT_TLVLEN |
| 4514 | (wmi_vdev_wmm_addts_cmd_fixed_param)); |
| 4515 | cmd->vdev_id = pAggrQosRspMsg->sessionId; |
| 4516 | cmd->ac = |
| 4517 | TID_TO_WME_AC(pAggrQosRspMsg->tspec[i].tsinfo. |
| 4518 | traffic.userPrio); |
| 4519 | cmd->medium_time_us = |
| 4520 | pAggrQosRspMsg->tspec[i].mediumTime * 32; |
| 4521 | cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO; |
| 4522 | WMA_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d", |
| 4523 | __func__, __LINE__, cmd->vdev_id, cmd->ac, |
| 4524 | cmd->medium_time_us, cmd->downgrade_type); |
| 4525 | if (wmi_unified_cmd_send |
| 4526 | (wma->wmi_handle, buf, len, |
| 4527 | WMI_VDEV_WMM_ADDTS_CMDID)) { |
| 4528 | WMA_LOGP("%s: Failed to send vdev ADDTS command", |
| 4529 | __func__); |
| 4530 | pAggrQosRspMsg->status[i] = |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4531 | QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4532 | cdf_nbuf_free(buf); |
| 4533 | } |
| 4534 | } |
| 4535 | } |
| 4536 | |
| 4537 | aggr_qos_exit: |
| 4538 | /* send reponse to upper layers from here only. */ |
| 4539 | wma_send_msg(wma, WMA_AGGR_QOS_RSP, pAggrQosRspMsg, 0); |
| 4540 | } |
| 4541 | |
| 4542 | /** |
| 4543 | * wma_add_ts_req() - send ADDTS request to fw |
| 4544 | * @wma: wma handle |
| 4545 | * @msg: ADDTS params |
| 4546 | * |
| 4547 | * Return: none |
| 4548 | */ |
| 4549 | void wma_add_ts_req(tp_wma_handle wma, tAddTsParams *msg) |
| 4550 | { |
| 4551 | wmi_vdev_wmm_addts_cmd_fixed_param *cmd; |
| 4552 | wmi_buf_t buf; |
| 4553 | int32_t len = sizeof(*cmd); |
| 4554 | |
| 4555 | #ifdef FEATURE_WLAN_ESE |
| 4556 | /* |
| 4557 | * msmt_interval is in unit called TU (1 TU = 1024 us) |
| 4558 | * max value of msmt_interval cannot make resulting |
| 4559 | * interval_miliseconds overflow 32 bit |
| 4560 | */ |
| 4561 | uint32_t intervalMiliseconds; |
| 4562 | ol_txrx_pdev_handle pdev = cds_get_context(CDF_MODULE_ID_TXRX); |
| 4563 | if (NULL == pdev) { |
| 4564 | WMA_LOGE("%s: Failed to get pdev", __func__); |
| 4565 | goto err; |
| 4566 | } |
| 4567 | |
| 4568 | intervalMiliseconds = (msg->tsm_interval * 1024) / 1000; |
| 4569 | |
| 4570 | ol_tx_set_compute_interval(pdev, intervalMiliseconds); |
| 4571 | #endif /* FEATURE_WLAN_ESE */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4572 | msg->status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | |
| 4574 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4575 | if (!buf) { |
| 4576 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 4577 | goto err; |
| 4578 | } |
| 4579 | cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf); |
| 4580 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4581 | WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param, |
| 4582 | WMITLV_GET_STRUCT_TLVLEN |
| 4583 | (wmi_vdev_wmm_addts_cmd_fixed_param)); |
| 4584 | cmd->vdev_id = msg->sme_session_id; |
| 4585 | cmd->ac = TID_TO_WME_AC(msg->tspec.tsinfo.traffic.userPrio); |
| 4586 | cmd->medium_time_us = msg->tspec.mediumTime * 32; |
| 4587 | cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP; |
| 4588 | WMA_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d", |
| 4589 | cmd->vdev_id, cmd->ac, cmd->medium_time_us, |
| 4590 | cmd->downgrade_type, __func__, __LINE__); |
| 4591 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 4592 | WMI_VDEV_WMM_ADDTS_CMDID)) { |
| 4593 | WMA_LOGP("%s: Failed to send vdev ADDTS command", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4594 | msg->status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4595 | cdf_nbuf_free(buf); |
| 4596 | } |
| 4597 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 4598 | if (msg->setRICparams == true) |
| 4599 | wma_set_ric_req(wma, msg, true); |
| 4600 | #endif /* WLAN_FEATURE_ROAM_OFFLOAD */ |
| 4601 | |
| 4602 | err: |
| 4603 | wma_send_msg(wma, WMA_ADD_TS_RSP, msg, 0); |
| 4604 | } |
| 4605 | |
| 4606 | /** |
| 4607 | * wma_enable_disable_packet_filter() - enable/disable packet filter in target |
| 4608 | * @wma: Pointer to wma handle |
| 4609 | * @vdev_id: vdev id |
| 4610 | * @enable: Flag to enable/disable packet filter |
| 4611 | * |
| 4612 | * Return: 0 for success or error code |
| 4613 | */ |
| 4614 | static int wma_enable_disable_packet_filter(tp_wma_handle wma, |
| 4615 | uint8_t vdev_id, bool enable) |
| 4616 | { |
| 4617 | int32_t len; |
| 4618 | int ret = 0; |
| 4619 | wmi_buf_t buf; |
| 4620 | WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd; |
| 4621 | |
| 4622 | len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param); |
| 4623 | |
| 4624 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4625 | if (!buf) { |
| 4626 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
| 4627 | return -ENOMEM; |
| 4628 | } |
| 4629 | |
| 4630 | cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf); |
| 4631 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4632 | WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param, |
| 4633 | WMITLV_GET_STRUCT_TLVLEN( |
| 4634 | WMI_PACKET_FILTER_ENABLE_CMD_fixed_param)); |
| 4635 | |
| 4636 | cmd->vdev_id = vdev_id; |
| 4637 | if (enable) |
| 4638 | cmd->enable = PACKET_FILTER_SET_ENABLE; |
| 4639 | else |
| 4640 | cmd->enable = PACKET_FILTER_SET_DISABLE; |
| 4641 | |
| 4642 | WMA_LOGE("%s: Packet filter enable %d for vdev_id %d", |
| 4643 | __func__, cmd->enable, vdev_id); |
| 4644 | |
| 4645 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 4646 | WMI_PACKET_FILTER_ENABLE_CMDID); |
| 4647 | if (ret) |
| 4648 | WMA_LOGE("Failed to send packet filter wmi cmd to fw"); |
| 4649 | |
| 4650 | return ret; |
| 4651 | } |
| 4652 | |
| 4653 | /** |
| 4654 | * wma_config_packet_filter() - configure packet filter in target |
| 4655 | * @wma: Pointer to wma handle |
| 4656 | * @vdev_id: vdev id |
| 4657 | * @rcv_filter_param: Packet filter parameters |
| 4658 | * @filter_id: Filter id |
| 4659 | * @enable: Flag to add/delete packet filter configuration |
| 4660 | * |
| 4661 | * Return: 0 for success or error code |
| 4662 | */ |
| 4663 | static int wma_config_packet_filter(tp_wma_handle wma, |
| 4664 | uint8_t vdev_id, tSirRcvPktFilterCfgType *rcv_filter_param, |
| 4665 | uint8_t filter_id, bool enable) |
| 4666 | { |
| 4667 | int len, i; |
| 4668 | int err = 0; |
| 4669 | wmi_buf_t buf; |
| 4670 | WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd; |
| 4671 | |
| 4672 | |
| 4673 | /* allocate the memory */ |
| 4674 | len = sizeof(*cmd); |
| 4675 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 4676 | if (!buf) { |
| 4677 | WMA_LOGE("Failed to allocate buffer to send set_param cmd"); |
| 4678 | return -ENOMEM; |
| 4679 | } |
| 4680 | |
| 4681 | cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf); |
| 4682 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4683 | WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param, |
| 4684 | WMITLV_GET_STRUCT_TLVLEN |
| 4685 | (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param)); |
| 4686 | |
| 4687 | cmd->vdev_id = vdev_id; |
| 4688 | cmd->filter_id = filter_id; |
| 4689 | if (enable) |
| 4690 | cmd->filter_action = PACKET_FILTER_SET_ACTIVE; |
| 4691 | else |
| 4692 | cmd->filter_action = PACKET_FILTER_SET_INACTIVE; |
| 4693 | |
| 4694 | if (enable) { |
| 4695 | cmd->num_params = CDF_MIN( |
| 4696 | WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER, |
| 4697 | rcv_filter_param->numFieldParams); |
| 4698 | cmd->filter_type = rcv_filter_param->filterType; |
| 4699 | cmd->coalesce_time = rcv_filter_param->coalesceTime; |
| 4700 | |
| 4701 | for (i = 0; i < cmd->num_params; i++) { |
| 4702 | cmd->paramsData[i].proto_type = |
| 4703 | rcv_filter_param->paramsData[i].protocolLayer; |
| 4704 | cmd->paramsData[i].cmp_type = |
| 4705 | rcv_filter_param->paramsData[i].cmpFlag; |
| 4706 | cmd->paramsData[i].data_length = |
| 4707 | rcv_filter_param->paramsData[i].dataLength; |
| 4708 | cmd->paramsData[i].data_offset = |
| 4709 | rcv_filter_param->paramsData[i].dataOffset; |
| 4710 | memcpy(&cmd->paramsData[i].compareData, |
| 4711 | rcv_filter_param->paramsData[i].compareData, |
| 4712 | sizeof(cmd->paramsData[i].compareData)); |
| 4713 | memcpy(&cmd->paramsData[i].dataMask, |
| 4714 | rcv_filter_param->paramsData[i].dataMask, |
| 4715 | sizeof(cmd->paramsData[i].dataMask)); |
| 4716 | } |
| 4717 | } |
| 4718 | |
| 4719 | WMA_LOGE("Packet filter action %d filter with id: %d, num_params=%d", |
| 4720 | cmd->filter_action, cmd->filter_id, cmd->num_params); |
| 4721 | /* send the command along with data */ |
| 4722 | err = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 4723 | WMI_PACKET_FILTER_CONFIG_CMDID); |
| 4724 | if (err) { |
| 4725 | WMA_LOGE("Failed to send pkt_filter cmd"); |
| 4726 | wmi_buf_free(buf); |
| 4727 | return -EIO; |
| 4728 | } |
| 4729 | |
| 4730 | /* Enable packet filter */ |
| 4731 | if (enable) |
| 4732 | wma_enable_disable_packet_filter(wma, vdev_id, true); |
| 4733 | |
| 4734 | return 0; |
| 4735 | } |
| 4736 | |
| 4737 | /** |
| 4738 | * wma_process_receive_filter_set_filter_req() - enable packet filter |
| 4739 | * @wma_handle: wma handle |
| 4740 | * @rcv_filter_param: filter params |
| 4741 | * |
| 4742 | * Return: 0 for success or error code |
| 4743 | */ |
| 4744 | int wma_process_receive_filter_set_filter_req(tp_wma_handle wma, |
| 4745 | tSirRcvPktFilterCfgType *rcv_filter_param) |
| 4746 | { |
| 4747 | int ret = 0; |
| 4748 | uint8_t vdev_id; |
| 4749 | |
| 4750 | /* Get the vdev id */ |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4751 | if (!wma_find_vdev_by_bssid(wma, |
| 4752 | rcv_filter_param->bssid.bytes, &vdev_id)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | WMA_LOGE("vdev handle is invalid for %pM", |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4754 | rcv_filter_param->bssid.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | return -EINVAL; |
| 4756 | } |
| 4757 | |
| 4758 | ret = wma_config_packet_filter(wma, vdev_id, rcv_filter_param, |
| 4759 | rcv_filter_param->filterId, true); |
| 4760 | |
| 4761 | return ret; |
| 4762 | } |
| 4763 | |
| 4764 | /** |
| 4765 | * wma_process_receive_filter_clear_filter_req() - disable packet filter |
| 4766 | * @wma_handle: wma handle |
| 4767 | * @rcv_clear_param: filter params |
| 4768 | * |
| 4769 | * Return: 0 for success or error code |
| 4770 | */ |
| 4771 | int wma_process_receive_filter_clear_filter_req(tp_wma_handle wma, |
| 4772 | tSirRcvFltPktClearParam *rcv_clear_param) |
| 4773 | { |
| 4774 | int ret = 0; |
| 4775 | uint8_t vdev_id; |
| 4776 | |
| 4777 | /* Get the vdev id */ |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4778 | if (!wma_find_vdev_by_bssid(wma, |
| 4779 | rcv_clear_param->bssid.bytes, &vdev_id)) { |
| 4780 | WMA_LOGE("vdev handle is invalid for %pM", |
| 4781 | rcv_clear_param->bssid.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4782 | return -EINVAL; |
| 4783 | } |
| 4784 | |
| 4785 | ret = wma_config_packet_filter(wma, vdev_id, NULL, |
| 4786 | rcv_clear_param->filterId, false); |
| 4787 | |
| 4788 | return ret; |
| 4789 | } |
| 4790 | |
| 4791 | #ifdef FEATURE_WLAN_ESE |
| 4792 | |
| 4793 | #define TSM_DELAY_HISTROGRAM_BINS 4 |
| 4794 | /** |
| 4795 | * wma_process_tsm_stats_req() - process tsm stats request |
| 4796 | * @wma_handler - handle to wma |
| 4797 | * @pTsmStatsMsg - TSM stats struct that needs to be populated and |
| 4798 | * passed in message. |
| 4799 | * |
| 4800 | * A parallel function to WMA_ProcessTsmStatsReq for pronto. This |
| 4801 | * function fetches stats from data path APIs and post |
| 4802 | * WMA_TSM_STATS_RSP msg back to LIM. |
| 4803 | * |
| 4804 | * Return: CDF status |
| 4805 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4806 | QDF_STATUS wma_process_tsm_stats_req(tp_wma_handle wma_handler, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4807 | void *pTsmStatsMsg) |
| 4808 | { |
| 4809 | uint8_t counter; |
| 4810 | uint32_t queue_delay_microsec = 0; |
| 4811 | uint32_t tx_delay_microsec = 0; |
| 4812 | uint16_t packet_count = 0; |
| 4813 | uint16_t packet_loss_count = 0; |
| 4814 | tpAniTrafStrmMetrics pTsmMetric = NULL; |
| 4815 | #ifdef FEATURE_WLAN_ESE_UPLOAD |
| 4816 | tpAniGetTsmStatsReq pStats = (tpAniGetTsmStatsReq) pTsmStatsMsg; |
| 4817 | tpAniGetTsmStatsRsp pTsmRspParams = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4818 | #endif /* FEATURE_WLAN_ESE_UPLOAD */ |
| 4819 | int tid = pStats->tid; |
| 4820 | /* |
| 4821 | * The number of histrogram bin report by data path api are different |
| 4822 | * than required by TSM, hence different (6) size array used |
| 4823 | */ |
| 4824 | uint16_t bin_values[QCA_TX_DELAY_HIST_REPORT_BINS] = { 0, }; |
| 4825 | |
| 4826 | ol_txrx_pdev_handle pdev = cds_get_context(CDF_MODULE_ID_TXRX); |
| 4827 | |
| 4828 | if (NULL == pdev) { |
| 4829 | WMA_LOGE("%s: Failed to get pdev", __func__); |
| 4830 | cdf_mem_free(pTsmStatsMsg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4831 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | } |
| 4833 | |
| 4834 | /* get required values from data path APIs */ |
| 4835 | ol_tx_delay(pdev, &queue_delay_microsec, &tx_delay_microsec, tid); |
| 4836 | ol_tx_delay_hist(pdev, bin_values, tid); |
| 4837 | ol_tx_packet_count(pdev, &packet_count, &packet_loss_count, tid); |
| 4838 | |
| 4839 | #ifdef FEATURE_WLAN_ESE_UPLOAD |
| 4840 | pTsmRspParams = |
| 4841 | (tpAniGetTsmStatsRsp) cdf_mem_malloc(sizeof(tAniGetTsmStatsRsp)); |
| 4842 | if (NULL == pTsmRspParams) { |
| 4843 | CDF_TRACE(CDF_MODULE_ID_WMA, CDF_TRACE_LEVEL_ERROR, |
| 4844 | "%s: CDF MEM Alloc Failure", __func__); |
| 4845 | CDF_ASSERT(0); |
| 4846 | cdf_mem_free(pTsmStatsMsg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4847 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4848 | } |
| 4849 | pTsmRspParams->staId = pStats->staId; |
| 4850 | pTsmRspParams->rc = eSIR_FAILURE; |
| 4851 | pTsmRspParams->tsmStatsReq = pStats; |
| 4852 | pTsmMetric = &pTsmRspParams->tsmMetrics; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | #endif /* FEATURE_WLAN_ESE_UPLOAD */ |
| 4854 | /* populate pTsmMetric */ |
| 4855 | pTsmMetric->UplinkPktQueueDly = queue_delay_microsec; |
| 4856 | /* store only required number of bin values */ |
| 4857 | for (counter = 0; counter < TSM_DELAY_HISTROGRAM_BINS; counter++) { |
| 4858 | pTsmMetric->UplinkPktQueueDlyHist[counter] = |
| 4859 | bin_values[counter]; |
| 4860 | } |
| 4861 | pTsmMetric->UplinkPktTxDly = tx_delay_microsec; |
| 4862 | pTsmMetric->UplinkPktLoss = packet_loss_count; |
| 4863 | pTsmMetric->UplinkPktCount = packet_count; |
| 4864 | |
| 4865 | /* |
| 4866 | * No need to populate roaming delay and roaming count as they are |
| 4867 | * being populated just before sending IAPP frame out |
| 4868 | */ |
| 4869 | /* post this message to LIM/PE */ |
| 4870 | #ifdef FEATURE_WLAN_ESE_UPLOAD |
| 4871 | wma_send_msg(wma_handler, WMA_TSM_STATS_RSP, (void *)pTsmRspParams, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | #endif /* FEATURE_WLAN_ESE_UPLOAD */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4873 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4874 | } |
| 4875 | |
| 4876 | #endif /* FEATURE_WLAN_ESE */ |
| 4877 | |
| 4878 | /** |
| 4879 | * wma_add_clear_mcbc_filter() - set mcast filter command to fw |
| 4880 | * @wma_handle: wma handle |
| 4881 | * @vdev_id: vdev id |
| 4882 | * @multicastAddr: mcast address |
| 4883 | * @clearList: clear list flag |
| 4884 | * |
| 4885 | * Return: 0 for success or error code |
| 4886 | */ |
| 4887 | static int wma_add_clear_mcbc_filter(tp_wma_handle wma_handle, uint8_t vdev_id, |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4888 | struct cdf_mac_addr multicast_addr, |
| 4889 | bool clearList) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4890 | { |
| 4891 | WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd; |
| 4892 | wmi_buf_t buf; |
| 4893 | int err; |
| 4894 | |
| 4895 | buf = wmi_buf_alloc(wma_handle->wmi_handle, sizeof(*cmd)); |
| 4896 | if (!buf) { |
| 4897 | WMA_LOGE("Failed to allocate buffer to send set_param cmd"); |
| 4898 | return -ENOMEM; |
| 4899 | } |
| 4900 | |
| 4901 | cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf); |
| 4902 | cdf_mem_zero(cmd, sizeof(*cmd)); |
| 4903 | |
| 4904 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 4905 | WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param, |
| 4906 | WMITLV_GET_STRUCT_TLVLEN |
| 4907 | (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param)); |
| 4908 | cmd->action = |
| 4909 | (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET); |
| 4910 | cmd->vdev_id = vdev_id; |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4911 | WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4912 | err = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 4913 | sizeof(*cmd), |
| 4914 | WMI_SET_MCASTBCAST_FILTER_CMDID); |
| 4915 | if (err) { |
| 4916 | WMA_LOGE("Failed to send set_param cmd"); |
| 4917 | cdf_mem_free(buf); |
| 4918 | return -EIO; |
| 4919 | } |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4920 | WMA_LOGD("Action:%d; vdev_id:%d; clearList:%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4921 | cmd->action, vdev_id, clearList); |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4922 | WMA_LOGD("MCBC MAC Addr: "MAC_ADDRESS_STR, |
| 4923 | MAC_ADDR_ARRAY(multicast_addr.bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4924 | return 0; |
| 4925 | } |
| 4926 | |
| 4927 | /** |
| 4928 | * wma_process_mcbc_set_filter_req() - process mcbc set filter request |
| 4929 | * @wma_handle: wma handle |
| 4930 | * @mcbc_param: mcbc params |
| 4931 | * |
| 4932 | * Return: CDF status |
| 4933 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4934 | QDF_STATUS wma_process_mcbc_set_filter_req(tp_wma_handle wma_handle, |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4935 | tSirRcvFltMcAddrList *mcbc_param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4936 | { |
| 4937 | uint8_t vdev_id = 0; |
| 4938 | int i; |
| 4939 | |
| 4940 | if (mcbc_param->ulMulticastAddrCnt <= 0) { |
Srinivas Girigowda | f2599dd | 2015-11-16 18:20:46 -0800 | [diff] [blame] | 4941 | WMA_LOGW("Number of multicast addresses is 0"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4942 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4943 | } |
| 4944 | |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4945 | if (!wma_find_vdev_by_addr(wma_handle, |
| 4946 | mcbc_param->self_macaddr.bytes, &vdev_id)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4947 | WMA_LOGE("%s: Failed to find vdev id for %pM", __func__, |
Srinivas Girigowda | 9853049 | 2015-11-20 17:39:24 -0800 | [diff] [blame] | 4948 | mcbc_param->bssid.bytes); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4949 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4950 | } |
| 4951 | /* set mcbc_param->action to clear MCList and reset |
| 4952 | * to configure the MCList in FW |
| 4953 | */ |
| 4954 | |
| 4955 | for (i = 0; i < mcbc_param->ulMulticastAddrCnt; i++) { |
| 4956 | wma_add_clear_mcbc_filter(wma_handle, vdev_id, |
| 4957 | mcbc_param->multicastAddr[i], |
| 4958 | (mcbc_param->action == 0)); |
| 4959 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 4960 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4961 | } |
| 4962 | |
| 4963 | #ifdef WLAN_FEATURE_GTK_OFFLOAD |
| 4964 | #define GTK_OFFLOAD_ENABLE 0 |
| 4965 | #define GTK_OFFLOAD_DISABLE 1 |
| 4966 | |
| 4967 | /** |
| 4968 | * wma_gtk_offload_status_event() - GTK offload status event handler |
| 4969 | * @handle: wma handle |
| 4970 | * @event: event buffer |
| 4971 | * @len: buffer length |
| 4972 | * |
| 4973 | * Return: 0 for success or error code |
| 4974 | */ |
| 4975 | int wma_gtk_offload_status_event(void *handle, uint8_t *event, |
| 4976 | uint32_t len) |
| 4977 | { |
| 4978 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 4979 | WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *status; |
| 4980 | WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf; |
| 4981 | tpSirGtkOffloadGetInfoRspParams resp; |
| 4982 | cds_msg_t cds_msg; |
| 4983 | uint8_t *bssid; |
| 4984 | |
| 4985 | WMA_LOGD("%s Enter", __func__); |
| 4986 | |
| 4987 | param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *) event; |
| 4988 | if (!param_buf) { |
| 4989 | WMA_LOGE("param_buf is NULL"); |
| 4990 | return -EINVAL; |
| 4991 | } |
| 4992 | |
| 4993 | status = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *) param_buf->fixed_param; |
| 4994 | |
| 4995 | if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) { |
| 4996 | WMA_LOGE("Invalid length for GTK status"); |
| 4997 | return -EINVAL; |
| 4998 | } |
| 4999 | bssid = wma_find_bssid_by_vdev_id(wma, status->vdev_id); |
| 5000 | if (!bssid) { |
| 5001 | WMA_LOGE("invalid bssid for vdev id %d", status->vdev_id); |
| 5002 | return -ENOENT; |
| 5003 | } |
| 5004 | |
| 5005 | resp = cdf_mem_malloc(sizeof(*resp)); |
| 5006 | if (!resp) { |
| 5007 | WMA_LOGE("%s: Failed to alloc response", __func__); |
| 5008 | return -ENOMEM; |
| 5009 | } |
| 5010 | cdf_mem_zero(resp, sizeof(*resp)); |
| 5011 | resp->mesgType = eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP; |
| 5012 | resp->mesgLen = sizeof(*resp); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5013 | resp->ulStatus = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5014 | resp->ulTotalRekeyCount = status->refresh_cnt; |
| 5015 | /* TODO: Is the total rekey count and GTK rekey count same? */ |
| 5016 | resp->ulGTKRekeyCount = status->refresh_cnt; |
| 5017 | |
| 5018 | cdf_mem_copy(&resp->ullKeyReplayCounter, &status->replay_counter, |
| 5019 | GTK_REPLAY_COUNTER_BYTES); |
| 5020 | |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 5021 | cdf_mem_copy(resp->bssid.bytes, bssid, IEEE80211_ADDR_LEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5022 | |
| 5023 | #ifdef IGTK_OFFLOAD |
| 5024 | /* TODO: Is the refresh count same for GTK and IGTK? */ |
| 5025 | resp->ulIGTKRekeyCount = status->refresh_cnt; |
| 5026 | #endif /* IGTK_OFFLOAD */ |
| 5027 | |
| 5028 | cds_msg.type = eWNI_PMC_GTK_OFFLOAD_GETINFO_RSP; |
| 5029 | cds_msg.bodyptr = (void *)resp; |
| 5030 | cds_msg.bodyval = 0; |
| 5031 | |
| 5032 | if (cds_mq_post_message(CDS_MQ_ID_SME, (cds_msg_t *) &cds_msg) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5033 | != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5034 | WMA_LOGE("Failed to post GTK response to SME"); |
| 5035 | cdf_mem_free(resp); |
| 5036 | return -EINVAL; |
| 5037 | } |
| 5038 | |
| 5039 | WMA_LOGD("GTK: got target status with replay counter " |
| 5040 | "%02x%02x%02x%02x%02x%02x%02x%02x. vdev %d " |
| 5041 | "Refresh GTK %d times exchanges since last set operation", |
| 5042 | status->replay_counter[0], |
| 5043 | status->replay_counter[1], |
| 5044 | status->replay_counter[2], |
| 5045 | status->replay_counter[3], |
| 5046 | status->replay_counter[4], |
| 5047 | status->replay_counter[5], |
| 5048 | status->replay_counter[6], |
| 5049 | status->replay_counter[7], |
| 5050 | status->vdev_id, status->refresh_cnt); |
| 5051 | |
| 5052 | WMA_LOGD("%s Exit", __func__); |
| 5053 | |
| 5054 | return 0; |
| 5055 | } |
| 5056 | |
| 5057 | /** |
| 5058 | * wma_send_gtk_offload_req() - send GTK offload command to fw |
| 5059 | * @wma: wma handle |
| 5060 | * @vdev_id: vdev id |
| 5061 | * @params: GTK offload parameters |
| 5062 | * |
| 5063 | * Return: CDF status |
| 5064 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5065 | static QDF_STATUS wma_send_gtk_offload_req(tp_wma_handle wma, uint8_t vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5066 | tpSirGtkOffloadParams params) |
| 5067 | { |
| 5068 | int len; |
| 5069 | wmi_buf_t buf; |
| 5070 | WMI_GTK_OFFLOAD_CMD_fixed_param *cmd; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5071 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5072 | |
| 5073 | WMA_LOGD("%s Enter", __func__); |
| 5074 | |
| 5075 | len = sizeof(*cmd); |
| 5076 | |
| 5077 | /* alloc wmi buffer */ |
| 5078 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5079 | if (!buf) { |
| 5080 | WMA_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5081 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5082 | goto out; |
| 5083 | } |
| 5084 | |
| 5085 | cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf); |
| 5086 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5087 | WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param, |
| 5088 | WMITLV_GET_STRUCT_TLVLEN |
| 5089 | (WMI_GTK_OFFLOAD_CMD_fixed_param)); |
| 5090 | |
| 5091 | cmd->vdev_id = vdev_id; |
| 5092 | |
| 5093 | /* Request target to enable GTK offload */ |
| 5094 | if (params->ulFlags == GTK_OFFLOAD_ENABLE) { |
| 5095 | cmd->flags = GTK_OFFLOAD_ENABLE_OPCODE; |
| 5096 | wma->wow.gtk_err_enable[vdev_id] = true; |
| 5097 | |
| 5098 | /* Copy the keys and replay counter */ |
| 5099 | cdf_mem_copy(cmd->KCK, params->aKCK, GTK_OFFLOAD_KCK_BYTES); |
| 5100 | cdf_mem_copy(cmd->KEK, params->aKEK, GTK_OFFLOAD_KEK_BYTES); |
| 5101 | cdf_mem_copy(cmd->replay_counter, ¶ms->ullKeyReplayCounter, |
| 5102 | GTK_REPLAY_COUNTER_BYTES); |
| 5103 | } else { |
| 5104 | wma->wow.gtk_err_enable[vdev_id] = false; |
| 5105 | cmd->flags = GTK_OFFLOAD_DISABLE_OPCODE; |
| 5106 | } |
| 5107 | |
| 5108 | /* send the wmi command */ |
| 5109 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5110 | WMI_GTK_OFFLOAD_CMDID)) { |
| 5111 | WMA_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID"); |
| 5112 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5113 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5114 | } |
| 5115 | |
| 5116 | WMA_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags); |
| 5117 | out: |
| 5118 | WMA_LOGD("%s Exit", __func__); |
| 5119 | return status; |
| 5120 | } |
| 5121 | |
| 5122 | /** |
| 5123 | * wma_process_gtk_offload_req() - process GTK offload req from umac |
| 5124 | * @handle: wma handle |
| 5125 | * @params: GTK offload params |
| 5126 | * |
| 5127 | * Return: CDF status |
| 5128 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5129 | QDF_STATUS wma_process_gtk_offload_req(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5130 | tpSirGtkOffloadParams params) |
| 5131 | { |
| 5132 | uint8_t vdev_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5133 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | |
| 5135 | WMA_LOGD("%s Enter", __func__); |
| 5136 | |
| 5137 | /* Get the vdev id */ |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 5138 | if (!wma_find_vdev_by_bssid(wma, params->bssid.bytes, &vdev_id)) { |
| 5139 | WMA_LOGE("vdev handle is invalid for %pM", params->bssid.bytes); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5140 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5141 | goto out; |
| 5142 | } |
| 5143 | |
| 5144 | /* Validate vdev id */ |
| 5145 | if (vdev_id >= wma->max_bssid) { |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 5146 | WMA_LOGE("invalid vdev_id %d for %pM", vdev_id, |
| 5147 | params->bssid.bytes); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5148 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5149 | goto out; |
| 5150 | } |
| 5151 | |
| 5152 | if ((params->ulFlags == GTK_OFFLOAD_ENABLE) && |
| 5153 | (wma->wow.gtk_err_enable[vdev_id] == true)) { |
| 5154 | WMA_LOGE("%s GTK Offload already enabled. Disable it first " |
| 5155 | "vdev_id %d", __func__, vdev_id); |
| 5156 | params->ulFlags = GTK_OFFLOAD_DISABLE; |
| 5157 | status = wma_send_gtk_offload_req(wma, vdev_id, params); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5158 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5159 | WMA_LOGE("%s Failed to disable GTK Offload", __func__); |
| 5160 | goto out; |
| 5161 | } |
| 5162 | WMA_LOGD("%s Enable GTK Offload again with updated inputs", |
| 5163 | __func__); |
| 5164 | params->ulFlags = GTK_OFFLOAD_ENABLE; |
| 5165 | } |
| 5166 | status = wma_send_gtk_offload_req(wma, vdev_id, params); |
| 5167 | out: |
| 5168 | cdf_mem_free(params); |
| 5169 | WMA_LOGD("%s Exit", __func__); |
| 5170 | return status; |
| 5171 | } |
| 5172 | |
| 5173 | /** |
| 5174 | * wma_process_gtk_offload_getinfo_req() - send GTK offload cmd to fw |
| 5175 | * @wma: wma handle |
| 5176 | * @params: GTK offload params |
| 5177 | * |
| 5178 | * Return: CDF status |
| 5179 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5180 | QDF_STATUS wma_process_gtk_offload_getinfo_req(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | tpSirGtkOffloadGetInfoRspParams params) |
| 5182 | { |
| 5183 | uint8_t vdev_id; |
| 5184 | int len; |
| 5185 | wmi_buf_t buf; |
| 5186 | WMI_GTK_OFFLOAD_CMD_fixed_param *cmd; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5187 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | |
| 5189 | WMA_LOGD("%s Enter", __func__); |
| 5190 | |
| 5191 | /* Get the vdev id */ |
Srinivas Girigowda | 2213b1d | 2015-11-20 17:10:11 -0800 | [diff] [blame] | 5192 | if (!wma_find_vdev_by_bssid(wma, params->bssid.bytes, &vdev_id)) { |
| 5193 | WMA_LOGE("vdev handle is invalid for %pM", params->bssid.bytes); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5194 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5195 | goto out; |
| 5196 | } |
| 5197 | |
| 5198 | len = sizeof(*cmd); |
| 5199 | |
| 5200 | /* alloc wmi buffer */ |
| 5201 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5202 | if (!buf) { |
| 5203 | WMA_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5204 | status = QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | goto out; |
| 5206 | } |
| 5207 | |
| 5208 | cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf); |
| 5209 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5210 | WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param, |
| 5211 | WMITLV_GET_STRUCT_TLVLEN |
| 5212 | (WMI_GTK_OFFLOAD_CMD_fixed_param)); |
| 5213 | |
| 5214 | /* Request for GTK offload status */ |
| 5215 | cmd->flags = GTK_OFFLOAD_REQUEST_STATUS_OPCODE; |
| 5216 | cmd->vdev_id = vdev_id; |
| 5217 | |
| 5218 | /* send the wmi command */ |
| 5219 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5220 | WMI_GTK_OFFLOAD_CMDID)) { |
| 5221 | WMA_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info"); |
| 5222 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5223 | status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5224 | } |
| 5225 | out: |
| 5226 | cdf_mem_free(params); |
| 5227 | WMA_LOGD("%s Exit", __func__); |
| 5228 | return status; |
| 5229 | } |
| 5230 | #endif /* WLAN_FEATURE_GTK_OFFLOAD */ |
| 5231 | |
| 5232 | /** |
| 5233 | * wma_enable_arp_ns_offload() - enable ARP NS offload |
| 5234 | * @wma: wma handle |
| 5235 | * @tpSirHostOffloadReq: offload request |
| 5236 | * @bArpOnly: flag |
| 5237 | * |
| 5238 | * To configure ARP NS off load data to firmware |
| 5239 | * when target goes to wow mode. |
| 5240 | * |
| 5241 | * Return: CDF Status |
| 5242 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5243 | QDF_STATUS wma_enable_arp_ns_offload(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | tpSirHostOffloadReq |
| 5245 | pHostOffloadParams, bool bArpOnly) |
| 5246 | { |
| 5247 | int32_t i; |
| 5248 | int32_t res; |
| 5249 | WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd; |
| 5250 | WMI_NS_OFFLOAD_TUPLE *ns_tuple; |
| 5251 | WMI_ARP_OFFLOAD_TUPLE *arp_tuple; |
| 5252 | A_UINT8 *buf_ptr; |
| 5253 | wmi_buf_t buf; |
| 5254 | int32_t len; |
| 5255 | uint8_t vdev_id; |
| 5256 | uint32_t count = 0, num_ns_ext_tuples = 0; |
| 5257 | |
| 5258 | /* Get the vdev id */ |
Srinivas Girigowda | b084b55 | 2015-11-24 12:39:12 -0800 | [diff] [blame] | 5259 | if (!wma_find_vdev_by_bssid(wma, pHostOffloadParams->bssid.bytes, |
| 5260 | &vdev_id)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5261 | WMA_LOGE("vdev handle is invalid for %pM", |
Srinivas Girigowda | b084b55 | 2015-11-24 12:39:12 -0800 | [diff] [blame] | 5262 | pHostOffloadParams->bssid.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5263 | cdf_mem_free(pHostOffloadParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5264 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5265 | } |
| 5266 | |
| 5267 | if (!wma->interfaces[vdev_id].vdev_up) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | WMA_LOGE("vdev %d is not up skipping arp/ns offload", vdev_id); |
| 5269 | cdf_mem_free(pHostOffloadParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5270 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5271 | } |
| 5272 | |
| 5273 | if (!bArpOnly) |
| 5274 | count = pHostOffloadParams->num_ns_offload_count; |
| 5275 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5276 | len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) + WMI_TLV_HDR_SIZE + /* TLV place holder size for array of NS tuples */ |
| 5277 | WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) + WMI_TLV_HDR_SIZE + /* TLV place holder size for array of ARP tuples */ |
| 5278 | WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE); |
| 5279 | |
| 5280 | /* |
| 5281 | * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate |
| 5282 | * extra length for extended NS offload tuples which follows ARP offload |
| 5283 | * tuples. Host needs to fill this structure in following format: |
| 5284 | * 2 NS ofload tuples |
| 5285 | * 2 ARP offload tuples |
| 5286 | * N numbers of extended NS offload tuples if HDD has given more than |
| 5287 | * 2 NS offload addresses |
| 5288 | */ |
| 5289 | if (!bArpOnly && count > WMI_MAX_NS_OFFLOADS) { |
| 5290 | num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS; |
| 5291 | len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples * |
| 5292 | sizeof(WMI_NS_OFFLOAD_TUPLE); |
| 5293 | } |
| 5294 | |
| 5295 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5296 | if (!buf) { |
| 5297 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
| 5298 | cdf_mem_free(pHostOffloadParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5299 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5300 | } |
| 5301 | |
| 5302 | buf_ptr = (A_UINT8 *) wmi_buf_data(buf); |
| 5303 | cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr; |
| 5304 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5305 | WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param, |
| 5306 | WMITLV_GET_STRUCT_TLVLEN |
| 5307 | (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param)); |
| 5308 | cmd->flags = 0; |
| 5309 | cmd->vdev_id = vdev_id; |
| 5310 | if (!bArpOnly) |
| 5311 | cmd->num_ns_ext_tuples = num_ns_ext_tuples; |
| 5312 | |
| 5313 | WMA_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id); |
| 5314 | |
| 5315 | /* Have copy of arp info to send along with NS, Since FW expects |
| 5316 | * both ARP and NS info in single cmd */ |
| 5317 | if (bArpOnly) |
| 5318 | cdf_mem_copy(&wma->mArpInfo, pHostOffloadParams, |
| 5319 | sizeof(tSirHostOffloadReq)); |
| 5320 | |
| 5321 | buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param); |
| 5322 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, |
| 5323 | (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE))); |
| 5324 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 5325 | for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) { |
| 5326 | ns_tuple = (WMI_NS_OFFLOAD_TUPLE *) buf_ptr; |
| 5327 | WMITLV_SET_HDR(&ns_tuple->tlv_header, |
| 5328 | WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE, |
| 5329 | (sizeof(WMI_NS_OFFLOAD_TUPLE) - |
| 5330 | WMI_TLV_HDR_SIZE)); |
| 5331 | |
| 5332 | /* Fill data only for NS offload in the first ARP tuple for LA */ |
| 5333 | if (!bArpOnly && |
| 5334 | ((pHostOffloadParams->enableOrDisable & SIR_OFFLOAD_ENABLE))) { |
| 5335 | ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID; |
| 5336 | |
| 5337 | #ifdef WLAN_NS_OFFLOAD |
| 5338 | /*Copy the target/solicitation/remote ip addr */ |
| 5339 | if (pHostOffloadParams->nsOffloadInfo. |
| 5340 | targetIPv6AddrValid[i]) |
| 5341 | A_MEMCPY(&ns_tuple->target_ipaddr[0], |
| 5342 | &pHostOffloadParams->nsOffloadInfo. |
| 5343 | targetIPv6Addr[i], |
| 5344 | sizeof(WMI_IPV6_ADDR)); |
| 5345 | A_MEMCPY(&ns_tuple->solicitation_ipaddr, |
| 5346 | &pHostOffloadParams->nsOffloadInfo. |
| 5347 | selfIPv6Addr[i], sizeof(WMI_IPV6_ADDR)); |
| 5348 | WMA_LOGD("NS solicitedIp: %pI6, targetIp: %pI6", |
| 5349 | &pHostOffloadParams->nsOffloadInfo.selfIPv6Addr[i], |
| 5350 | &pHostOffloadParams->nsOffloadInfo. |
| 5351 | targetIPv6Addr[i]); |
| 5352 | |
| 5353 | /* target MAC is optional, check if it is valid, |
| 5354 | * if this is not valid, the target will use the known |
| 5355 | * local MAC address rather than the tuple |
| 5356 | */ |
| 5357 | WMI_CHAR_ARRAY_TO_MAC_ADDR(pHostOffloadParams-> |
Srinivas Girigowda | 110d620 | 2015-11-24 12:48:46 -0800 | [diff] [blame] | 5358 | nsOffloadInfo.self_macaddr.bytes, |
| 5359 | &ns_tuple->target_mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5360 | #endif /* WLAN_NS_OFFLOAD */ |
| 5361 | if ((ns_tuple->target_mac.mac_addr31to0 != 0) || |
| 5362 | (ns_tuple->target_mac.mac_addr47to32 != 0)) { |
| 5363 | ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID; |
| 5364 | } |
| 5365 | } |
| 5366 | buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE); |
| 5367 | } |
| 5368 | |
| 5369 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, |
| 5370 | (WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE))); |
| 5371 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 5372 | for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) { |
| 5373 | arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *) buf_ptr; |
| 5374 | WMITLV_SET_HDR(&arp_tuple->tlv_header, |
| 5375 | WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE, |
| 5376 | WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE)); |
| 5377 | |
| 5378 | /* Fill data for ARP and NS in the first tupple for LA */ |
| 5379 | if ((wma->mArpInfo.enableOrDisable & SIR_OFFLOAD_ENABLE) |
| 5380 | && (i == 0)) { |
| 5381 | /*Copy the target ip addr and flags */ |
| 5382 | arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID; |
| 5383 | A_MEMCPY(&arp_tuple->target_ipaddr, |
| 5384 | wma->mArpInfo.params.hostIpv4Addr, |
| 5385 | SIR_IPV4_ADDR_LEN); |
| 5386 | WMA_LOGD("ARPOffload IP4 address: %pI4", |
| 5387 | wma->mArpInfo.params.hostIpv4Addr); |
| 5388 | } |
| 5389 | buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE); |
| 5390 | } |
| 5391 | |
| 5392 | /* Populate extended NS offload tuples */ |
| 5393 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, |
| 5394 | (num_ns_ext_tuples*sizeof(WMI_NS_OFFLOAD_TUPLE))); |
| 5395 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 5396 | |
| 5397 | if (num_ns_ext_tuples) { |
| 5398 | for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) { |
| 5399 | ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)buf_ptr; |
| 5400 | WMITLV_SET_HDR(&ns_tuple->tlv_header, |
| 5401 | WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE, |
| 5402 | (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE)); |
| 5403 | |
| 5404 | /* Fill data only for NS offload in the first ARP tuple for LA */ |
| 5405 | if (!bArpOnly && |
| 5406 | ((pHostOffloadParams->enableOrDisable & SIR_OFFLOAD_ENABLE))) { |
| 5407 | ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID; |
| 5408 | #ifdef WLAN_NS_OFFLOAD |
| 5409 | /*Copy the target/solicitation/remote ip addr */ |
| 5410 | if (pHostOffloadParams->nsOffloadInfo.targetIPv6AddrValid[i]) |
| 5411 | A_MEMCPY(&ns_tuple->target_ipaddr[0], |
| 5412 | &pHostOffloadParams->nsOffloadInfo.targetIPv6Addr[i], |
| 5413 | sizeof(WMI_IPV6_ADDR)); |
| 5414 | A_MEMCPY(&ns_tuple->solicitation_ipaddr, |
| 5415 | &pHostOffloadParams->nsOffloadInfo.selfIPv6Addr[i], |
| 5416 | sizeof(WMI_IPV6_ADDR)); |
| 5417 | WMA_LOGD("Index %d NS solicitedIp: %pI6, targetIp: %pI6", i, |
| 5418 | &pHostOffloadParams->nsOffloadInfo.selfIPv6Addr[i], |
| 5419 | &pHostOffloadParams->nsOffloadInfo.targetIPv6Addr[i]); |
| 5420 | |
| 5421 | /* target MAC is optional, check if it is valid, if this is not valid, |
| 5422 | * the target will use the known local MAC address rather than the tuple */ |
Srinivas Girigowda | 110d620 | 2015-11-24 12:48:46 -0800 | [diff] [blame] | 5423 | WMI_CHAR_ARRAY_TO_MAC_ADDR( |
| 5424 | pHostOffloadParams->nsOffloadInfo.self_macaddr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5425 | &ns_tuple->target_mac); |
| 5426 | #endif |
| 5427 | if ((ns_tuple->target_mac.mac_addr31to0 != 0) || |
| 5428 | (ns_tuple->target_mac.mac_addr47to32 != 0)) { |
| 5429 | ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID; |
| 5430 | } |
| 5431 | } |
| 5432 | buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE); |
| 5433 | } |
| 5434 | } |
| 5435 | |
| 5436 | res = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5437 | WMI_SET_ARP_NS_OFFLOAD_CMDID); |
| 5438 | if (res) { |
| 5439 | WMA_LOGE("Failed to enable ARP NDP/NSffload"); |
| 5440 | wmi_buf_free(buf); |
| 5441 | cdf_mem_free(pHostOffloadParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5442 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5443 | } |
| 5444 | |
| 5445 | cdf_mem_free(pHostOffloadParams); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5446 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5447 | } |
| 5448 | |
| 5449 | /** |
| 5450 | * wma_process_add_periodic_tx_ptrn_ind - add periodic tx ptrn |
| 5451 | * @handle: wma handle |
| 5452 | * @pAddPeriodicTxPtrnParams: tx ptrn params |
| 5453 | * |
| 5454 | * Retrun: CDF status |
| 5455 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5456 | QDF_STATUS wma_process_add_periodic_tx_ptrn_ind(WMA_HANDLE handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5457 | tSirAddPeriodicTxPtrn * |
| 5458 | pAddPeriodicTxPtrnParams) |
| 5459 | { |
| 5460 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 5461 | WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd; |
| 5462 | wmi_buf_t wmi_buf; |
| 5463 | uint32_t len; |
| 5464 | uint8_t vdev_id; |
| 5465 | uint8_t *buf_ptr; |
| 5466 | uint32_t ptrn_len, ptrn_len_aligned; |
| 5467 | int j; |
| 5468 | |
| 5469 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 5470 | WMA_LOGE("%s: WMA is closed, can not issue fw add pattern cmd", |
| 5471 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5472 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5473 | } |
| 5474 | ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize; |
| 5475 | ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t)); |
| 5476 | len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) + |
| 5477 | WMI_TLV_HDR_SIZE + ptrn_len_aligned; |
| 5478 | |
| 5479 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 5480 | if (!wmi_buf) { |
| 5481 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5482 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5483 | } |
| 5484 | if (!wma_find_vdev_by_addr(wma_handle, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 5485 | pAddPeriodicTxPtrnParams->mac_address.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5486 | &vdev_id)) { |
| 5487 | WMA_LOGE("%s: Failed to find vdev id for %pM", __func__, |
Srinivas Girigowda | 3189655 | 2015-11-18 22:59:52 -0800 | [diff] [blame] | 5488 | pAddPeriodicTxPtrnParams->mac_address.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5489 | cdf_nbuf_free(wmi_buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5490 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5491 | } |
| 5492 | buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf); |
| 5493 | |
| 5494 | cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr; |
| 5495 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5496 | WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param, |
| 5497 | WMITLV_GET_STRUCT_TLVLEN |
| 5498 | (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param)); |
| 5499 | |
| 5500 | /* Pass the pattern id to delete for the corresponding vdev id */ |
| 5501 | cmd->vdev_id = vdev_id; |
| 5502 | cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId; |
| 5503 | cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs; |
| 5504 | cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize; |
| 5505 | |
| 5506 | /* Pattern info */ |
| 5507 | buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param); |
| 5508 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned); |
| 5509 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 5510 | cdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len); |
| 5511 | for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++) { |
| 5512 | WMA_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff); |
| 5513 | } |
| 5514 | WMA_LOGD("%s: Add ptrn id: %d vdev_id: %d", |
| 5515 | __func__, cmd->pattern_id, cmd->vdev_id); |
| 5516 | |
| 5517 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 5518 | WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) { |
| 5519 | WMA_LOGE("%s: failed to add pattern set state command", |
| 5520 | __func__); |
| 5521 | cdf_nbuf_free(wmi_buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5522 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5523 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5524 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5525 | } |
| 5526 | |
| 5527 | /** |
| 5528 | * wma_process_del_periodic_tx_ptrn_ind - del periodic tx ptrn |
| 5529 | * @handle: wma handle |
| 5530 | * @pDelPeriodicTxPtrnParams: tx ptrn params |
| 5531 | * |
| 5532 | * Retrun: CDF status |
| 5533 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5534 | QDF_STATUS wma_process_del_periodic_tx_ptrn_ind(WMA_HANDLE handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5535 | tSirDelPeriodicTxPtrn * |
| 5536 | pDelPeriodicTxPtrnParams) |
| 5537 | { |
| 5538 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 5539 | WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd; |
| 5540 | wmi_buf_t wmi_buf; |
| 5541 | uint8_t vdev_id; |
| 5542 | uint32_t len = |
| 5543 | sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param); |
| 5544 | |
| 5545 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 5546 | WMA_LOGE("%s: WMA is closed, can not issue Del Pattern cmd", |
| 5547 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5548 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5549 | } |
| 5550 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 5551 | if (!wmi_buf) { |
| 5552 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5553 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | } |
| 5555 | if (!wma_find_vdev_by_addr(wma_handle, |
Srinivas Girigowda | a5bba7a | 2015-11-18 22:44:36 -0800 | [diff] [blame] | 5556 | pDelPeriodicTxPtrnParams->mac_address.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5557 | &vdev_id)) { |
| 5558 | WMA_LOGE("%s: Failed to find vdev id for %pM", __func__, |
Srinivas Girigowda | a5bba7a | 2015-11-18 22:44:36 -0800 | [diff] [blame] | 5559 | pDelPeriodicTxPtrnParams->mac_address.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5560 | cdf_nbuf_free(wmi_buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5561 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | } |
| 5563 | cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) |
| 5564 | wmi_buf_data(wmi_buf); |
| 5565 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5566 | WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param, |
| 5567 | WMITLV_GET_STRUCT_TLVLEN |
| 5568 | (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param)); |
| 5569 | |
| 5570 | /* Pass the pattern id to delete for the corresponding vdev id */ |
| 5571 | cmd->vdev_id = vdev_id; |
| 5572 | cmd->pattern_id = pDelPeriodicTxPtrnParams->ucPtrnId; |
| 5573 | WMA_LOGD("%s: Del ptrn id: %d vdev_id: %d", |
| 5574 | __func__, cmd->pattern_id, cmd->vdev_id); |
| 5575 | |
| 5576 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 5577 | WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) { |
| 5578 | WMA_LOGE("%s: failed to send del pattern command", __func__); |
| 5579 | cdf_nbuf_free(wmi_buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5580 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5581 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5582 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5583 | } |
| 5584 | |
| 5585 | #ifdef WLAN_FEATURE_STATS_EXT |
| 5586 | /** |
| 5587 | * wma_stats_ext_req() - request ext stats from fw |
| 5588 | * @wma_ptr: wma handle |
| 5589 | * @preq: stats ext params |
| 5590 | * |
| 5591 | * Return: CDF status |
| 5592 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5593 | QDF_STATUS wma_stats_ext_req(void *wma_ptr, tpStatsExtRequest preq) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5594 | { |
| 5595 | int32_t ret; |
| 5596 | tp_wma_handle wma = (tp_wma_handle) wma_ptr; |
| 5597 | wmi_req_stats_ext_cmd_fixed_param *cmd; |
| 5598 | wmi_buf_t buf; |
| 5599 | uint16_t len; |
| 5600 | uint8_t *buf_ptr; |
| 5601 | |
| 5602 | len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len; |
| 5603 | |
| 5604 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5605 | if (!buf) { |
| 5606 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
| 5607 | return -ENOMEM; |
| 5608 | } |
| 5609 | |
| 5610 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 5611 | cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr; |
| 5612 | |
| 5613 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5614 | WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param, |
| 5615 | WMITLV_GET_STRUCT_TLVLEN |
| 5616 | (wmi_req_stats_ext_cmd_fixed_param)); |
| 5617 | cmd->vdev_id = preq->vdev_id; |
| 5618 | cmd->data_len = preq->request_data_len; |
| 5619 | |
| 5620 | WMA_LOGD("%s: The data len value is %u and vdev id set is %u ", |
| 5621 | __func__, preq->request_data_len, preq->vdev_id); |
| 5622 | |
| 5623 | buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param); |
| 5624 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len); |
| 5625 | |
| 5626 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 5627 | cdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len); |
| 5628 | |
| 5629 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5630 | WMI_REQUEST_STATS_EXT_CMDID); |
| 5631 | if (ret != EOK) { |
| 5632 | WMA_LOGE("%s: Failed to send notify cmd ret = %d", __func__, |
| 5633 | ret); |
| 5634 | wmi_buf_free(buf); |
| 5635 | } |
| 5636 | |
| 5637 | return ret; |
| 5638 | } |
| 5639 | |
| 5640 | #endif /* WLAN_FEATURE_STATS_EXT */ |
| 5641 | |
| 5642 | #ifdef WLAN_FEATURE_EXTWOW_SUPPORT |
| 5643 | /** |
| 5644 | * wma_send_status_of_ext_wow() - send ext wow status to SME |
| 5645 | * @wma: wma handle |
| 5646 | * @status: status |
| 5647 | * |
| 5648 | * Return: none |
| 5649 | */ |
| 5650 | static void wma_send_status_of_ext_wow(tp_wma_handle wma, bool status) |
| 5651 | { |
| 5652 | tSirReadyToExtWoWInd *ready_to_extwow; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5653 | QDF_STATUS vstatus; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5654 | cds_msg_t cds_msg; |
| 5655 | uint8_t len; |
| 5656 | |
| 5657 | WMA_LOGD("Posting ready to suspend indication to umac"); |
| 5658 | |
| 5659 | len = sizeof(tSirReadyToExtWoWInd); |
| 5660 | ready_to_extwow = (tSirReadyToExtWoWInd *) cdf_mem_malloc(len); |
| 5661 | |
| 5662 | if (NULL == ready_to_extwow) { |
| 5663 | WMA_LOGE("%s: Memory allocation failure", __func__); |
| 5664 | return; |
| 5665 | } |
| 5666 | |
| 5667 | ready_to_extwow->mesgType = eWNI_SME_READY_TO_EXTWOW_IND; |
| 5668 | ready_to_extwow->mesgLen = len; |
| 5669 | ready_to_extwow->status = status; |
| 5670 | |
| 5671 | cds_msg.type = eWNI_SME_READY_TO_EXTWOW_IND; |
| 5672 | cds_msg.bodyptr = (void *)ready_to_extwow; |
| 5673 | cds_msg.bodyval = 0; |
| 5674 | |
| 5675 | vstatus = cds_mq_post_message(CDS_MQ_ID_SME, &cds_msg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5676 | if (vstatus != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5677 | WMA_LOGE("Failed to post ready to suspend"); |
| 5678 | cdf_mem_free(ready_to_extwow); |
| 5679 | } |
| 5680 | } |
| 5681 | |
| 5682 | /** |
| 5683 | * wma_enable_ext_wow() - enable ext wow in fw |
| 5684 | * @wma: wma handle |
| 5685 | * @params: ext wow params |
| 5686 | * |
| 5687 | * Return:0 for success or error code |
| 5688 | */ |
| 5689 | int wma_enable_ext_wow(tp_wma_handle wma, tpSirExtWoWParams params) |
| 5690 | { |
| 5691 | wmi_extwow_enable_cmd_fixed_param *cmd; |
| 5692 | wmi_buf_t buf; |
| 5693 | int32_t len; |
| 5694 | int ret; |
| 5695 | |
| 5696 | len = sizeof(wmi_extwow_enable_cmd_fixed_param); |
| 5697 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5698 | if (!buf) { |
| 5699 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5700 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5701 | } |
| 5702 | |
| 5703 | cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf); |
| 5704 | |
| 5705 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5706 | WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param, |
| 5707 | WMITLV_GET_STRUCT_TLVLEN |
| 5708 | (wmi_extwow_enable_cmd_fixed_param)); |
| 5709 | |
| 5710 | cmd->vdev_id = params->vdev_id; |
| 5711 | cmd->type = params->type; |
| 5712 | cmd->wakeup_pin_num = params->wakeup_pin_num; |
| 5713 | |
| 5714 | WMA_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x", |
| 5715 | __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num); |
| 5716 | |
| 5717 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5718 | WMI_EXTWOW_ENABLE_CMDID); |
| 5719 | if (ret) { |
| 5720 | WMA_LOGE("%s: Failed to set EXTWOW Enable", __func__); |
| 5721 | wmi_buf_free(buf); |
| 5722 | wma_send_status_of_ext_wow(wma, false); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5723 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5724 | } |
| 5725 | |
| 5726 | wma_send_status_of_ext_wow(wma, true); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5727 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5728 | |
| 5729 | } |
| 5730 | |
| 5731 | /** |
| 5732 | * wma_set_app_type1_params_in_fw() - set app type1 params in fw |
| 5733 | * @wma: wma handle |
| 5734 | * @appType1Params: app type1 params |
| 5735 | * |
| 5736 | * Return: CDF status |
| 5737 | */ |
| 5738 | int wma_set_app_type1_params_in_fw(tp_wma_handle wma, |
| 5739 | tpSirAppType1Params appType1Params) |
| 5740 | { |
| 5741 | wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd; |
| 5742 | wmi_buf_t buf; |
| 5743 | int32_t len; |
| 5744 | int ret; |
| 5745 | |
| 5746 | len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param); |
| 5747 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5748 | if (!buf) { |
| 5749 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5750 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | } |
| 5752 | |
| 5753 | cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *) |
| 5754 | wmi_buf_data(buf); |
| 5755 | |
| 5756 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5757 | WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param, |
| 5758 | WMITLV_GET_STRUCT_TLVLEN |
| 5759 | (wmi_extwow_set_app_type1_params_cmd_fixed_param)); |
| 5760 | |
| 5761 | cmd->vdev_id = appType1Params->vdev_id; |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 5762 | WMI_CHAR_ARRAY_TO_MAC_ADDR(appType1Params->wakee_mac_addr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5763 | &cmd->wakee_mac); |
| 5764 | cdf_mem_copy(cmd->ident, appType1Params->identification_id, 8); |
| 5765 | cmd->ident_len = appType1Params->id_length; |
| 5766 | cdf_mem_copy(cmd->passwd, appType1Params->password, 16); |
| 5767 | cmd->passwd_len = appType1Params->pass_length; |
| 5768 | |
| 5769 | WMA_LOGD("%s: vdev_id %d wakee_mac_addr %pM " |
| 5770 | "identification_id %.8s id_length %u " |
| 5771 | "password %.16s pass_length %u", |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 5772 | __func__, cmd->vdev_id, appType1Params->wakee_mac_addr.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5773 | cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len); |
| 5774 | |
| 5775 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5776 | WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID); |
| 5777 | if (ret) { |
| 5778 | WMA_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__); |
| 5779 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5780 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5781 | } |
| 5782 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5783 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5784 | } |
| 5785 | |
| 5786 | /** |
| 5787 | * wma_set_app_type2_params_in_fw() - set app type2 params in fw |
| 5788 | * @wma: wma handle |
| 5789 | * @appType2Params: app type2 params |
| 5790 | * |
| 5791 | * Return: CDF status |
| 5792 | */ |
| 5793 | int wma_set_app_type2_params_in_fw(tp_wma_handle wma, |
| 5794 | tpSirAppType2Params appType2Params) |
| 5795 | { |
| 5796 | wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd; |
| 5797 | wmi_buf_t buf; |
| 5798 | int32_t len; |
| 5799 | int ret; |
| 5800 | |
| 5801 | len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param); |
| 5802 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 5803 | if (!buf) { |
| 5804 | WMA_LOGE("%s: Failed allocate wmi buffer", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5805 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5806 | } |
| 5807 | |
| 5808 | cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *) |
| 5809 | wmi_buf_data(buf); |
| 5810 | |
| 5811 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5812 | WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param, |
| 5813 | WMITLV_GET_STRUCT_TLVLEN |
| 5814 | (wmi_extwow_set_app_type2_params_cmd_fixed_param)); |
| 5815 | |
| 5816 | cmd->vdev_id = appType2Params->vdev_id; |
| 5817 | |
| 5818 | cdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16); |
| 5819 | cmd->rc4_key_len = appType2Params->rc4_key_len; |
| 5820 | |
| 5821 | cmd->ip_id = appType2Params->ip_id; |
| 5822 | cmd->ip_device_ip = appType2Params->ip_device_ip; |
| 5823 | cmd->ip_server_ip = appType2Params->ip_server_ip; |
| 5824 | |
| 5825 | cmd->tcp_src_port = appType2Params->tcp_src_port; |
| 5826 | cmd->tcp_dst_port = appType2Params->tcp_dst_port; |
| 5827 | cmd->tcp_seq = appType2Params->tcp_seq; |
| 5828 | cmd->tcp_ack_seq = appType2Params->tcp_ack_seq; |
| 5829 | |
| 5830 | cmd->keepalive_init = appType2Params->keepalive_init; |
| 5831 | cmd->keepalive_min = appType2Params->keepalive_min; |
| 5832 | cmd->keepalive_max = appType2Params->keepalive_max; |
| 5833 | cmd->keepalive_inc = appType2Params->keepalive_inc; |
| 5834 | |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 5835 | WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5836 | &cmd->gateway_mac); |
| 5837 | cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val; |
| 5838 | cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val; |
| 5839 | |
| 5840 | WMA_LOGD("%s: vdev_id %d gateway_mac %pM " |
| 5841 | "rc4_key %.16s rc4_key_len %u " |
| 5842 | "ip_id %x ip_device_ip %x ip_server_ip %x " |
| 5843 | "tcp_src_port %u tcp_dst_port %u tcp_seq %u " |
| 5844 | "tcp_ack_seq %u keepalive_init %u keepalive_min %u " |
| 5845 | "keepalive_max %u keepalive_inc %u " |
| 5846 | "tcp_tx_timeout_val %u tcp_rx_timeout_val %u", |
Srinivas Girigowda | 0420991 | 2015-11-24 12:11:13 -0800 | [diff] [blame] | 5847 | __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5848 | cmd->rc4_key, cmd->rc4_key_len, |
| 5849 | cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip, |
| 5850 | cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq, |
| 5851 | cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min, |
| 5852 | cmd->keepalive_max, cmd->keepalive_inc, |
| 5853 | cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val); |
| 5854 | |
| 5855 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 5856 | WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID); |
| 5857 | if (ret) { |
| 5858 | WMA_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__); |
| 5859 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5860 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5861 | } |
| 5862 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5863 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5864 | |
| 5865 | } |
| 5866 | #endif /* WLAN_FEATURE_EXTWOW_SUPPORT */ |
| 5867 | |
| 5868 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 5869 | /** |
| 5870 | * wma_auto_shutdown_event_handler() - process auto shutdown timer trigger |
| 5871 | * @handle: wma handle |
| 5872 | * @event: event buffer |
| 5873 | * @len: buffer length |
| 5874 | * |
| 5875 | * Return: 0 for success or error code |
| 5876 | */ |
| 5877 | int wma_auto_shutdown_event_handler(void *handle, uint8_t *event, |
| 5878 | uint32_t len) |
| 5879 | { |
| 5880 | wmi_host_auto_shutdown_event_fixed_param *wmi_auto_sh_evt; |
| 5881 | WMI_HOST_AUTO_SHUTDOWN_EVENTID_param_tlvs *param_buf = |
| 5882 | (WMI_HOST_AUTO_SHUTDOWN_EVENTID_param_tlvs *) |
| 5883 | event; |
| 5884 | |
| 5885 | if (!param_buf || !param_buf->fixed_param) { |
| 5886 | WMA_LOGE("%s:%d: Invalid Auto shutdown timer evt", __func__, |
| 5887 | __LINE__); |
| 5888 | return -EINVAL; |
| 5889 | } |
| 5890 | |
| 5891 | wmi_auto_sh_evt = param_buf->fixed_param; |
| 5892 | |
| 5893 | if (wmi_auto_sh_evt->shutdown_reason |
| 5894 | != WMI_HOST_AUTO_SHUTDOWN_REASON_TIMER_EXPIRY) { |
| 5895 | WMA_LOGE("%s:%d: Invalid Auto shutdown timer evt", __func__, |
| 5896 | __LINE__); |
| 5897 | return -EINVAL; |
| 5898 | } |
| 5899 | |
| 5900 | WMA_LOGD("%s:%d: Auto Shutdown Evt: %d", __func__, __LINE__, |
| 5901 | wmi_auto_sh_evt->shutdown_reason); |
| 5902 | return wma_post_auto_shutdown_msg(); |
| 5903 | } |
| 5904 | |
| 5905 | /** |
| 5906 | * wma_set_auto_shutdown_timer_req() - sets auto shutdown timer in firmware |
| 5907 | * @wma: wma handle |
| 5908 | * @auto_sh_cmd: auto shutdown timer value |
| 5909 | * |
| 5910 | * Return: CDF status |
| 5911 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5912 | QDF_STATUS wma_set_auto_shutdown_timer_req(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5913 | tSirAutoShutdownCmdParams * |
| 5914 | auto_sh_cmd) |
| 5915 | { |
| 5916 | int status = 0; |
| 5917 | wmi_buf_t buf = NULL; |
| 5918 | uint8_t *buf_ptr; |
| 5919 | wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd; |
| 5920 | int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param); |
| 5921 | |
| 5922 | if (auto_sh_cmd == NULL) { |
| 5923 | WMA_LOGE("%s : Invalid Autoshutdown cfg cmd", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5924 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5925 | } |
| 5926 | |
| 5927 | WMA_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d", |
| 5928 | __func__, auto_sh_cmd->timer_val); |
| 5929 | |
| 5930 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 5931 | if (!buf) { |
| 5932 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5933 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5934 | } |
| 5935 | |
| 5936 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 5937 | wmi_auto_sh_cmd = |
| 5938 | (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr; |
| 5939 | wmi_auto_sh_cmd->timer_value = auto_sh_cmd->timer_val; |
| 5940 | |
| 5941 | WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header, |
| 5942 | WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param, |
| 5943 | WMITLV_GET_STRUCT_TLVLEN |
| 5944 | (wmi_host_auto_shutdown_cfg_cmd_fixed_param)); |
| 5945 | |
| 5946 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 5947 | len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID); |
| 5948 | if (status != EOK) { |
| 5949 | WMA_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d", |
| 5950 | __func__, status); |
| 5951 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5952 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5953 | } |
| 5954 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5955 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5956 | } |
| 5957 | #endif /* FEATURE_WLAN_AUTO_SHUTDOWN */ |
| 5958 | |
| 5959 | #ifdef WLAN_FEATURE_NAN |
| 5960 | /** |
| 5961 | * wma_nan_req() - to send nan request to target |
| 5962 | * @wma: wma_handle |
| 5963 | * @nan_req: request data which will be non-null |
| 5964 | * |
| 5965 | * Return: CDF status |
| 5966 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5967 | QDF_STATUS wma_nan_req(void *wma_ptr, tpNanRequest nan_req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5968 | { |
| 5969 | int ret; |
| 5970 | tp_wma_handle wma_handle = (tp_wma_handle) wma_ptr; |
| 5971 | wmi_nan_cmd_param *cmd; |
| 5972 | wmi_buf_t buf; |
| 5973 | uint16_t len = sizeof(*cmd); |
| 5974 | uint16_t nan_data_len, nan_data_len_aligned; |
| 5975 | uint8_t *buf_ptr; |
| 5976 | |
| 5977 | /* |
| 5978 | * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ----> |
| 5979 | * +------------+----------+-----------------------+--------------+ |
| 5980 | * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data | |
| 5981 | * +------------+----------+-----------------------+--------------+ |
| 5982 | */ |
| 5983 | if (!nan_req) { |
| 5984 | WMA_LOGE("%s:nan req is not valid", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5985 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | } |
| 5987 | nan_data_len = nan_req->request_data_len; |
| 5988 | nan_data_len_aligned = roundup(nan_req->request_data_len, |
| 5989 | sizeof(uint32_t)); |
| 5990 | len += WMI_TLV_HDR_SIZE + nan_data_len_aligned; |
| 5991 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 5992 | if (!buf) { |
| 5993 | WMA_LOGE("%s:wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 5994 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5995 | } |
| 5996 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 5997 | cmd = (wmi_nan_cmd_param *) buf_ptr; |
| 5998 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 5999 | WMITLV_TAG_STRUC_wmi_nan_cmd_param, |
| 6000 | WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param)); |
| 6001 | cmd->data_len = nan_req->request_data_len; |
| 6002 | WMA_LOGD("%s: The data len value is %u", |
| 6003 | __func__, nan_req->request_data_len); |
| 6004 | buf_ptr += sizeof(wmi_nan_cmd_param); |
| 6005 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned); |
| 6006 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 6007 | cdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len); |
| 6008 | |
| 6009 | ret = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 6010 | WMI_NAN_CMDID); |
| 6011 | if (ret != EOK) { |
| 6012 | WMA_LOGE("%s Failed to send set param command ret = %d", |
| 6013 | __func__, ret); |
| 6014 | wmi_buf_free(buf); |
| 6015 | } |
| 6016 | return ret; |
| 6017 | } |
| 6018 | #endif /* WLAN_FEATURE_NAN */ |
| 6019 | |
| 6020 | #ifdef DHCP_SERVER_OFFLOAD |
| 6021 | /** |
| 6022 | * wma_process_dhcpserver_offload() - enable DHCP server offload |
| 6023 | * @wma_handle: wma handle |
| 6024 | * @pDhcpSrvOffloadInfo: DHCP server offload info |
| 6025 | * |
| 6026 | * Return: 0 for success or error code |
| 6027 | */ |
| 6028 | int wma_process_dhcpserver_offload(tp_wma_handle wma_handle, |
| 6029 | tSirDhcpSrvOffloadInfo * |
| 6030 | pDhcpSrvOffloadInfo) |
| 6031 | { |
| 6032 | wmi_set_dhcp_server_offload_cmd_fixed_param *cmd; |
| 6033 | wmi_buf_t buf; |
| 6034 | int err; |
| 6035 | |
| 6036 | buf = wmi_buf_alloc(wma_handle->wmi_handle, sizeof(*cmd)); |
| 6037 | if (!buf) { |
| 6038 | WMA_LOGE("Failed to allocate buffer to send " |
| 6039 | "set_dhcp_server_offload cmd"); |
| 6040 | return -ENOMEM; |
| 6041 | } |
| 6042 | |
| 6043 | cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf); |
| 6044 | cdf_mem_zero(cmd, sizeof(*cmd)); |
| 6045 | |
| 6046 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6047 | WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param, |
| 6048 | WMITLV_GET_STRUCT_TLVLEN |
| 6049 | (wmi_set_dhcp_server_offload_cmd_fixed_param)); |
| 6050 | cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id; |
| 6051 | cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled; |
| 6052 | cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum; |
| 6053 | cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP; |
| 6054 | cmd->start_lsb = 0; |
| 6055 | err = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 6056 | sizeof(*cmd), |
| 6057 | WMI_SET_DHCP_SERVER_OFFLOAD_CMDID); |
| 6058 | if (err) { |
| 6059 | WMA_LOGE("Failed to send set_dhcp_server_offload cmd"); |
| 6060 | wmi_buf_free(buf); |
| 6061 | return -EIO; |
| 6062 | } |
| 6063 | WMA_LOGD("Set dhcp server offload to vdevId %d", |
| 6064 | pDhcpSrvOffloadInfo->vdev_id); |
| 6065 | return 0; |
| 6066 | } |
| 6067 | #endif /* DHCP_SERVER_OFFLOAD */ |
| 6068 | |
| 6069 | #ifdef WLAN_FEATURE_GPIO_LED_FLASHING |
| 6070 | /** |
| 6071 | * wma_set_led_flashing() - set led flashing in fw |
| 6072 | * @wma_handle: wma handle |
| 6073 | * @flashing: flashing request |
| 6074 | * |
| 6075 | * Return: CDF status |
| 6076 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6077 | QDF_STATUS wma_set_led_flashing(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6078 | tSirLedFlashingReq *flashing) |
| 6079 | { |
| 6080 | wmi_set_led_flashing_cmd_fixed_param *cmd; |
| 6081 | int status = 0; |
| 6082 | wmi_buf_t buf; |
| 6083 | uint8_t *buf_ptr; |
| 6084 | int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param); |
| 6085 | |
| 6086 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 6087 | WMA_LOGE(FL("WMA is closed, can not issue cmd")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6088 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6089 | } |
| 6090 | if (!flashing) { |
| 6091 | WMA_LOGE(FL("invalid parameter: flashing")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6092 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6093 | } |
| 6094 | |
| 6095 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 6096 | if (!buf) { |
| 6097 | WMA_LOGP(FL("wmi_buf_alloc failed")); |
| 6098 | return -ENOMEM; |
| 6099 | } |
| 6100 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 6101 | cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr; |
| 6102 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6103 | WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param, |
| 6104 | WMITLV_GET_STRUCT_TLVLEN |
| 6105 | (wmi_set_led_flashing_cmd_fixed_param)); |
| 6106 | cmd->pattern_id = flashing->pattern_id; |
| 6107 | cmd->led_x0 = flashing->led_x0; |
| 6108 | cmd->led_x1 = flashing->led_x1; |
| 6109 | |
| 6110 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, len, |
| 6111 | WMI_PDEV_SET_LED_FLASHING_CMDID); |
| 6112 | if (status != EOK) { |
| 6113 | WMA_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD" |
| 6114 | " returned Error %d", __func__, status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6115 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6116 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6117 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6118 | } |
| 6119 | #endif /* WLAN_FEATURE_GPIO_LED_FLASHING */ |
| 6120 | |
| 6121 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6122 | /** |
| 6123 | * wma_channel_avoid_evt_handler() - process channel to avoid event from FW. |
| 6124 | * @handle: wma handle |
| 6125 | * @event: event buffer |
| 6126 | * @len: buffer length |
| 6127 | * |
| 6128 | * Return: 0 for success or error code |
| 6129 | */ |
| 6130 | int wma_channel_avoid_evt_handler(void *handle, uint8_t *event, |
| 6131 | uint32_t len) |
| 6132 | { |
| 6133 | wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param; |
| 6134 | wmi_avoid_freq_range_desc *afr_desc; |
| 6135 | uint32_t num_freq_ranges, freq_range_idx; |
| 6136 | tSirChAvoidIndType *sca_indication; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6137 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6138 | cds_msg_t sme_msg = { 0 }; |
| 6139 | WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf = |
| 6140 | (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) event; |
| 6141 | |
| 6142 | if (!param_buf) { |
| 6143 | WMA_LOGE("Invalid channel avoid event buffer"); |
| 6144 | return -EINVAL; |
| 6145 | } |
| 6146 | |
| 6147 | afr_fixed_param = param_buf->fixed_param; |
| 6148 | if (!afr_fixed_param) { |
| 6149 | WMA_LOGE("Invalid channel avoid event fixed param buffer"); |
| 6150 | return -EINVAL; |
| 6151 | } |
| 6152 | |
| 6153 | num_freq_ranges = |
| 6154 | (afr_fixed_param->num_freq_ranges > |
| 6155 | SIR_CH_AVOID_MAX_RANGE) ? SIR_CH_AVOID_MAX_RANGE : |
| 6156 | afr_fixed_param->num_freq_ranges; |
| 6157 | |
| 6158 | WMA_LOGD("Channel avoid event received with %d ranges", |
| 6159 | num_freq_ranges); |
| 6160 | for (freq_range_idx = 0; freq_range_idx < num_freq_ranges; |
| 6161 | freq_range_idx++) { |
| 6162 | afr_desc = (wmi_avoid_freq_range_desc *) |
| 6163 | ((void *)param_buf->avd_freq_range + |
| 6164 | freq_range_idx * sizeof(wmi_avoid_freq_range_desc)); |
| 6165 | |
| 6166 | WMA_LOGD("range %d: tlv id = %u, start freq = %u, end freq = %u", |
| 6167 | freq_range_idx, afr_desc->tlv_header, afr_desc->start_freq, |
| 6168 | afr_desc->end_freq); |
| 6169 | } |
| 6170 | |
| 6171 | sca_indication = (tSirChAvoidIndType *) |
| 6172 | cdf_mem_malloc(sizeof(tSirChAvoidIndType)); |
| 6173 | if (!sca_indication) { |
| 6174 | WMA_LOGE("Invalid channel avoid indication buffer"); |
| 6175 | return -EINVAL; |
| 6176 | } |
| 6177 | |
| 6178 | sca_indication->avoid_range_count = num_freq_ranges; |
| 6179 | for (freq_range_idx = 0; freq_range_idx < num_freq_ranges; |
| 6180 | freq_range_idx++) { |
| 6181 | afr_desc = (wmi_avoid_freq_range_desc *) |
| 6182 | ((void *)param_buf->avd_freq_range + |
| 6183 | freq_range_idx * sizeof(wmi_avoid_freq_range_desc)); |
| 6184 | sca_indication->avoid_freq_range[freq_range_idx].start_freq = |
| 6185 | afr_desc->start_freq; |
| 6186 | sca_indication->avoid_freq_range[freq_range_idx].end_freq = |
| 6187 | afr_desc->end_freq; |
| 6188 | } |
| 6189 | |
| 6190 | sme_msg.type = eWNI_SME_CH_AVOID_IND; |
| 6191 | sme_msg.bodyptr = sca_indication; |
| 6192 | sme_msg.bodyval = 0; |
| 6193 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6194 | qdf_status = cds_mq_post_message(CDF_MODULE_ID_SME, &sme_msg); |
| 6195 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | WMA_LOGE("Fail to post eWNI_SME_CH_AVOID_IND msg to SME"); |
| 6197 | cdf_mem_free(sca_indication); |
| 6198 | return -EINVAL; |
| 6199 | } |
| 6200 | |
| 6201 | return 0; |
| 6202 | } |
| 6203 | |
| 6204 | /** |
| 6205 | * wma_process_ch_avoid_update_req() - handles channel avoid update request |
| 6206 | * @wma_handle: wma handle |
| 6207 | * @ch_avoid_update_req: channel avoid update params |
| 6208 | * |
| 6209 | * Return: CDF status |
| 6210 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6211 | QDF_STATUS wma_process_ch_avoid_update_req(tp_wma_handle wma_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6212 | tSirChAvoidUpdateReq * |
| 6213 | ch_avoid_update_req) |
| 6214 | { |
| 6215 | int status = 0; |
| 6216 | wmi_buf_t buf = NULL; |
| 6217 | uint8_t *buf_ptr; |
| 6218 | wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp; |
| 6219 | int len = sizeof(wmi_chan_avoid_update_cmd_param); |
| 6220 | |
| 6221 | if (ch_avoid_update_req == NULL) { |
| 6222 | WMA_LOGE("%s : ch_avoid_update_req is NULL", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6223 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6224 | } |
| 6225 | |
| 6226 | WMA_LOGI("%s: WMA --> WMI_CHAN_AVOID_UPDATE", __func__); |
| 6227 | |
| 6228 | buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 6229 | if (!buf) { |
| 6230 | WMA_LOGE("%s : wmi_buf_alloc failed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6231 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6232 | } |
| 6233 | |
| 6234 | buf_ptr = (uint8_t *) wmi_buf_data(buf); |
| 6235 | ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr; |
| 6236 | WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header, |
| 6237 | WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param, |
| 6238 | WMITLV_GET_STRUCT_TLVLEN |
| 6239 | (wmi_chan_avoid_update_cmd_param)); |
| 6240 | |
| 6241 | status = wmi_unified_cmd_send(wma_handle->wmi_handle, buf, |
| 6242 | len, WMI_CHAN_AVOID_UPDATE_CMDID); |
| 6243 | if (status != EOK) { |
| 6244 | WMA_LOGE("wmi_unified_cmd_send" |
| 6245 | " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE" |
| 6246 | " returned Error %d", status); |
| 6247 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6248 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6249 | } |
| 6250 | |
| 6251 | WMA_LOGI("%s: WMA --> WMI_CHAN_AVOID_UPDATE sent through WMI", |
| 6252 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6253 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6254 | } |
| 6255 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 6256 | |
| 6257 | /** |
| 6258 | * wma_set_reg_domain() - set reg domain |
| 6259 | * @clientCtxt: client context |
| 6260 | * @regId: reg id |
| 6261 | * |
| 6262 | * Return: CDF status |
| 6263 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6264 | QDF_STATUS wma_set_reg_domain(void *clientCtxt, v_REGDOMAIN_t regId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6266 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | cds_set_reg_domain(clientCtxt, regId)) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6268 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6269 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6270 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6271 | } |
| 6272 | |
| 6273 | /** |
| 6274 | * wma_send_regdomain_info_to_fw() - send regdomain info to fw |
| 6275 | * @reg_dmn: reg domain |
| 6276 | * @regdmn2G: 2G reg domain |
| 6277 | * @regdmn5G: 5G reg domain |
| 6278 | * @ctl2G: 2G test limit |
| 6279 | * @ctl5G: 5G test limit |
| 6280 | * |
| 6281 | * Return: none |
| 6282 | */ |
| 6283 | void wma_send_regdomain_info_to_fw(uint32_t reg_dmn, uint16_t regdmn2G, |
| 6284 | uint16_t regdmn5G, int8_t ctl2G, |
| 6285 | int8_t ctl5G) |
| 6286 | { |
| 6287 | wmi_buf_t buf; |
| 6288 | wmi_pdev_set_regdomain_cmd_fixed_param *cmd; |
| 6289 | int32_t len = sizeof(*cmd); |
| 6290 | tp_wma_handle wma = cds_get_context(CDF_MODULE_ID_WMA); |
| 6291 | int32_t cck_mask_val = 0; |
| 6292 | int ret = 0; |
| 6293 | |
| 6294 | if (NULL == wma) { |
| 6295 | WMA_LOGE("%s: wma context is NULL", __func__); |
| 6296 | return; |
| 6297 | } |
| 6298 | |
| 6299 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 6300 | if (!buf) { |
| 6301 | WMA_LOGP("%s: wmi_buf_alloc failed", __func__); |
| 6302 | return; |
| 6303 | } |
| 6304 | cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf); |
| 6305 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6306 | WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param, |
| 6307 | WMITLV_GET_STRUCT_TLVLEN |
| 6308 | (wmi_pdev_set_regdomain_cmd_fixed_param)); |
| 6309 | cmd->reg_domain = reg_dmn; |
| 6310 | cmd->reg_domain_2G = regdmn2G; |
| 6311 | cmd->reg_domain_5G = regdmn5G; |
| 6312 | cmd->conformance_test_limit_2G = ctl2G; |
| 6313 | cmd->conformance_test_limit_5G = ctl5G; |
| 6314 | |
| 6315 | if (wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 6316 | WMI_PDEV_SET_REGDOMAIN_CMDID)) { |
| 6317 | WMA_LOGP("%s: Failed to send pdev set regdomain command", |
| 6318 | __func__); |
| 6319 | cdf_nbuf_free(buf); |
| 6320 | } |
| 6321 | |
| 6322 | if ((((reg_dmn & ~COUNTRY_ERD_FLAG) == CTRY_JAPAN) || |
| 6323 | ((reg_dmn & ~COUNTRY_ERD_FLAG) == CTRY_KOREA_ROC)) && |
| 6324 | (true == wma->tx_chain_mask_cck)) |
| 6325 | cck_mask_val = 1; |
| 6326 | |
| 6327 | cck_mask_val |= (wma->self_gen_frm_pwr << 16); |
| 6328 | ret = wmi_unified_pdev_set_param(wma->wmi_handle, |
| 6329 | WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK, |
| 6330 | cck_mask_val); |
| 6331 | if (ret) |
| 6332 | WMA_LOGE("failed to set PDEV tx_chain_mask_cck %d", |
| 6333 | ret); |
| 6334 | |
| 6335 | return; |
| 6336 | } |
| 6337 | |
| 6338 | /** |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6339 | * wma_post_runtime_resume_msg() - post the resume request |
| 6340 | * @handle: validated wma handle |
| 6341 | * |
| 6342 | * request the MC thread unpaus the vdev and set resume dtim |
| 6343 | * |
| 6344 | * Return: cdf status of the mq post |
| 6345 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6346 | static QDF_STATUS wma_post_runtime_resume_msg(WMA_HANDLE handle) |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6347 | { |
| 6348 | cds_msg_t resume_msg; |
| 6349 | |
| 6350 | resume_msg.bodyptr = NULL; |
| 6351 | resume_msg.type = WMA_RUNTIME_PM_RESUME_IND; |
| 6352 | return cds_mq_post_message(CDF_MODULE_ID_WMA, &resume_msg); |
| 6353 | } |
| 6354 | |
| 6355 | /** |
| 6356 | * wma_post_runtime_suspend_msg() - post the suspend request |
| 6357 | * @handle: validated wma handle |
| 6358 | * |
| 6359 | * Requests for offloads to be configured for runtime suspend |
| 6360 | * on the MC thread |
| 6361 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6362 | * Return QDF_STATUS_E_AGAIN in case of timeout or QDF_STATUS_SUCCESS |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6363 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6364 | static QDF_STATUS wma_post_runtime_suspend_msg(WMA_HANDLE handle) |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6365 | { |
| 6366 | cds_msg_t cds_msg; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6367 | QDF_STATUS qdf_status; |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6368 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 6369 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6370 | qdf_event_reset(&wma->runtime_suspend); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6371 | |
| 6372 | cds_msg.bodyptr = NULL; |
| 6373 | cds_msg.type = WMA_RUNTIME_PM_SUSPEND_IND; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6374 | qdf_status = cds_mq_post_message(CDF_MODULE_ID_WMA, &cds_msg); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6375 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6376 | if (qdf_status != QDF_STATUS_SUCCESS) |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6377 | goto failure; |
| 6378 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6379 | if (qdf_wait_single_event(&wma->runtime_suspend, |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6380 | WMA_TGT_SUSPEND_COMPLETE_TIMEOUT) != |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6381 | QDF_STATUS_SUCCESS) { |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6382 | WMA_LOGE("Failed to get runtime suspend event"); |
| 6383 | goto failure; |
| 6384 | } |
| 6385 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6386 | return QDF_STATUS_SUCCESS; |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6387 | |
| 6388 | failure: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6389 | return QDF_STATUS_E_AGAIN; |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | /** |
| 6393 | * __wma_bus_suspend(): handles bus suspend for wma |
| 6394 | * @type: is this suspend part of runtime suspend or system suspend? |
| 6395 | * |
| 6396 | * Bails if a scan is in progress. |
| 6397 | * Calls the appropriate handlers based on configuration and event. |
| 6398 | * |
| 6399 | * Return: 0 for success or error code |
| 6400 | */ |
| 6401 | static int __wma_bus_suspend(enum cdf_suspend_type type) |
| 6402 | { |
| 6403 | WMA_HANDLE handle = cds_get_context(CDF_MODULE_ID_WMA); |
| 6404 | if (NULL == handle) { |
| 6405 | WMA_LOGE("%s: wma context is NULL", __func__); |
| 6406 | return -EFAULT; |
| 6407 | } |
| 6408 | |
| 6409 | if (wma_check_scan_in_progress(handle)) { |
| 6410 | WMA_LOGE("%s: Scan in progress. Aborting suspend", __func__); |
| 6411 | return -EBUSY; |
| 6412 | } |
| 6413 | |
| 6414 | if (type == CDF_RUNTIME_SUSPEND) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6415 | QDF_STATUS status = wma_post_runtime_suspend_msg(handle); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6416 | if (status) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6417 | return qdf_status_to_os_return(status); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6418 | } |
| 6419 | |
| 6420 | if (type == CDF_SYSTEM_SUSPEND) |
| 6421 | WMA_LOGE("%s: wow mode selected %d", __func__, |
| 6422 | wma_is_wow_mode_selected(handle)); |
| 6423 | |
| 6424 | if (wma_is_wow_mode_selected(handle)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6425 | QDF_STATUS status = wma_enable_wow_in_fw(handle); |
| 6426 | return qdf_status_to_os_return(status); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6427 | } |
| 6428 | |
| 6429 | return wma_suspend_target(handle, 0); |
| 6430 | } |
| 6431 | |
| 6432 | /** |
| 6433 | * wma_runtime_suspend() - handles runtime suspend request from hdd |
| 6434 | * |
| 6435 | * Calls the appropriate handler based on configuration and event. |
| 6436 | * Last busy marking should prevent race conditions between processing |
| 6437 | * of asyncronous fw events and the running of runtime suspend. |
| 6438 | * (eg. last busy marking should guarantee that any auth requests have |
| 6439 | * been processed) |
| 6440 | * Events comming from the host are not protected, but aren't expected |
| 6441 | * to be an issue. |
| 6442 | * |
| 6443 | * Return: 0 for success or error code |
| 6444 | */ |
| 6445 | int wma_runtime_suspend(void) |
| 6446 | { |
| 6447 | return __wma_bus_suspend(CDF_RUNTIME_SUSPEND); |
| 6448 | } |
| 6449 | |
| 6450 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6451 | * wma_bus_suspend() - handles bus suspend request from hdd |
| 6452 | * |
| 6453 | * Calls the appropriate handler based on configuration and event |
| 6454 | * |
| 6455 | * Return: 0 for success or error code |
| 6456 | */ |
| 6457 | int wma_bus_suspend(void) |
| 6458 | { |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6459 | |
Houston Hoffman | 103f39b | 2016-02-01 17:35:44 -0800 | [diff] [blame] | 6460 | return __wma_bus_suspend(CDF_SYSTEM_SUSPEND); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6461 | } |
| 6462 | |
| 6463 | /** |
| 6464 | * __wma_bus_resume() - bus resume for wma |
| 6465 | * |
| 6466 | * does the part of the bus resume common to bus and system suspend |
| 6467 | * |
| 6468 | * Return: os error code. |
| 6469 | */ |
| 6470 | int __wma_bus_resume(WMA_HANDLE handle) |
| 6471 | { |
| 6472 | bool wow_mode = wma_is_wow_mode_selected(handle); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6473 | QDF_STATUS status; |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6474 | |
| 6475 | WMA_LOGE("%s: wow mode %d", __func__, wow_mode); |
| 6476 | |
| 6477 | if (!wow_mode) |
| 6478 | return wma_resume_target(handle); |
| 6479 | |
| 6480 | status = wma_disable_wow_in_fw(handle); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6481 | return qdf_status_to_os_return(status); |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6482 | } |
| 6483 | |
| 6484 | /** |
| 6485 | * wma_runtime_resume() - do the runtime resume operation for wma |
| 6486 | * |
| 6487 | * Return: os error code. |
| 6488 | */ |
| 6489 | int wma_runtime_resume(void) |
| 6490 | { |
| 6491 | int ret; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6492 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6493 | WMA_HANDLE handle = cds_get_context(CDF_MODULE_ID_WMA); |
| 6494 | if (NULL == handle) { |
| 6495 | WMA_LOGE("%s: wma context is NULL", __func__); |
| 6496 | return -EFAULT; |
| 6497 | } |
| 6498 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6499 | ret = __wma_bus_resume(handle); |
| 6500 | if (ret) |
| 6501 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6502 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6503 | status = wma_post_runtime_resume_msg(handle); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6504 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6505 | } |
| 6506 | |
| 6507 | /** |
| 6508 | * wma_bus_resume() - handles bus resume request from hdd |
| 6509 | * @handle: valid wma handle |
| 6510 | * |
| 6511 | * Calls the appropriate handler based on configuration |
| 6512 | * |
| 6513 | * Return: 0 for success or error code |
| 6514 | */ |
| 6515 | int wma_bus_resume(void) |
| 6516 | { |
| 6517 | WMA_HANDLE handle = cds_get_context(CDF_MODULE_ID_WMA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6518 | if (NULL == handle) { |
| 6519 | WMA_LOGE("%s: wma context is NULL", __func__); |
| 6520 | return -EFAULT; |
| 6521 | } |
| 6522 | |
Houston Hoffman | a76591b | 2015-11-10 16:52:05 -0800 | [diff] [blame] | 6523 | return __wma_bus_resume(handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6524 | } |
| 6525 | |
| 6526 | /** |
| 6527 | * wma_suspend_target() - suspend target |
| 6528 | * @handle: wma handle |
| 6529 | * @disable_target_intr: disable target interrupt |
| 6530 | * |
| 6531 | * Return: 0 for success or error code |
| 6532 | */ |
| 6533 | int wma_suspend_target(WMA_HANDLE handle, int disable_target_intr) |
| 6534 | { |
| 6535 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 6536 | wmi_pdev_suspend_cmd_fixed_param *cmd; |
| 6537 | wmi_buf_t wmibuf; |
| 6538 | uint32_t len = sizeof(*cmd); |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 6539 | struct hif_opaque_softc *scn; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | int ret; |
Yue Ma | e1a85f3 | 2015-10-20 18:12:45 -0700 | [diff] [blame] | 6541 | #ifdef CONFIG_CNSS |
| 6542 | tpAniSirGlobal pmac = cds_get_context(CDF_MODULE_ID_PE); |
| 6543 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6544 | |
| 6545 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 6546 | WMA_LOGE("WMA is closed. can not issue suspend cmd"); |
| 6547 | return -EINVAL; |
| 6548 | } |
Yue Ma | e1a85f3 | 2015-10-20 18:12:45 -0700 | [diff] [blame] | 6549 | |
| 6550 | #ifdef CONFIG_CNSS |
| 6551 | if (NULL == pmac) { |
| 6552 | WMA_LOGE("%s: Unable to get PE context", __func__); |
| 6553 | return -EINVAL; |
| 6554 | } |
| 6555 | #endif |
| 6556 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6557 | /* |
| 6558 | * send the comand to Target to ignore the |
| 6559 | * PCIE reset so as to ensure that Host and target |
| 6560 | * states are in sync |
| 6561 | */ |
| 6562 | wmibuf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 6563 | if (wmibuf == NULL) |
| 6564 | return -ENOMEM; |
| 6565 | |
| 6566 | cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf); |
| 6567 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6568 | WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param, |
| 6569 | WMITLV_GET_STRUCT_TLVLEN |
| 6570 | (wmi_pdev_suspend_cmd_fixed_param)); |
| 6571 | if (disable_target_intr) { |
| 6572 | cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR; |
| 6573 | } else { |
| 6574 | cmd->suspend_opt = WMI_PDEV_SUSPEND; |
| 6575 | } |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6576 | qdf_event_reset(&wma_handle->target_suspend); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6577 | ret = wmi_unified_cmd_send(wma_handle->wmi_handle, wmibuf, len, |
| 6578 | WMI_PDEV_SUSPEND_CMDID); |
| 6579 | if (ret < 0) { |
| 6580 | cdf_nbuf_free(wmibuf); |
| 6581 | return ret; |
| 6582 | } |
| 6583 | |
| 6584 | wmi_set_target_suspend(wma_handle->wmi_handle, true); |
| 6585 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6586 | if (qdf_wait_single_event(&wma_handle->target_suspend, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6587 | WMA_TGT_SUSPEND_COMPLETE_TIMEOUT) |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6588 | != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6589 | WMA_LOGE("Failed to get ACK from firmware for pdev suspend"); |
| 6590 | wmi_set_target_suspend(wma_handle->wmi_handle, false); |
Yue Ma | e1a85f3 | 2015-10-20 18:12:45 -0700 | [diff] [blame] | 6591 | #ifdef CONFIG_CNSS |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 6592 | if (!cds_is_driver_recovering()) { |
Yue Ma | 455aff6 | 2015-10-20 18:29:16 -0700 | [diff] [blame] | 6593 | if (pmac->sme.enableSelfRecovery) { |
| 6594 | cds_trigger_recovery(); |
| 6595 | } else { |
| 6596 | CDF_BUG(0); |
| 6597 | } |
Yue Ma | e1a85f3 | 2015-10-20 18:12:45 -0700 | [diff] [blame] | 6598 | } else { |
Yue Ma | 455aff6 | 2015-10-20 18:29:16 -0700 | [diff] [blame] | 6599 | WMA_LOGE("%s: LOGP is in progress, ignore!", __func__); |
Yue Ma | e1a85f3 | 2015-10-20 18:12:45 -0700 | [diff] [blame] | 6600 | } |
| 6601 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | return -EFAULT; |
| 6603 | } |
| 6604 | |
| 6605 | scn = cds_get_context(CDF_MODULE_ID_HIF); |
| 6606 | |
| 6607 | if (scn == NULL) { |
| 6608 | WMA_LOGE("%s: Failed to get HIF context", __func__); |
| 6609 | CDF_ASSERT(0); |
| 6610 | return -EFAULT; |
| 6611 | } |
| 6612 | |
| 6613 | htc_cancel_deferred_target_sleep(scn); |
| 6614 | |
| 6615 | return 0; |
| 6616 | } |
| 6617 | |
| 6618 | /** |
| 6619 | * wma_target_suspend_acknowledge() - update target susspend status |
| 6620 | * @context: wma context |
| 6621 | * |
| 6622 | * Return: none |
| 6623 | */ |
| 6624 | void wma_target_suspend_acknowledge(void *context) |
| 6625 | { |
| 6626 | tp_wma_handle wma = cds_get_context(CDF_MODULE_ID_WMA); |
| 6627 | int wow_nack = *((int *)context); |
| 6628 | |
| 6629 | if (NULL == wma) { |
| 6630 | WMA_LOGE("%s: wma is NULL", __func__); |
| 6631 | return; |
| 6632 | } |
| 6633 | |
| 6634 | wma->wow_nack = wow_nack; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6635 | qdf_event_set(&wma->target_suspend); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | if (wow_nack) |
| 6637 | cdf_wake_lock_timeout_acquire(&wma->wow_wake_lock, |
| 6638 | WMA_WAKE_LOCK_TIMEOUT, |
| 6639 | WIFI_POWER_EVENT_WAKELOCK_WOW); |
| 6640 | } |
| 6641 | |
| 6642 | /** |
| 6643 | * wma_resume_target() - resume target |
| 6644 | * @handle: wma handle |
| 6645 | * |
| 6646 | * Return: 0 for success or error code |
| 6647 | */ |
| 6648 | int wma_resume_target(WMA_HANDLE handle) |
| 6649 | { |
| 6650 | int ret; |
| 6651 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 6652 | wmi_buf_t wmibuf; |
| 6653 | wmi_pdev_resume_cmd_fixed_param *cmd; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6654 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6655 | #ifdef CONFIG_CNSS |
| 6656 | tpAniSirGlobal pMac = cds_get_context(CDF_MODULE_ID_PE); |
| 6657 | if (NULL == pMac) { |
| 6658 | WMA_LOGE("%s: Unable to get PE context", __func__); |
| 6659 | return -EINVAL; |
| 6660 | } |
| 6661 | #endif /* CONFIG_CNSS */ |
| 6662 | |
| 6663 | wmibuf = wmi_buf_alloc(wma->wmi_handle, sizeof(*cmd)); |
| 6664 | if (wmibuf == NULL) { |
| 6665 | return -ENOMEM; |
| 6666 | } |
| 6667 | cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf); |
| 6668 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6669 | WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param, |
| 6670 | WMITLV_GET_STRUCT_TLVLEN |
| 6671 | (wmi_pdev_resume_cmd_fixed_param)); |
| 6672 | cmd->reserved0 = 0; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6673 | qdf_event_reset(&wma->wma_resume_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6674 | ret = wmi_unified_cmd_send(wma->wmi_handle, wmibuf, sizeof(*cmd), |
| 6675 | WMI_PDEV_RESUME_CMDID); |
| 6676 | if (ret != EOK) { |
| 6677 | WMA_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command"); |
| 6678 | wmi_buf_free(wmibuf); |
| 6679 | } |
| 6680 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6681 | qdf_status = qdf_wait_single_event(&(wma->wma_resume_event), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6682 | WMA_RESUME_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 6683 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6684 | WMA_LOGP("%s: Timeout waiting for resume event from FW", |
| 6685 | __func__); |
| 6686 | WMA_LOGP("%s: Pending commands %d credits %d", __func__, |
| 6687 | wmi_get_pending_cmds(wma->wmi_handle), |
| 6688 | wmi_get_host_credits(wma->wmi_handle)); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 6689 | if (!cds_is_driver_recovering()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6690 | #ifdef CONFIG_CNSS |
| 6691 | if (pMac->sme.enableSelfRecovery) { |
| 6692 | cds_trigger_recovery(); |
| 6693 | } else { |
| 6694 | CDF_BUG(0); |
| 6695 | } |
| 6696 | #else |
| 6697 | CDF_BUG(0); |
| 6698 | #endif /* CONFIG_CNSS */ |
| 6699 | } else { |
| 6700 | WMA_LOGE("%s: SSR in progress, ignore resume timeout", |
| 6701 | __func__); |
| 6702 | } |
| 6703 | } else { |
| 6704 | WMA_LOGD("Host wakeup received"); |
| 6705 | } |
| 6706 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 6707 | if (QDF_STATUS_SUCCESS == qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6708 | wmi_set_target_suspend(wma->wmi_handle, false); |
| 6709 | |
| 6710 | return ret; |
| 6711 | } |
| 6712 | |
| 6713 | /** |
| 6714 | * wma_get_modeselect() - get modeSelect flag based on phy_capability |
| 6715 | * @wma: wma handle |
| 6716 | * @modeSelect: mode Select |
| 6717 | * |
| 6718 | * Return: none |
| 6719 | */ |
| 6720 | void wma_get_modeselect(tp_wma_handle wma, uint32_t *modeSelect) |
| 6721 | { |
| 6722 | |
| 6723 | switch (wma->phy_capability) { |
| 6724 | case WMI_11G_CAPABILITY: |
| 6725 | case WMI_11NG_CAPABILITY: |
| 6726 | *modeSelect &= ~(REGDMN_MODE_11A | REGDMN_MODE_TURBO | |
| 6727 | REGDMN_MODE_108A | REGDMN_MODE_11A_HALF_RATE | |
| 6728 | REGDMN_MODE_11A_QUARTER_RATE | |
| 6729 | REGDMN_MODE_11NA_HT20 | |
| 6730 | REGDMN_MODE_11NA_HT40PLUS | |
| 6731 | REGDMN_MODE_11NA_HT40MINUS | |
| 6732 | REGDMN_MODE_11AC_VHT20 | |
| 6733 | REGDMN_MODE_11AC_VHT40PLUS | |
| 6734 | REGDMN_MODE_11AC_VHT40MINUS | |
| 6735 | REGDMN_MODE_11AC_VHT80); |
| 6736 | break; |
| 6737 | case WMI_11A_CAPABILITY: |
| 6738 | case WMI_11NA_CAPABILITY: |
| 6739 | case WMI_11AC_CAPABILITY: |
| 6740 | *modeSelect &= ~(REGDMN_MODE_11B | REGDMN_MODE_11G | |
| 6741 | REGDMN_MODE_108G | REGDMN_MODE_11NG_HT20 | |
| 6742 | REGDMN_MODE_11NG_HT40PLUS | |
| 6743 | REGDMN_MODE_11NG_HT40MINUS | |
| 6744 | REGDMN_MODE_11AC_VHT20_2G | |
| 6745 | REGDMN_MODE_11AC_VHT40_2G | |
| 6746 | REGDMN_MODE_11AC_VHT80_2G); |
| 6747 | break; |
| 6748 | } |
| 6749 | } |
| 6750 | |
| 6751 | |
| 6752 | #ifdef FEATURE_WLAN_TDLS |
| 6753 | /** |
| 6754 | * wma_tdls_event_handler() - handle TDLS event |
| 6755 | * @handle: wma handle |
| 6756 | * @event: event buffer |
| 6757 | * @len: buffer length |
| 6758 | * |
| 6759 | * Return: 0 for success or error code |
| 6760 | */ |
| 6761 | int wma_tdls_event_handler(void *handle, uint8_t *event, uint32_t len) |
| 6762 | { |
| 6763 | tp_wma_handle wma = (tp_wma_handle) handle; |
| 6764 | WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf = NULL; |
| 6765 | wmi_tdls_peer_event_fixed_param *peer_event = NULL; |
| 6766 | tSirTdlsEventnotify *tdls_event; |
| 6767 | |
| 6768 | if (!event) { |
| 6769 | WMA_LOGE("%s: event param null", __func__); |
| 6770 | return -EINVAL; |
| 6771 | } |
| 6772 | |
| 6773 | param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *) event; |
| 6774 | if (!param_buf) { |
| 6775 | WMA_LOGE("%s: received null buf from target", __func__); |
| 6776 | return -EINVAL; |
| 6777 | } |
| 6778 | |
| 6779 | peer_event = param_buf->fixed_param; |
| 6780 | if (!peer_event) { |
| 6781 | WMA_LOGE("%s: received null event data from target", __func__); |
| 6782 | return -EINVAL; |
| 6783 | } |
| 6784 | |
| 6785 | tdls_event = (tSirTdlsEventnotify *) |
| 6786 | cdf_mem_malloc(sizeof(*tdls_event)); |
| 6787 | if (!tdls_event) { |
| 6788 | WMA_LOGE("%s: failed to allocate memory for tdls_event", |
| 6789 | __func__); |
| 6790 | return -ENOMEM; |
| 6791 | } |
| 6792 | |
| 6793 | tdls_event->sessionId = peer_event->vdev_id; |
| 6794 | WMI_MAC_ADDR_TO_CHAR_ARRAY(&peer_event->peer_macaddr, |
Srinivas Girigowda | 4f59379 | 2015-11-19 15:33:42 -0800 | [diff] [blame] | 6795 | tdls_event->peermac.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6796 | |
| 6797 | switch (peer_event->peer_status) { |
| 6798 | case WMI_TDLS_SHOULD_DISCOVER: |
| 6799 | tdls_event->messageType = WMA_TDLS_SHOULD_DISCOVER_CMD; |
| 6800 | break; |
| 6801 | case WMI_TDLS_SHOULD_TEARDOWN: |
| 6802 | tdls_event->messageType = WMA_TDLS_SHOULD_TEARDOWN_CMD; |
| 6803 | break; |
| 6804 | case WMI_TDLS_PEER_DISCONNECTED: |
| 6805 | tdls_event->messageType = WMA_TDLS_PEER_DISCONNECTED_CMD; |
| 6806 | break; |
| 6807 | default: |
| 6808 | WMA_LOGE("%s: Discarding unknown tdls event(%d) from target", |
| 6809 | __func__, peer_event->peer_status); |
| 6810 | return -EINVAL; |
| 6811 | } |
| 6812 | |
| 6813 | switch (peer_event->peer_reason) { |
| 6814 | case WMI_TDLS_TEARDOWN_REASON_TX: |
| 6815 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_TX; |
| 6816 | break; |
| 6817 | case WMI_TDLS_TEARDOWN_REASON_RSSI: |
| 6818 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_RSSI; |
| 6819 | break; |
| 6820 | case WMI_TDLS_TEARDOWN_REASON_SCAN: |
| 6821 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_SCAN; |
| 6822 | break; |
| 6823 | case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE: |
| 6824 | tdls_event->peer_reason = |
| 6825 | eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE; |
| 6826 | break; |
| 6827 | case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT: |
| 6828 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT; |
| 6829 | break; |
| 6830 | case WMI_TDLS_TEARDOWN_REASON_BAD_PTR: |
| 6831 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_BAD_PTR; |
| 6832 | break; |
| 6833 | case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE: |
| 6834 | tdls_event->peer_reason = eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE; |
| 6835 | break; |
| 6836 | default: |
| 6837 | WMA_LOGE("%s: unknown reason(%d) in tdls event(%d) from target", |
| 6838 | __func__, peer_event->peer_reason, |
| 6839 | peer_event->peer_status); |
| 6840 | return -EINVAL; |
| 6841 | } |
| 6842 | |
| 6843 | WMA_LOGD("%s: sending msg to umac, messageType: 0x%x, " |
| 6844 | "for peer: %pM, reason: %d, smesessionId: %d", |
Srinivas Girigowda | 4f59379 | 2015-11-19 15:33:42 -0800 | [diff] [blame] | 6845 | __func__, tdls_event->messageType, tdls_event->peermac.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6846 | tdls_event->peer_reason, tdls_event->sessionId); |
| 6847 | |
| 6848 | wma_send_msg(wma, tdls_event->messageType, (void *)tdls_event, 0); |
| 6849 | return 0; |
| 6850 | } |
| 6851 | |
| 6852 | /** |
| 6853 | * wma_set_tdls_offchan_mode() - set tdls off channel mode |
| 6854 | * @handle: wma handle |
| 6855 | * @chan_switch_params: Pointer to tdls channel switch parameter structure |
| 6856 | * |
| 6857 | * This function sets tdls off channel mode |
| 6858 | * |
| 6859 | * Return: 0 on success; Negative errno otherwise |
| 6860 | */ |
| 6861 | int wma_set_tdls_offchan_mode(WMA_HANDLE handle, |
| 6862 | tdls_chan_switch_params *chan_switch_params) |
| 6863 | { |
| 6864 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 6865 | wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd; |
| 6866 | wmi_buf_t wmi_buf; |
| 6867 | u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param); |
| 6868 | int ret = 0; |
| 6869 | |
| 6870 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 6871 | WMA_LOGE(FL( |
| 6872 | "WMA is closed, can not issue tdls off channel cmd" |
| 6873 | )); |
| 6874 | ret = -EINVAL; |
| 6875 | goto end; |
| 6876 | } |
| 6877 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 6878 | if (!wmi_buf) { |
| 6879 | WMA_LOGE(FL("wmi_buf_alloc failed")); |
| 6880 | ret = -ENOMEM; |
| 6881 | goto end; |
| 6882 | } |
| 6883 | cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *) |
| 6884 | wmi_buf_data(wmi_buf); |
| 6885 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6886 | WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param, |
| 6887 | WMITLV_GET_STRUCT_TLVLEN( |
| 6888 | wmi_tdls_set_offchan_mode_cmd_fixed_param)); |
| 6889 | |
| 6890 | WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr, |
| 6891 | &cmd->peer_macaddr); |
| 6892 | cmd->vdev_id = chan_switch_params->vdev_id; |
| 6893 | cmd->offchan_mode = chan_switch_params->tdls_sw_mode; |
| 6894 | cmd->is_peer_responder = chan_switch_params->is_responder; |
| 6895 | cmd->offchan_num = chan_switch_params->tdls_off_ch; |
| 6896 | cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset; |
| 6897 | cmd->offchan_oper_class = chan_switch_params->oper_class; |
| 6898 | |
| 6899 | WMA_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"), |
| 6900 | cmd->peer_macaddr.mac_addr31to0, |
| 6901 | cmd->peer_macaddr.mac_addr47to32); |
| 6902 | |
| 6903 | WMA_LOGD(FL( |
| 6904 | "vdev_id: %d, off channel mode: %d, off channel Num: %d, off channel offset: 0x%x, is_peer_responder: %d, operating class: %d" |
| 6905 | ), |
| 6906 | cmd->vdev_id, |
| 6907 | cmd->offchan_mode, |
| 6908 | cmd->offchan_num, |
| 6909 | cmd->offchan_bw_bitmap, |
| 6910 | cmd->is_peer_responder, |
| 6911 | cmd->offchan_oper_class); |
| 6912 | |
| 6913 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 6914 | WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) { |
| 6915 | WMA_LOGP(FL("failed to send tdls off chan command")); |
| 6916 | cdf_nbuf_free(wmi_buf); |
| 6917 | ret = -EIO; |
| 6918 | } |
| 6919 | |
| 6920 | end: |
| 6921 | if (chan_switch_params) |
| 6922 | cdf_mem_free(chan_switch_params); |
| 6923 | return ret; |
| 6924 | } |
| 6925 | |
| 6926 | /** |
| 6927 | * wma_update_fw_tdls_state() - send enable/disable tdls for a vdev |
| 6928 | * @wma: wma handle |
| 6929 | * @pwmaTdlsparams: TDLS params |
| 6930 | * |
| 6931 | * Return: 0 for sucess or error code |
| 6932 | */ |
| 6933 | int wma_update_fw_tdls_state(WMA_HANDLE handle, void *pwmaTdlsparams) |
| 6934 | { |
| 6935 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 6936 | wmi_tdls_set_state_cmd_fixed_param *cmd; |
| 6937 | wmi_buf_t wmi_buf; |
| 6938 | t_wma_tdls_mode tdls_mode; |
| 6939 | t_wma_tdls_params *wma_tdls = (t_wma_tdls_params *) pwmaTdlsparams; |
| 6940 | uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param); |
| 6941 | int ret = 0; |
| 6942 | |
| 6943 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 6944 | WMA_LOGE("%s: WMA is closed, can not issue fw tdls state cmd", |
| 6945 | __func__); |
| 6946 | ret = -EINVAL; |
| 6947 | goto end_fw_tdls_state; |
| 6948 | } |
| 6949 | |
| 6950 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 6951 | if (!wmi_buf) { |
| 6952 | WMA_LOGE("%s: wmai_buf_alloc failed", __func__); |
| 6953 | ret = ENOMEM; |
| 6954 | goto end_fw_tdls_state; |
| 6955 | } |
| 6956 | tdls_mode = wma_tdls->tdls_state; |
| 6957 | cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf); |
| 6958 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 6959 | WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param, |
| 6960 | WMITLV_GET_STRUCT_TLVLEN |
| 6961 | (wmi_tdls_set_state_cmd_fixed_param)); |
| 6962 | cmd->vdev_id = wma_tdls->vdev_id; |
| 6963 | |
| 6964 | if (WMA_TDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY == tdls_mode) { |
| 6965 | cmd->state = WMI_TDLS_ENABLE_PASSIVE; |
| 6966 | } else if (WMA_TDLS_SUPPORT_ENABLED == tdls_mode) { |
| 6967 | cmd->state = WMI_TDLS_ENABLE_ACTIVE; |
Kabilan Kannan | 421714b | 2015-11-23 04:44:59 -0800 | [diff] [blame] | 6968 | } else if (WMA_TDLS_SUPPORT_ACTIVE_EXTERNAL_CONTROL == tdls_mode) { |
| 6969 | cmd->state = WMI_TDLS_ENABLE_ACTIVE_EXTERNAL_CONTROL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6970 | } else { |
| 6971 | cmd->state = WMI_TDLS_DISABLE; |
| 6972 | } |
| 6973 | |
| 6974 | cmd->notification_interval_ms = wma_tdls->notification_interval_ms; |
| 6975 | cmd->tx_discovery_threshold = wma_tdls->tx_discovery_threshold; |
| 6976 | cmd->tx_teardown_threshold = wma_tdls->tx_teardown_threshold; |
| 6977 | cmd->rssi_teardown_threshold = wma_tdls->rssi_teardown_threshold; |
| 6978 | cmd->rssi_delta = wma_tdls->rssi_delta; |
| 6979 | cmd->tdls_options = wma_tdls->tdls_options; |
| 6980 | cmd->tdls_peer_traffic_ind_window = wma_tdls->peer_traffic_ind_window; |
| 6981 | cmd->tdls_peer_traffic_response_timeout_ms = |
| 6982 | wma_tdls->peer_traffic_response_timeout; |
| 6983 | cmd->tdls_puapsd_mask = wma_tdls->puapsd_mask; |
| 6984 | cmd->tdls_puapsd_inactivity_time_ms = wma_tdls->puapsd_inactivity_time; |
| 6985 | cmd->tdls_puapsd_rx_frame_threshold = |
| 6986 | wma_tdls->puapsd_rx_frame_threshold; |
Kabilan Kannan | ca670be | 2015-11-23 01:56:12 -0800 | [diff] [blame] | 6987 | cmd->teardown_notification_ms = |
| 6988 | wma_tdls->teardown_notification_ms; |
Kabilan Kannan | 421714b | 2015-11-23 04:44:59 -0800 | [diff] [blame] | 6989 | cmd->tdls_peer_kickout_threshold = |
| 6990 | wma_tdls->tdls_peer_kickout_threshold; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6991 | |
| 6992 | WMA_LOGD("%s: tdls_mode: %d, state: %d, " |
| 6993 | "notification_interval_ms: %d, " |
| 6994 | "tx_discovery_threshold: %d, " |
| 6995 | "tx_teardown_threshold: %d, " |
| 6996 | "rssi_teardown_threshold: %d, " |
| 6997 | "rssi_delta: %d, " |
| 6998 | "tdls_options: 0x%x, " |
| 6999 | "tdls_peer_traffic_ind_window: %d, " |
| 7000 | "tdls_peer_traffic_response_timeout: %d, " |
| 7001 | "tdls_puapsd_mask: 0x%x, " |
| 7002 | "tdls_puapsd_inactivity_time: %d, " |
Kabilan Kannan | ca670be | 2015-11-23 01:56:12 -0800 | [diff] [blame] | 7003 | "tdls_puapsd_rx_frame_threshold: %d, " |
Kabilan Kannan | 421714b | 2015-11-23 04:44:59 -0800 | [diff] [blame] | 7004 | "teardown_notification_ms: %d, " |
| 7005 | "tdls_peer_kickout_threshold: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7006 | __func__, tdls_mode, cmd->state, |
| 7007 | cmd->notification_interval_ms, |
| 7008 | cmd->tx_discovery_threshold, |
| 7009 | cmd->tx_teardown_threshold, |
| 7010 | cmd->rssi_teardown_threshold, |
| 7011 | cmd->rssi_delta, |
| 7012 | cmd->tdls_options, |
| 7013 | cmd->tdls_peer_traffic_ind_window, |
| 7014 | cmd->tdls_peer_traffic_response_timeout_ms, |
| 7015 | cmd->tdls_puapsd_mask, |
| 7016 | cmd->tdls_puapsd_inactivity_time_ms, |
Kabilan Kannan | ca670be | 2015-11-23 01:56:12 -0800 | [diff] [blame] | 7017 | cmd->tdls_puapsd_rx_frame_threshold, |
Kabilan Kannan | 421714b | 2015-11-23 04:44:59 -0800 | [diff] [blame] | 7018 | cmd->teardown_notification_ms, |
| 7019 | cmd->tdls_peer_kickout_threshold); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7020 | |
| 7021 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 7022 | WMI_TDLS_SET_STATE_CMDID)) { |
| 7023 | WMA_LOGP("%s: failed to send tdls set state command", __func__); |
| 7024 | cdf_nbuf_free(wmi_buf); |
| 7025 | ret = -EIO; |
| 7026 | goto end_fw_tdls_state; |
| 7027 | } |
| 7028 | WMA_LOGD("%s: vdev_id %d", __func__, wma_tdls->vdev_id); |
| 7029 | |
| 7030 | end_fw_tdls_state: |
| 7031 | if (pwmaTdlsparams) |
| 7032 | cdf_mem_free(pwmaTdlsparams); |
| 7033 | return ret; |
| 7034 | } |
| 7035 | |
| 7036 | /** |
| 7037 | * wma_update_tdls_peer_state() - update TDLS peer state |
| 7038 | * @handle: wma handle |
| 7039 | * @peerStateParams: TDLS peer state params |
| 7040 | * |
| 7041 | * Return: 0 for success or error code |
| 7042 | */ |
| 7043 | int wma_update_tdls_peer_state(WMA_HANDLE handle, |
| 7044 | tTdlsPeerStateParams *peerStateParams) |
| 7045 | { |
| 7046 | tp_wma_handle wma_handle = (tp_wma_handle) handle; |
| 7047 | wmi_tdls_peer_update_cmd_fixed_param *cmd; |
| 7048 | wmi_tdls_peer_capabilities *peer_cap; |
| 7049 | wmi_channel *chan_info; |
| 7050 | wmi_buf_t wmi_buf; |
| 7051 | uint8_t *buf_ptr; |
| 7052 | uint32_t i; |
| 7053 | ol_txrx_pdev_handle pdev; |
| 7054 | uint8_t peer_id; |
| 7055 | struct ol_txrx_peer_t *peer; |
| 7056 | int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) + |
| 7057 | sizeof(wmi_tdls_peer_capabilities); |
| 7058 | int ret = 0; |
| 7059 | |
| 7060 | if (!wma_handle || !wma_handle->wmi_handle) { |
| 7061 | WMA_LOGE("%s: WMA is closed, can not issue cmd", __func__); |
| 7062 | ret = -EINVAL; |
| 7063 | goto end_tdls_peer_state; |
| 7064 | } |
| 7065 | |
| 7066 | /* peer capability info is valid only when peer state is connected */ |
| 7067 | if (WMA_TDLS_PEER_STATE_CONNECTED != peerStateParams->peerState) { |
| 7068 | cdf_mem_zero(&peerStateParams->peerCap, |
| 7069 | sizeof(tTdlsPeerCapParams)); |
| 7070 | } |
| 7071 | |
| 7072 | len += WMI_TLV_HDR_SIZE + |
| 7073 | sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen; |
| 7074 | |
| 7075 | wmi_buf = wmi_buf_alloc(wma_handle->wmi_handle, len); |
| 7076 | if (!wmi_buf) { |
| 7077 | WMA_LOGE("%s: wmi_buf_alloc failed", __func__); |
| 7078 | ret = ENOMEM; |
| 7079 | goto end_tdls_peer_state; |
| 7080 | } |
| 7081 | |
| 7082 | buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf); |
| 7083 | cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr; |
| 7084 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 7085 | WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param, |
| 7086 | WMITLV_GET_STRUCT_TLVLEN |
| 7087 | (wmi_tdls_peer_update_cmd_fixed_param)); |
| 7088 | |
| 7089 | cmd->vdev_id = peerStateParams->vdevId; |
| 7090 | WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr, |
| 7091 | &cmd->peer_macaddr); |
| 7092 | |
| 7093 | switch (peerStateParams->peerState) { |
| 7094 | case WMA_TDLS_PEER_STATE_PEERING: |
| 7095 | cmd->peer_state = WMI_TDLS_PEER_STATE_PEERING; |
| 7096 | break; |
| 7097 | case WMA_TDLS_PEER_STATE_CONNECTED: |
| 7098 | cmd->peer_state = WMI_TDLS_PEER_STATE_CONNECTED; |
| 7099 | break; |
| 7100 | case WMA_TDLS_PEER_STATE_TEARDOWN: |
| 7101 | cmd->peer_state = WMI_TDLS_PEER_STATE_TEARDOWN; |
| 7102 | break; |
Kabilan Kannan | 421714b | 2015-11-23 04:44:59 -0800 | [diff] [blame] | 7103 | case WMA_TDLS_PEER_ADD_MAC_ADDR: |
| 7104 | cmd->peer_state = WMI_TDLS_PEER_ADD_MAC_ADDR; |
| 7105 | break; |
| 7106 | case WMA_TDLS_PEER_REMOVE_MAC_ADDR: |
| 7107 | cmd->peer_state = WMI_TDLS_PEER_REMOVE_MAC_ADDR; |
| 7108 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | } |
| 7110 | |
| 7111 | WMA_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, " |
| 7112 | "peer_macaddr.mac_addr31to0: 0x%x, " |
| 7113 | "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d", |
| 7114 | __func__, cmd->vdev_id, peerStateParams->peerMacAddr, |
| 7115 | cmd->peer_macaddr.mac_addr31to0, |
| 7116 | cmd->peer_macaddr.mac_addr47to32, cmd->peer_state); |
| 7117 | |
| 7118 | buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param); |
| 7119 | peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr; |
| 7120 | WMITLV_SET_HDR(&peer_cap->tlv_header, |
| 7121 | WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities, |
| 7122 | WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities)); |
| 7123 | |
| 7124 | if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3) |
| 7125 | WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap); |
| 7126 | if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2) |
| 7127 | WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap); |
| 7128 | if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1) |
| 7129 | WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap); |
| 7130 | if (peerStateParams->peerCap.peerUapsdQueue & 0x01) |
| 7131 | WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap); |
| 7132 | |
| 7133 | /* Ack and More Data Ack are sent as 0, so no need to set |
| 7134 | * but fill SP |
| 7135 | */ |
| 7136 | WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap, |
| 7137 | peerStateParams->peerCap.peerMaxSp); |
| 7138 | |
| 7139 | peer_cap->buff_sta_support = |
| 7140 | peerStateParams->peerCap.peerBuffStaSupport; |
| 7141 | peer_cap->off_chan_support = |
| 7142 | peerStateParams->peerCap.peerOffChanSupport; |
| 7143 | peer_cap->peer_curr_operclass = |
| 7144 | peerStateParams->peerCap.peerCurrOperClass; |
| 7145 | /* self curr operclass is not being used and so pass op class for |
| 7146 | * preferred off chan in it. |
| 7147 | */ |
| 7148 | peer_cap->self_curr_operclass = |
| 7149 | peerStateParams->peerCap.opClassForPrefOffChan; |
| 7150 | peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen; |
| 7151 | peer_cap->peer_operclass_len = |
| 7152 | peerStateParams->peerCap.peerOperClassLen; |
| 7153 | |
| 7154 | WMA_LOGD("%s: peer_operclass_len: %d", |
| 7155 | __func__, peer_cap->peer_operclass_len); |
| 7156 | for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) { |
| 7157 | peer_cap->peer_operclass[i] = |
| 7158 | peerStateParams->peerCap.peerOperClass[i]; |
| 7159 | WMA_LOGD("%s: peer_operclass[%d]: %d", |
| 7160 | __func__, i, peer_cap->peer_operclass[i]); |
| 7161 | } |
| 7162 | |
| 7163 | peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder; |
| 7164 | peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum; |
| 7165 | peer_cap->pref_offchan_bw = |
| 7166 | peerStateParams->peerCap.prefOffChanBandwidth; |
| 7167 | |
| 7168 | WMA_LOGD |
| 7169 | ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: %d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num: %d, pref_offchan_bw: %d", |
| 7170 | __func__, peer_cap->peer_qos, peer_cap->buff_sta_support, |
| 7171 | peer_cap->off_chan_support, peer_cap->peer_curr_operclass, |
| 7172 | peer_cap->self_curr_operclass, peer_cap->peer_chan_len, |
| 7173 | peer_cap->peer_operclass_len, peer_cap->is_peer_responder, |
| 7174 | peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw); |
| 7175 | |
| 7176 | /* next fill variable size array of peer chan info */ |
| 7177 | buf_ptr += sizeof(wmi_tdls_peer_capabilities); |
| 7178 | WMITLV_SET_HDR(buf_ptr, |
| 7179 | WMITLV_TAG_ARRAY_STRUC, |
| 7180 | sizeof(wmi_channel) * |
| 7181 | peerStateParams->peerCap.peerChanLen); |
| 7182 | chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE); |
| 7183 | |
| 7184 | for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) { |
| 7185 | WMITLV_SET_HDR(&chan_info->tlv_header, |
| 7186 | WMITLV_TAG_STRUC_wmi_channel, |
| 7187 | WMITLV_GET_STRUCT_TLVLEN(wmi_channel)); |
| 7188 | chan_info->mhz = |
| 7189 | cds_chan_to_freq(peerStateParams->peerCap.peerChan[i]. |
| 7190 | chanId); |
| 7191 | chan_info->band_center_freq1 = chan_info->mhz; |
| 7192 | chan_info->band_center_freq2 = 0; |
| 7193 | |
| 7194 | WMA_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz); |
| 7195 | |
| 7196 | if (peerStateParams->peerCap.peerChan[i].dfsSet) { |
| 7197 | WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE); |
| 7198 | WMA_LOGI("chan[%d] DFS[%d]\n", |
| 7199 | peerStateParams->peerCap.peerChan[i].chanId, |
| 7200 | peerStateParams->peerCap.peerChan[i].dfsSet); |
| 7201 | } |
| 7202 | |
| 7203 | if (chan_info->mhz < WMA_2_4_GHZ_MAX_FREQ) { |
| 7204 | WMI_SET_CHANNEL_MODE(chan_info, MODE_11G); |
| 7205 | } else { |
| 7206 | WMI_SET_CHANNEL_MODE(chan_info, MODE_11A); |
| 7207 | } |
| 7208 | |
| 7209 | WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, |
| 7210 | peerStateParams->peerCap. |
| 7211 | peerChan[i].pwr); |
| 7212 | |
| 7213 | WMI_SET_CHANNEL_REG_POWER(chan_info, |
| 7214 | peerStateParams->peerCap.peerChan[i]. |
| 7215 | pwr); |
| 7216 | WMA_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz, |
| 7217 | peerStateParams->peerCap.peerChan[i].pwr); |
| 7218 | |
| 7219 | chan_info++; |
| 7220 | } |
| 7221 | |
| 7222 | if (wmi_unified_cmd_send(wma_handle->wmi_handle, wmi_buf, len, |
| 7223 | WMI_TDLS_PEER_UPDATE_CMDID)) { |
| 7224 | WMA_LOGE("%s: failed to send tdls peer update state command", |
| 7225 | __func__); |
| 7226 | cdf_nbuf_free(wmi_buf); |
| 7227 | ret = -EIO; |
| 7228 | goto end_tdls_peer_state; |
| 7229 | } |
| 7230 | |
| 7231 | /* in case of teardown, remove peer from fw */ |
| 7232 | if (WMA_TDLS_PEER_STATE_TEARDOWN == peerStateParams->peerState) { |
| 7233 | pdev = cds_get_context(CDF_MODULE_ID_TXRX); |
| 7234 | if (!pdev) { |
| 7235 | WMA_LOGE("%s: Failed to find pdev", __func__); |
| 7236 | ret = -EIO; |
| 7237 | goto end_tdls_peer_state; |
| 7238 | } |
| 7239 | |
| 7240 | peer = ol_txrx_find_peer_by_addr(pdev, |
| 7241 | peerStateParams->peerMacAddr, |
| 7242 | &peer_id); |
| 7243 | if (!peer) { |
| 7244 | WMA_LOGE("%s: Failed to get peer handle using peer mac %pM", |
| 7245 | __func__, peerStateParams->peerMacAddr); |
| 7246 | ret = -EIO; |
| 7247 | goto end_tdls_peer_state; |
| 7248 | } |
| 7249 | |
| 7250 | WMA_LOGD("%s: calling wma_remove_peer for peer " MAC_ADDRESS_STR |
| 7251 | " vdevId: %d", __func__, |
| 7252 | MAC_ADDR_ARRAY(peer->mac_addr.raw), |
| 7253 | peerStateParams->vdevId); |
| 7254 | wma_remove_peer(wma_handle, peer->mac_addr.raw, |
| 7255 | peerStateParams->vdevId, peer, false); |
| 7256 | } |
| 7257 | |
| 7258 | end_tdls_peer_state: |
| 7259 | if (peerStateParams) |
| 7260 | cdf_mem_free(peerStateParams); |
| 7261 | return ret; |
| 7262 | } |
| 7263 | #endif /* FEATURE_WLAN_TDLS */ |
| 7264 | |
| 7265 | |
| 7266 | /** |
| 7267 | * wma_dfs_attach() - Attach DFS methods to the umac state. |
| 7268 | * @dfs_ic: ieee80211com ptr |
| 7269 | * |
| 7270 | * Return: Return ieee80211com ptr with updated info |
| 7271 | */ |
| 7272 | struct ieee80211com *wma_dfs_attach(struct ieee80211com *dfs_ic) |
| 7273 | { |
| 7274 | /*Allocate memory for dfs_ic before passing it up to dfs_attach() */ |
| 7275 | dfs_ic = (struct ieee80211com *) |
| 7276 | os_malloc(NULL, sizeof(struct ieee80211com), GFP_ATOMIC); |
| 7277 | if (dfs_ic == NULL) { |
| 7278 | WMA_LOGE("%s:Allocation of dfs_ic failed %zu", |
| 7279 | __func__, sizeof(struct ieee80211com)); |
| 7280 | return NULL; |
| 7281 | } |
| 7282 | OS_MEMZERO(dfs_ic, sizeof(struct ieee80211com)); |
| 7283 | /* DFS pattern matching hooks */ |
| 7284 | dfs_ic->ic_dfs_attach = ol_if_dfs_attach; |
| 7285 | dfs_ic->ic_dfs_disable = ol_if_dfs_disable; |
| 7286 | dfs_ic->ic_find_channel = ieee80211_find_channel; |
| 7287 | dfs_ic->ic_dfs_enable = ol_if_dfs_enable; |
| 7288 | dfs_ic->ic_ieee2mhz = ieee80211_ieee2mhz; |
| 7289 | |
| 7290 | /* Hardware facing hooks */ |
| 7291 | dfs_ic->ic_get_ext_busy = ol_if_dfs_get_ext_busy; |
| 7292 | dfs_ic->ic_get_mib_cycle_counts_pct = |
| 7293 | ol_if_dfs_get_mib_cycle_counts_pct; |
| 7294 | dfs_ic->ic_get_TSF64 = ol_if_get_tsf64; |
| 7295 | |
| 7296 | /* NOL related hooks */ |
| 7297 | dfs_ic->ic_dfs_usenol = ol_if_dfs_usenol; |
| 7298 | /* |
| 7299 | * Hooks from wma/dfs/ back |
| 7300 | * into the PE/SME |
| 7301 | * and shared DFS code |
| 7302 | */ |
| 7303 | dfs_ic->ic_dfs_notify_radar = ieee80211_mark_dfs; |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7304 | cdf_spinlock_init(&dfs_ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7305 | /* Initializes DFS Data Structures and queues */ |
| 7306 | dfs_attach(dfs_ic); |
| 7307 | |
| 7308 | return dfs_ic; |
| 7309 | } |
| 7310 | |
| 7311 | /** |
| 7312 | * wma_dfs_detach() - Detach DFS methods |
| 7313 | * @dfs_ic: ieee80211com ptr |
| 7314 | * |
| 7315 | * Return: none |
| 7316 | */ |
| 7317 | void wma_dfs_detach(struct ieee80211com *dfs_ic) |
| 7318 | { |
| 7319 | dfs_detach(dfs_ic); |
| 7320 | |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7321 | cdf_spinlock_destroy(&dfs_ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7322 | if (NULL != dfs_ic->ic_curchan) { |
| 7323 | OS_FREE(dfs_ic->ic_curchan); |
| 7324 | dfs_ic->ic_curchan = NULL; |
| 7325 | } |
| 7326 | |
| 7327 | OS_FREE(dfs_ic); |
| 7328 | } |
| 7329 | |
| 7330 | /** |
| 7331 | * wma_dfs_configure() - configure dfs |
| 7332 | * @ic: ieee80211com ptr |
| 7333 | * |
| 7334 | * Configures Radar Filters during |
| 7335 | * vdev start/channel change/regulatory domain |
| 7336 | * change.This Configuration enables to program |
| 7337 | * the DFS pattern matching module. |
| 7338 | * |
| 7339 | * Return: none |
| 7340 | */ |
| 7341 | void wma_dfs_configure(struct ieee80211com *ic) |
| 7342 | { |
| 7343 | struct ath_dfs_radar_tab_info rinfo; |
| 7344 | int dfsdomain; |
| 7345 | int radar_enabled_status = 0; |
| 7346 | if (ic == NULL) { |
| 7347 | WMA_LOGE("%s: DFS ic is Invalid", __func__); |
| 7348 | return; |
| 7349 | } |
| 7350 | |
| 7351 | dfsdomain = ic->current_dfs_regdomain; |
| 7352 | |
| 7353 | /* Fetch current radar patterns from the lmac */ |
| 7354 | OS_MEMZERO(&rinfo, sizeof(rinfo)); |
| 7355 | |
| 7356 | /* |
| 7357 | * Look up the current DFS |
| 7358 | * regulatory domain and decide |
| 7359 | * which radar pulses to use. |
| 7360 | */ |
| 7361 | switch (dfsdomain) { |
| 7362 | case DFS_FCC_DOMAIN: |
| 7363 | WMA_LOGI("%s: DFS-FCC domain", __func__); |
| 7364 | rinfo.dfsdomain = DFS_FCC_DOMAIN; |
| 7365 | rinfo.dfs_radars = dfs_fcc_radars; |
| 7366 | rinfo.numradars = CDF_ARRAY_SIZE(dfs_fcc_radars); |
| 7367 | rinfo.b5pulses = dfs_fcc_bin5pulses; |
| 7368 | rinfo.numb5radars = CDF_ARRAY_SIZE(dfs_fcc_bin5pulses); |
| 7369 | break; |
| 7370 | case DFS_ETSI_DOMAIN: |
| 7371 | WMA_LOGI("%s: DFS-ETSI domain", __func__); |
| 7372 | rinfo.dfsdomain = DFS_ETSI_DOMAIN; |
| 7373 | rinfo.dfs_radars = dfs_etsi_radars; |
| 7374 | rinfo.numradars = CDF_ARRAY_SIZE(dfs_etsi_radars); |
| 7375 | rinfo.b5pulses = NULL; |
| 7376 | rinfo.numb5radars = 0; |
| 7377 | break; |
| 7378 | case DFS_MKK4_DOMAIN: |
| 7379 | WMA_LOGI("%s: DFS-MKK4 domain", __func__); |
| 7380 | rinfo.dfsdomain = DFS_MKK4_DOMAIN; |
| 7381 | rinfo.dfs_radars = dfs_mkk4_radars; |
| 7382 | rinfo.numradars = CDF_ARRAY_SIZE(dfs_mkk4_radars); |
| 7383 | rinfo.b5pulses = dfs_jpn_bin5pulses; |
| 7384 | rinfo.numb5radars = CDF_ARRAY_SIZE(dfs_jpn_bin5pulses); |
| 7385 | break; |
| 7386 | default: |
| 7387 | WMA_LOGI("%s: DFS-UNINT domain", __func__); |
| 7388 | rinfo.dfsdomain = DFS_UNINIT_DOMAIN; |
| 7389 | rinfo.dfs_radars = NULL; |
| 7390 | rinfo.numradars = 0; |
| 7391 | rinfo.b5pulses = NULL; |
| 7392 | rinfo.numb5radars = 0; |
| 7393 | break; |
| 7394 | } |
| 7395 | |
| 7396 | rinfo.dfs_pri_multiplier = ic->dfs_pri_multiplier; |
| 7397 | |
| 7398 | /* |
| 7399 | * Set the regulatory domain, |
| 7400 | * radar pulse table and enable |
| 7401 | * radar events if required. |
| 7402 | * dfs_radar_enable() returns |
| 7403 | * 0 on success and non-zero |
| 7404 | * failure. |
| 7405 | */ |
| 7406 | radar_enabled_status = dfs_radar_enable(ic, &rinfo); |
| 7407 | if (radar_enabled_status != DFS_STATUS_SUCCESS) { |
| 7408 | WMA_LOGE("%s[%d]: DFS- Radar Detection Enabling Failed", |
| 7409 | __func__, __LINE__); |
| 7410 | } |
| 7411 | } |
| 7412 | |
| 7413 | /** |
| 7414 | * wma_dfs_configure_channel() - configure DFS channel |
| 7415 | * @dfs_ic: ieee80211com ptr |
| 7416 | * @chan: wmi channel |
| 7417 | * @chanmode: channel mode |
| 7418 | * @ req: vdev start request |
| 7419 | * |
| 7420 | * Set the Channel parameters in to DFS module |
| 7421 | * Also,configure the DFS radar filters for |
| 7422 | * matching the DFS phyerrors. |
| 7423 | * |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7424 | * Return: dfs_ieee80211_channel / NULL for error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7425 | */ |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7426 | struct dfs_ieee80211_channel *wma_dfs_configure_channel( |
| 7427 | struct ieee80211com *dfs_ic, |
| 7428 | wmi_channel *chan, |
| 7429 | WLAN_PHY_MODE chanmode, |
| 7430 | struct wma_vdev_start_req |
| 7431 | *req) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7432 | { |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7433 | uint8_t ext_channel; |
| 7434 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | if (dfs_ic == NULL) { |
| 7436 | WMA_LOGE("%s: DFS ic is Invalid", __func__); |
| 7437 | return NULL; |
| 7438 | } |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7439 | |
| 7440 | if (!dfs_ic->ic_curchan) { |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7441 | dfs_ic->ic_curchan = (struct dfs_ieee80211_channel *)os_malloc( |
| 7442 | NULL, |
| 7443 | sizeof(struct dfs_ieee80211_channel), |
| 7444 | GFP_ATOMIC); |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7445 | if (dfs_ic->ic_curchan == NULL) { |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7446 | WMA_LOGE( |
| 7447 | "%s: allocation of dfs_ic->ic_curchan failed %zu", |
| 7448 | __func__, sizeof(struct dfs_ieee80211_channel)); |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7449 | return NULL; |
| 7450 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7451 | } |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7452 | |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7453 | OS_MEMZERO(dfs_ic->ic_curchan, sizeof(struct dfs_ieee80211_channel)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7454 | |
| 7455 | dfs_ic->ic_curchan->ic_ieee = req->chan; |
| 7456 | dfs_ic->ic_curchan->ic_freq = chan->mhz; |
| 7457 | dfs_ic->ic_curchan->ic_vhtop_ch_freq_seg1 = chan->band_center_freq1; |
| 7458 | dfs_ic->ic_curchan->ic_vhtop_ch_freq_seg2 = chan->band_center_freq2; |
| 7459 | dfs_ic->ic_curchan->ic_pri_freq_center_freq_mhz_separation = |
| 7460 | dfs_ic->ic_curchan->ic_freq - |
| 7461 | dfs_ic->ic_curchan->ic_vhtop_ch_freq_seg1; |
| 7462 | |
| 7463 | if ((dfs_ic->ic_curchan->ic_ieee >= WMA_11A_CHANNEL_BEGIN) && |
| 7464 | (dfs_ic->ic_curchan->ic_ieee <= WMA_11A_CHANNEL_END)) { |
| 7465 | dfs_ic->ic_curchan->ic_flags |= IEEE80211_CHAN_5GHZ; |
| 7466 | } |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7467 | |
| 7468 | switch (req->chan_width) { |
| 7469 | case CH_WIDTH_20MHZ: |
| 7470 | dfs_ic->ic_curchan->ic_flags |= |
| 7471 | (req->vht_capable ? IEEE80211_CHAN_VHT20 : |
| 7472 | IEEE80211_CHAN_HT20); |
| 7473 | break; |
| 7474 | case CH_WIDTH_40MHZ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7475 | if (req->chan < req->ch_center_freq_seg0) |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7476 | dfs_ic->ic_curchan->ic_flags |= |
| 7477 | (req->vht_capable ? |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7478 | IEEE80211_CHAN_VHT40PLUS : |
| 7479 | IEEE80211_CHAN_HT40PLUS); |
| 7480 | else |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7481 | dfs_ic->ic_curchan->ic_flags |= |
| 7482 | (req->vht_capable ? |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7483 | IEEE80211_CHAN_VHT40MINUS : |
| 7484 | IEEE80211_CHAN_HT40MINUS); |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7485 | break; |
| 7486 | case CH_WIDTH_80MHZ: |
| 7487 | dfs_ic->ic_curchan->ic_flags |= IEEE80211_CHAN_VHT80; |
| 7488 | break; |
| 7489 | case CH_WIDTH_80P80MHZ: |
| 7490 | ext_channel = cds_freq_to_chan(chan->band_center_freq2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7491 | dfs_ic->ic_curchan->ic_flags |= |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7492 | IEEE80211_CHAN_VHT80P80; |
| 7493 | dfs_ic->ic_curchan->ic_freq_ext = |
| 7494 | chan->band_center_freq2; |
| 7495 | dfs_ic->ic_curchan->ic_ieee_ext = ext_channel; |
| 7496 | |
| 7497 | /* verify both the 80MHz are DFS bands or not */ |
| 7498 | if ((CHANNEL_STATE_DFS == |
| 7499 | cds_get_bonded_channel_state(req->chan , |
| 7500 | CH_WIDTH_80MHZ)) && |
| 7501 | (CHANNEL_STATE_DFS == |
| 7502 | cds_get_bonded_channel_state( |
| 7503 | ext_channel - 6 , |
| 7504 | CH_WIDTH_80MHZ))) |
| 7505 | dfs_ic->ic_curchan->ic_80p80_both_dfs = true; |
| 7506 | break; |
| 7507 | case CH_WIDTH_160MHZ: |
| 7508 | dfs_ic->ic_curchan->ic_flags |= |
| 7509 | IEEE80211_CHAN_VHT160; |
| 7510 | break; |
| 7511 | default: |
| 7512 | WMA_LOGE( |
| 7513 | "%s: Recieved a wrong channel width %d", |
| 7514 | __func__, req->chan_width); |
| 7515 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7516 | } |
Sandeep Puligilla | e2c9a95 | 2015-12-14 16:37:38 -0800 | [diff] [blame] | 7517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7518 | dfs_ic->ic_curchan->ic_flagext |= IEEE80211_CHAN_DFS; |
| 7519 | |
| 7520 | if (req->oper_mode == BSS_OPERATIONAL_MODE_AP) { |
| 7521 | dfs_ic->ic_opmode = IEEE80211_M_HOSTAP; |
| 7522 | dfs_ic->vdev_id = req->vdev_id; |
| 7523 | } |
| 7524 | |
| 7525 | dfs_ic->dfs_pri_multiplier = req->dfs_pri_multiplier; |
| 7526 | |
| 7527 | /* |
| 7528 | * Configuring the DFS with current channel and the radar filters |
| 7529 | */ |
| 7530 | wma_dfs_configure(dfs_ic); |
| 7531 | WMA_LOGI("%s: DFS- CHANNEL CONFIGURED", __func__); |
| 7532 | return dfs_ic->ic_curchan; |
| 7533 | } |
| 7534 | |
| 7535 | |
| 7536 | /** |
| 7537 | * wma_set_dfs_region() - set DFS region |
| 7538 | * @wma: wma handle |
| 7539 | * |
| 7540 | * Configure the DFS region for DFS radar filter initialization |
| 7541 | * |
| 7542 | * Return: none |
| 7543 | */ |
| 7544 | void wma_set_dfs_region(tp_wma_handle wma, uint8_t dfs_region) |
| 7545 | { |
| 7546 | /* dfs information is passed */ |
| 7547 | if (dfs_region > DFS_MKK4_DOMAIN || dfs_region == DFS_UNINIT_DOMAIN) |
| 7548 | /* assign DFS_FCC_DOMAIN as default domain*/ |
| 7549 | wma->dfs_ic->current_dfs_regdomain = DFS_FCC_DOMAIN; |
| 7550 | else |
| 7551 | wma->dfs_ic->current_dfs_regdomain = dfs_region; |
| 7552 | |
| 7553 | WMA_LOGI("%s: DFS Region Domain: %d", __func__, |
| 7554 | wma->dfs_ic->current_dfs_regdomain); |
| 7555 | } |
| 7556 | |
| 7557 | /** |
| 7558 | * wma_get_channels() - prepare dfs radar channel list |
| 7559 | * @ichan: channel |
| 7560 | * @chan_list: return channel list |
| 7561 | * |
| 7562 | * Return: return number of channels |
| 7563 | */ |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7564 | int wma_get_channels(struct dfs_ieee80211_channel *ichan, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7565 | struct wma_dfs_radar_channel_list *chan_list) |
| 7566 | { |
| 7567 | uint8_t center_chan = cds_freq_to_chan(ichan->ic_vhtop_ch_freq_seg1); |
| 7568 | |
| 7569 | chan_list->nchannels = 0; |
| 7570 | |
| 7571 | if (IEEE80211_IS_CHAN_11AC_VHT80(ichan)) { |
| 7572 | chan_list->nchannels = 4; |
| 7573 | chan_list->channels[0] = center_chan - 6; |
| 7574 | chan_list->channels[1] = center_chan - 2; |
| 7575 | chan_list->channels[2] = center_chan + 2; |
| 7576 | chan_list->channels[3] = center_chan + 6; |
| 7577 | } else if (IEEE80211_IS_CHAN_11N_HT40(ichan) || |
| 7578 | IEEE80211_IS_CHAN_11AC_VHT40(ichan)) { |
| 7579 | chan_list->nchannels = 2; |
| 7580 | chan_list->channels[0] = center_chan - 2; |
| 7581 | chan_list->channels[1] = center_chan + 2; |
| 7582 | } else { |
| 7583 | chan_list->nchannels = 1; |
| 7584 | chan_list->channels[0] = center_chan; |
| 7585 | } |
| 7586 | |
| 7587 | return chan_list->nchannels; |
| 7588 | } |
| 7589 | |
| 7590 | |
| 7591 | /** |
| 7592 | * wma_dfs_indicate_radar() - Indicate Radar to SAP/HDD |
| 7593 | * @ic: ieee80211com ptr |
| 7594 | * @ichan: ieee 80211 channel |
| 7595 | * |
| 7596 | * Return: 0 for success or error code |
| 7597 | */ |
| 7598 | int wma_dfs_indicate_radar(struct ieee80211com *ic, |
Chandrasekaran, Manishekar | 22a7e1e | 2015-11-05 10:38:49 +0530 | [diff] [blame] | 7599 | struct dfs_ieee80211_channel *ichan) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | { |
| 7601 | tp_wma_handle wma; |
| 7602 | void *hdd_ctx; |
| 7603 | struct wma_dfs_radar_indication *radar_event; |
| 7604 | struct wma_dfs_radar_ind wma_radar_event; |
| 7605 | tpAniSirGlobal pmac = NULL; |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 7606 | bool indication_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | |
| 7608 | wma = cds_get_context(CDF_MODULE_ID_WMA); |
| 7609 | if (wma == NULL) { |
| 7610 | WMA_LOGE("%s: DFS- Invalid wma", __func__); |
| 7611 | return -ENOENT; |
| 7612 | } |
| 7613 | |
| 7614 | hdd_ctx = cds_get_context(CDF_MODULE_ID_HDD); |
| 7615 | pmac = (tpAniSirGlobal) |
| 7616 | cds_get_context(CDF_MODULE_ID_PE); |
| 7617 | |
| 7618 | if (!pmac) { |
| 7619 | WMA_LOGE("%s: Invalid MAC handle", __func__); |
| 7620 | return -ENOENT; |
| 7621 | } |
| 7622 | |
| 7623 | if (wma->dfs_ic != ic) { |
| 7624 | WMA_LOGE("%s:DFS- Invalid WMA handle", __func__); |
| 7625 | return -ENOENT; |
| 7626 | } |
| 7627 | radar_event = (struct wma_dfs_radar_indication *) |
| 7628 | cdf_mem_malloc(sizeof(struct wma_dfs_radar_indication)); |
| 7629 | if (radar_event == NULL) { |
| 7630 | WMA_LOGE("%s:DFS- Invalid radar_event", __func__); |
| 7631 | return -ENOMEM; |
| 7632 | } |
| 7633 | |
| 7634 | /* |
| 7635 | * Do not post multiple Radar events on the same channel. |
| 7636 | * But, when DFS test mode is enabled, allow multiple dfs |
| 7637 | * radar events to be posted on the same channel. |
| 7638 | */ |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7639 | cdf_spin_lock_bh(&ic->chan_lock); |
Edhar, Mahesh Kumar | 35d9b2e | 2015-10-26 17:06:23 +0530 | [diff] [blame] | 7640 | if (!pmac->sap.SapDfsInfo.disable_dfs_ch_switch) |
| 7641 | wma->dfs_ic->disable_phy_err_processing = true; |
| 7642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7643 | if ((ichan->ic_ieee != (wma->dfs_ic->last_radar_found_chan)) || |
| 7644 | (pmac->sap.SapDfsInfo.disable_dfs_ch_switch == true)) { |
| 7645 | wma->dfs_ic->last_radar_found_chan = ichan->ic_ieee; |
| 7646 | /* Indicate the radar event to HDD to stop the netif Tx queues */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7647 | wma_radar_event.chan_freq = ichan->ic_freq; |
| 7648 | wma_radar_event.dfs_radar_status = WMA_DFS_RADAR_FOUND; |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 7649 | indication_status = |
| 7650 | wma->dfs_radar_indication_cb(hdd_ctx, &wma_radar_event); |
| 7651 | if (indication_status == false) { |
| 7652 | WMA_LOGE("%s:Application triggered channel switch in progress!.. drop radar event indiaction to SAP", |
| 7653 | __func__); |
| 7654 | cdf_mem_free(radar_event); |
| 7655 | cdf_spin_unlock_bh(&ic->chan_lock); |
| 7656 | return 0; |
| 7657 | } |
| 7658 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7659 | WMA_LOGE("%s:DFS- RADAR INDICATED TO HDD", __func__); |
| 7660 | |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 7661 | wma_radar_event.ieee_chan_number = ichan->ic_ieee; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7662 | /* |
| 7663 | * Indicate to the radar event to SAP to |
| 7664 | * select a new channel and set CSA IE |
| 7665 | */ |
| 7666 | radar_event->vdev_id = ic->vdev_id; |
| 7667 | wma_get_channels(ichan, &radar_event->chan_list); |
| 7668 | radar_event->dfs_radar_status = WMA_DFS_RADAR_FOUND; |
| 7669 | radar_event->use_nol = ic->ic_dfs_usenol(ic); |
| 7670 | wma_send_msg(wma, WMA_DFS_RADAR_IND, (void *)radar_event, 0); |
| 7671 | WMA_LOGE("%s:DFS- WMA_DFS_RADAR_IND Message Posted", __func__); |
| 7672 | } |
Edhar, Mahesh Kumar | b0319c4 | 2015-10-26 16:53:30 +0530 | [diff] [blame] | 7673 | cdf_spin_unlock_bh(&ic->chan_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7674 | |
| 7675 | return 0; |
| 7676 | } |
| 7677 | |
| 7678 | #ifdef WLAN_FEATURE_MEMDUMP |
| 7679 | /* |
| 7680 | * wma_process_fw_mem_dump_req() - Function to request fw memory dump from |
| 7681 | * firmware |
| 7682 | * @wma: Pointer to WMA handle |
| 7683 | * @mem_dump_req: Pointer for mem_dump_req |
| 7684 | * |
| 7685 | * This function sends memory dump request to firmware |
| 7686 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7687 | * Return: QDF_STATUS_SUCCESS for success otherwise failure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7688 | * |
| 7689 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7690 | QDF_STATUS wma_process_fw_mem_dump_req(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7691 | struct fw_dump_req *mem_dump_req) |
| 7692 | { |
| 7693 | wmi_get_fw_mem_dump_fixed_param *cmd; |
| 7694 | wmi_fw_mem_dump *dump_params; |
| 7695 | struct fw_dump_seg_req *seg_req; |
| 7696 | int32_t len; |
| 7697 | wmi_buf_t buf; |
| 7698 | u_int8_t *buf_ptr; |
| 7699 | int ret, loop; |
| 7700 | |
| 7701 | if (!mem_dump_req || !wma) { |
| 7702 | WMA_LOGE(FL("input pointer is NULL")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7703 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7704 | } |
| 7705 | |
| 7706 | /* |
| 7707 | * len = sizeof(fixed param) that includes tlv header + |
| 7708 | * tlv header for array of struc + |
| 7709 | * sizeof (each struct) |
| 7710 | */ |
| 7711 | len = sizeof(*cmd) + WMI_TLV_HDR_SIZE; |
| 7712 | len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump); |
| 7713 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 7714 | |
| 7715 | if (!buf) { |
| 7716 | WMA_LOGE(FL("Failed allocate wmi buffer")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7717 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7718 | } |
| 7719 | |
| 7720 | buf_ptr = (u_int8_t *) wmi_buf_data(buf); |
| 7721 | cdf_mem_zero(buf_ptr, len); |
| 7722 | cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr; |
| 7723 | |
| 7724 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 7725 | WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param, |
| 7726 | WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param)); |
| 7727 | |
| 7728 | cmd->request_id = mem_dump_req->request_id; |
| 7729 | cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg; |
| 7730 | |
| 7731 | /* TLV indicating array of structures to follow */ |
| 7732 | buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param); |
| 7733 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, |
| 7734 | sizeof(wmi_fw_mem_dump) * |
| 7735 | cmd->num_fw_mem_dump_segs); |
| 7736 | |
| 7737 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 7738 | dump_params = (wmi_fw_mem_dump *) buf_ptr; |
| 7739 | |
| 7740 | WMA_LOGI(FL("request_id:%d num_seg:%d"), |
| 7741 | mem_dump_req->request_id, mem_dump_req->num_seg); |
| 7742 | for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) { |
| 7743 | seg_req = (struct fw_dump_seg_req *) |
| 7744 | ((uint8_t *)(mem_dump_req->segment) + |
| 7745 | loop * sizeof(*seg_req)); |
| 7746 | WMITLV_SET_HDR(&dump_params->tlv_header, |
| 7747 | WMITLV_TAG_STRUC_wmi_fw_mem_dump_params, |
| 7748 | WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump)); |
| 7749 | dump_params->seg_id = seg_req->seg_id; |
| 7750 | dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo; |
| 7751 | dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi; |
| 7752 | dump_params->seg_length = seg_req->seg_length; |
| 7753 | dump_params->dest_addr_lo = seg_req->dst_addr_lo; |
| 7754 | dump_params->dest_addr_hi = seg_req->dst_addr_hi; |
| 7755 | WMA_LOGI(FL("seg_number:%d"), loop); |
| 7756 | WMA_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"), |
| 7757 | dump_params->seg_id, dump_params->seg_start_addr_lo, |
| 7758 | dump_params->seg_start_addr_hi); |
| 7759 | WMA_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"), |
| 7760 | dump_params->seg_length, dump_params->dest_addr_lo, |
| 7761 | dump_params->dest_addr_hi); |
| 7762 | dump_params++; |
| 7763 | } |
| 7764 | |
| 7765 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 7766 | WMI_GET_FW_MEM_DUMP_CMDID); |
| 7767 | if (ret) { |
| 7768 | WMA_LOGE(FL("Failed to send get firmware mem dump request")); |
| 7769 | wmi_buf_free(buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7770 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7771 | } |
| 7772 | |
| 7773 | WMA_LOGI(FL("Get firmware mem dump request sent successfully")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7774 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7775 | } |
| 7776 | |
| 7777 | /** |
| 7778 | * wma_fw_mem_dump_rsp() - send fw mem dump response to SME |
| 7779 | * |
| 7780 | * @req_id - request id. |
| 7781 | * @status - copy status from the firmware. |
| 7782 | * |
| 7783 | * This function is called by the memory dump response handler to |
| 7784 | * indicate SME that firmware dump copy is complete |
| 7785 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7786 | * Return: QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7787 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7788 | static QDF_STATUS wma_fw_mem_dump_rsp(uint32_t req_id, uint32_t status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7789 | { |
| 7790 | struct fw_dump_rsp *dump_rsp; |
| 7791 | cds_msg_t sme_msg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7792 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7793 | |
| 7794 | dump_rsp = cdf_mem_malloc(sizeof(*dump_rsp)); |
| 7795 | |
| 7796 | if (!dump_rsp) { |
| 7797 | WMA_LOGE(FL("Memory allocation failed.")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7798 | qdf_status = QDF_STATUS_E_NOMEM; |
| 7799 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7800 | } |
| 7801 | |
| 7802 | WMA_LOGI(FL("FW memory dump copy complete status: %d for request: %d"), |
| 7803 | status, req_id); |
| 7804 | |
| 7805 | dump_rsp->request_id = req_id; |
| 7806 | dump_rsp->dump_complete = status; |
| 7807 | |
| 7808 | sme_msg.type = eWNI_SME_FW_DUMP_IND; |
| 7809 | sme_msg.bodyptr = dump_rsp; |
| 7810 | sme_msg.bodyval = 0; |
| 7811 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7812 | qdf_status = cds_mq_post_message(CDF_MODULE_ID_SME, &sme_msg); |
| 7813 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7814 | WMA_LOGE(FL("Fail to post fw mem dump ind msg")); |
| 7815 | cdf_mem_free(dump_rsp); |
| 7816 | } |
| 7817 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7818 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7819 | } |
| 7820 | |
| 7821 | /** |
| 7822 | * wma_fw_mem_dump_event_handler() - handles fw memory dump event |
| 7823 | * |
| 7824 | * @handle: pointer to wma handle. |
| 7825 | * @cmd_param_info: pointer to TLV info received in the event. |
| 7826 | * @len: length of data in @cmd_param_info |
| 7827 | * |
| 7828 | * This function is a handler for firmware memory dump event. |
| 7829 | * |
| 7830 | * Return: integer (0 for success and error code otherwise) |
| 7831 | */ |
| 7832 | int wma_fw_mem_dump_event_handler(void *handle, u_int8_t *cmd_param_info, |
| 7833 | u_int32_t len) |
| 7834 | { |
| 7835 | WMI_UPDATE_FW_MEM_DUMP_EVENTID_param_tlvs *param_buf; |
| 7836 | wmi_update_fw_mem_dump_fixed_param *event; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7837 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | |
| 7839 | param_buf = |
| 7840 | (WMI_UPDATE_FW_MEM_DUMP_EVENTID_param_tlvs *) cmd_param_info; |
| 7841 | if (!param_buf) { |
| 7842 | WMA_LOGA("%s: Invalid stats event", __func__); |
| 7843 | return -EINVAL; |
| 7844 | } |
| 7845 | |
| 7846 | event = param_buf->fixed_param; |
| 7847 | |
| 7848 | status = wma_fw_mem_dump_rsp(event->request_id, |
| 7849 | event->fw_mem_dump_complete); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7850 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7851 | WMA_LOGE("Error posting FW MEM DUMP RSP."); |
| 7852 | return -EINVAL; |
| 7853 | } |
| 7854 | |
| 7855 | WMA_LOGI("FW MEM DUMP RSP posted successfully"); |
| 7856 | return 0; |
| 7857 | } |
| 7858 | #endif /* WLAN_FEATURE_MEMDUMP */ |
| 7859 | |
| 7860 | /* |
| 7861 | * wma_process_set_ie_info() - Function to send IE info to firmware |
| 7862 | * @wma: Pointer to WMA handle |
| 7863 | * @ie_data: Pointer for ie data |
| 7864 | * |
| 7865 | * This function sends IE information to firmware |
| 7866 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7867 | * Return: QDF_STATUS_SUCCESS for success otherwise failure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7868 | * |
| 7869 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7870 | QDF_STATUS wma_process_set_ie_info(tp_wma_handle wma, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7871 | struct vdev_ie_info *ie_info) |
| 7872 | { |
| 7873 | wmi_vdev_set_ie_cmd_fixed_param *cmd; |
| 7874 | wmi_buf_t buf; |
| 7875 | uint8_t *buf_ptr; |
| 7876 | uint32_t len, ie_len_aligned; |
| 7877 | int ret; |
| 7878 | |
| 7879 | if (!ie_info || !wma) { |
| 7880 | WMA_LOGE(FL("input pointer is NULL")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7881 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7882 | } |
| 7883 | |
| 7884 | /* Validate the input */ |
| 7885 | if (ie_info->length <= 0) { |
| 7886 | WMA_LOGE(FL("Invalid IE length")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7887 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | } |
| 7889 | |
| 7890 | ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t)); |
| 7891 | /* Allocate memory for the WMI command */ |
| 7892 | len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned; |
| 7893 | |
| 7894 | buf = wmi_buf_alloc(wma->wmi_handle, len); |
| 7895 | if (!buf) { |
| 7896 | WMA_LOGE(FL("wmi_buf_alloc failed")); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame^] | 7897 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7898 | } |
| 7899 | |
| 7900 | buf_ptr = wmi_buf_data(buf); |
| 7901 | cdf_mem_zero(buf_ptr, len); |
| 7902 | |
| 7903 | /* Populate the WMI command */ |
| 7904 | cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr; |
| 7905 | |
| 7906 | WMITLV_SET_HDR(&cmd->tlv_header, |
| 7907 | WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param, |
| 7908 | WMITLV_GET_STRUCT_TLVLEN( |
| 7909 | wmi_vdev_set_ie_cmd_fixed_param)); |
| 7910 | cmd->vdev_id = ie_info->vdev_id; |
| 7911 | cmd->ie_id = ie_info->ie_id; |
| 7912 | cmd->ie_len = ie_info->length; |
| 7913 | |
| 7914 | WMA_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id, |
| 7915 | ie_info->length, ie_info->vdev_id); |
| 7916 | |
| 7917 | buf_ptr += sizeof(*cmd); |
| 7918 | WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned); |
| 7919 | buf_ptr += WMI_TLV_HDR_SIZE; |
| 7920 | |
| 7921 | cdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len); |
| 7922 | |
| 7923 | ret = wmi_unified_cmd_send(wma->wmi_handle, buf, len, |
| 7924 | WMI_VDEV_SET_IE_CMDID); |
| 7925 | if (ret != EOK) { |
| 7926 | WMA_LOGE(FL("Failed to send set IE command ret = %d"), ret); |
| 7927 | wmi_buf_free(buf); |
| 7928 | } |
| 7929 | |
| 7930 | return ret; |
| 7931 | } |
| 7932 | |