From 4e9cf39d1d8336035bf446b33a1adc821f4d6994 Mon Sep 17 00:00:00 2001 From: Krishna Kumaar Natarajan Date: Fri, 20 Nov 2015 13:35:05 -0800 Subject: [PATCH] qcacld-3.0: Add event handler for oem data response Add event handler for oem data response event from FW. Add new boolean member to differentiate the response generated internally and one coming from the FW. Change-Id: Ia906c5dcbb7e560fd78ccd96fc47c7801b33aa6a CRs-Fixed: 942261 --- core/mac/inc/sir_api.h | 3 +- core/mac/src/pe/include/lim_global.h | 3 +- .../src/pe/lim/lim_process_mlm_req_messages.c | 4 +- .../src/pe/lim/lim_send_sme_rsp_messages.c | 4 +- core/sme/src/oem_data/oem_data_api.c | 30 ++++------ core/wma/inc/wma_if.h | 3 +- core/wma/inc/wma_internal.h | 5 +- core/wma/src/wma_features.c | 60 ++++++++++++++++++- core/wma/src/wma_main.c | 6 +- 9 files changed, 90 insertions(+), 28 deletions(-) diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 162cebc9c294..e5dde5720b44 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -881,6 +881,7 @@ typedef struct sSirOemDataReq { typedef struct sSirOemDataRsp { uint16_t messageType; uint16_t length; + bool target_rsp; uint8_t oemDataRsp[OEM_DATA_RSP_SIZE]; } tSirOemDataRsp, *tpSirOemDataRsp; diff --git a/core/mac/src/pe/include/lim_global.h b/core/mac/src/pe/include/lim_global.h index c40bb1cef5dd..b5825b4f6203 100644 --- a/core/mac/src/pe/include/lim_global.h +++ b/core/mac/src/pe/include/lim_global.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -311,6 +311,7 @@ typedef struct sLimMlmOemDataReq { } tLimMlmOemDataReq, *tpLimMlmOemDataReq; typedef struct sLimMlmOemDataRsp { + bool target_rsp; uint8_t oemDataRsp[OEM_DATA_RSP_SIZE]; } tLimMlmOemDataRsp, *tpLimMlmOemDataRsp; #endif diff --git a/core/mac/src/pe/lim/lim_process_mlm_req_messages.c b/core/mac/src/pe/lim/lim_process_mlm_req_messages.c index 11561472d032..2de1a1db93ad 100644 --- a/core/mac/src/pe/lim/lim_process_mlm_req_messages.c +++ b/core/mac/src/pe/lim/lim_process_mlm_req_messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -421,6 +421,7 @@ error: ("memory allocation for mlm_oem_data_rsp")); return; } + mlm_oem_data_rsp->target_rsp = false; if (NULL != mac_ctx->lim.gpLimMlmOemDataReq) { cdf_mem_free(mac_ctx->lim.gpLimMlmOemDataReq); @@ -822,6 +823,7 @@ static void lim_process_mlm_oem_data_req(tpAniSirGlobal mac_ctx, /* Return Meas confirm with INVALID_PARAMETERS */ mlm_oem_data_rsp = cdf_mem_malloc(sizeof(tLimMlmOemDataRsp)); if (mlm_oem_data_rsp != NULL) { + mlm_oem_data_rsp->target_rsp = false; lim_post_sme_message(mac_ctx, LIM_MLM_OEM_DATA_CNF, (uint32_t *) mlm_oem_data_rsp); cdf_mem_free(mlm_oem_data_rsp); diff --git a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c index 1eab1eccb9a1..ff4848c2dd44 100644 --- a/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c +++ b/core/mac/src/pe/lim/lim_send_sme_rsp_messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -844,7 +844,7 @@ void lim_send_sme_oem_data_rsp(tpAniSirGlobal pMac, uint32_t *pMsgBuf, pSirSmeOemDataRsp->length = msgLength; pSirSmeOemDataRsp->messageType = eWNI_SME_OEM_DATA_RSP; #endif - + pSirSmeOemDataRsp->target_rsp = pMlmOemDataRsp->target_rsp; cdf_mem_copy(pSirSmeOemDataRsp->oemDataRsp, pMlmOemDataRsp->oemDataRsp, OEM_DATA_RSP_SIZE); diff --git a/core/sme/src/oem_data/oem_data_api.c b/core/sme/src/oem_data/oem_data_api.c index 89eda604f90c..a666991cba05 100644 --- a/core/sme/src/oem_data/oem_data_api.c +++ b/core/sme/src/oem_data/oem_data_api.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -290,7 +290,6 @@ CDF_STATUS sme_handle_oem_data_rsp(tHalHandle hHal, uint8_t *pMsg) tListElem *pEntry = NULL; tSmeCmd *pCommand = NULL; tSirOemDataRsp *pOemDataRsp = NULL; - uint32_t *msgSubType; pMac = PMAC_STRUCT(hHal); @@ -326,21 +325,18 @@ CDF_STATUS sme_handle_oem_data_rsp(tHalHandle hHal, uint8_t *pMsg) pOemDataRsp = (tSirOemDataRsp *) pMsg; - /* check if message is to be forwarded to oem application or not */ - msgSubType = (uint32_t *) (&pOemDataRsp->oemDataRsp[0]); - if (*msgSubType != OEM_MESSAGE_SUBTYPE_INTERNAL) { - CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, - "%s: calling send_oem_data_rsp_msg, msgSubType(0x%x)", - __func__, *msgSubType); - if (pMac->oemData.oem_data_rsp_callback != NULL) { - pMac->oemData.oem_data_rsp_callback( - sizeof(tOemDataRsp), - &pOemDataRsp->oemDataRsp[0]); - } - } else - CDF_TRACE(CDF_MODULE_ID_SME, CDF_TRACE_LEVEL_INFO, - "%s: received internal oem data resp, msgSubType (0x%x)", - __func__, *msgSubType); + /* Send to upper layer only if rsp is from target */ + if (pOemDataRsp->target_rsp) { + sms_log(pMac, LOG1, + FL("received target oem data resp")); + if (pMac->oemData.oem_data_rsp_callback != NULL) + pMac->oemData.oem_data_rsp_callback( + sizeof(tOemDataRsp), + &pOemDataRsp->oemDataRsp[0]); + } else { + sms_log(pMac, LOG1, + FL("received internal oem data resp")); + } } while (0); return status; diff --git a/core/wma/inc/wma_if.h b/core/wma/inc/wma_if.h index 482b800b298f..42bd8844dfe8 100644 --- a/core/wma/inc/wma_if.h +++ b/core/wma/inc/wma_if.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -688,6 +688,7 @@ typedef struct { * @oemDataRsp: OEM Data response */ typedef struct { + bool target_rsp; uint8_t oemDataRsp[OEM_DATA_RSP_SIZE]; } tStartOemDataRsp, *tpStartOemDataRsp; #endif /* FEATURE_OEM_DATA_SUPPORT */ diff --git a/core/wma/inc/wma_internal.h b/core/wma/inc/wma_internal.h index 0fd93a395ec5..59751de4214b 100644 --- a/core/wma/inc/wma_internal.h +++ b/core/wma/inc/wma_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -910,6 +910,9 @@ int wma_oem_measurement_report_event_callback(void *handle, uint8_t *datap, int wma_oem_error_report_event_callback(void *handle, uint8_t *datap, uint32_t len); + +int wma_oem_data_response_handler(void *handle, uint8_t *datap, + uint32_t len); #endif void wma_register_dfs_event_handler(tp_wma_handle wma_handle); diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index a35a58490061..735c36c0199b 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -1699,6 +1699,7 @@ int wma_oem_capability_event_callback(void *handle, } cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); + pStartOemDataRsp->target_rsp = true; msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); *msg_subtype = WMI_OEM_CAPABILITY_RSP; cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); @@ -1760,6 +1761,7 @@ int wma_oem_measurement_report_event_callback(void *handle, } cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); + pStartOemDataRsp->target_rsp = true; msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); *msg_subtype = WMI_OEM_MEASUREMENT_RSP; cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); @@ -1820,6 +1822,7 @@ int wma_oem_error_report_event_callback(void *handle, } cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); + pStartOemDataRsp->target_rsp = true; msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); *msg_subtype = WMI_OEM_ERROR_REPORT_RSP; cdf_mem_copy(&pStartOemDataRsp->oemDataRsp[4], data, datalen); @@ -1831,6 +1834,59 @@ int wma_oem_error_report_event_callback(void *handle, return 0; } +/** + * wma_oem_data_response_handler() - OEM data response event handler + * @handle: wma handle + * @datap: data ptr + * @len: data length + * + * Return: 0 for success or error code + */ +int wma_oem_data_response_handler(void *handle, + uint8_t *datap, uint32_t len) +{ + tp_wma_handle wma = (tp_wma_handle) handle; + WMI_OEM_RESPONSE_EVENTID_param_tlvs *param_buf; + uint8_t *data; + uint32_t datalen; + tStartOemDataRsp *oem_data_rsp; + + param_buf = (WMI_OEM_RESPONSE_EVENTID_param_tlvs *) datap; + if (!param_buf) { + WMA_LOGE(FL("Received NULL buf ptr from FW")); + return -ENOMEM; + } + + data = param_buf->data; + datalen = param_buf->num_data; + + if (!data) { + WMA_LOGE(FL("Received NULL data from FW")); + return -EINVAL; + } + + if (datalen > OEM_DATA_RSP_SIZE) { + WMA_LOGE(FL("Received data len %d exceeds max value %d"), + datalen, OEM_DATA_RSP_SIZE); + return -EINVAL; + } + + oem_data_rsp = cdf_mem_malloc(sizeof(*oem_data_rsp)); + if (!oem_data_rsp) { + WMA_LOGE(FL("Failed to alloc oem_data_rsp")); + return -ENOMEM; + } + + cdf_mem_zero(oem_data_rsp, sizeof(tStartOemDataRsp)); + oem_data_rsp->target_rsp = true; + cdf_mem_copy(&oem_data_rsp->oemDataRsp[0], data, datalen); + + WMA_LOGI(FL("Sending WMA_START_OEM_DATA_RSP, data len %d"), datalen); + + wma_send_msg(wma, WMA_START_OEM_DATA_RSP, (void *)oem_data_rsp, 0); + return 0; +} + /** * wma_start_oem_data_req() - start OEM data request to target * @wma_handle: wma handle @@ -1844,7 +1900,6 @@ void wma_start_oem_data_req(tp_wma_handle wma_handle, wmi_buf_t buf; uint8_t *cmd; int ret = 0; - uint32_t *msg_subtype; tStartOemDataRsp *pStartOemDataRsp; WMA_LOGD("%s: Send OEM Data Request to target", __func__); @@ -1903,8 +1958,7 @@ out: return; } cdf_mem_zero(pStartOemDataRsp, sizeof(tStartOemDataRsp)); - msg_subtype = (uint32_t *) (&pStartOemDataRsp->oemDataRsp[0]); - *msg_subtype = WMI_OEM_INTERNAL_RSP; + pStartOemDataRsp->target_rsp = false; WMA_LOGI("%s: Sending WMA_START_OEM_DATA_RSP to clear up PE/SME pending cmd", __func__); diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index f493262c8c0a..ab6e66417626 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -1817,6 +1817,10 @@ CDF_STATUS wma_open(void *cds_context, wmi_unified_register_event_handler(wma_handle->wmi_handle, WMI_OEM_ERROR_REPORT_EVENTID, wma_oem_error_report_event_callback); + + wmi_unified_register_event_handler(wma_handle->wmi_handle, + WMI_OEM_RESPONSE_EVENTID, + wma_oem_data_response_handler); #endif /* FEATURE_OEM_DATA_SUPPORT */ /* * Register appropriate DFS phyerr event handler for