From b3b15386d6bd5122eb2ade2016e389d733475144 Mon Sep 17 00:00:00 2001 From: Bapiraju Alla Date: Mon, 20 Sep 2021 16:09:12 +0530 Subject: [PATCH] qcacld-3.0: Add support to calibration failure events parsing Currently there is no provision to get the calibration failure information from the driver. Because of this it is getting difficult to debug the calibration failure issues. To simplify the calibration failure issue debugging, add support to parse calibration failures events in the driver. Change-Id: I6d831804cca259862fea3e8bb4af33d556138d43 CRs-Fixed: 3078926 --- Kbuild | 1 + configs/default_defconfig | 2 ++ core/hdd/src/wlan_hdd_main.c | 27 ++++++++++++++++ core/mac/inc/ani_global.h | 7 +++- core/sme/inc/sme_api.h | 21 ++++++++++++ core/sme/src/common/sme_api.c | 24 ++++++++++++++ core/wma/inc/wma_types.h | 3 +- core/wma/src/wma_main.c | 60 +++++++++++++++++++++++++++++++++-- 8 files changed, 140 insertions(+), 5 deletions(-) diff --git a/Kbuild b/Kbuild index b62db12edf2c..2a1531657266 100644 --- a/Kbuild +++ b/Kbuild @@ -3338,6 +3338,7 @@ cppflags-$(CONFIG_RXDMA_ERR_PKT_DROP) += -DRXDMA_ERR_PKT_DROP cppflags-$(CONFIG_MAX_ALLOC_PAGE_SIZE) += -DMAX_ALLOC_PAGE_SIZE cppflags-$(CONFIG_DELIVERY_TO_STACK_STATUS_CHECK) += -DDELIVERY_TO_STACK_STATUS_CHECK cppflags-$(CONFIG_WLAN_TRACE_HIDE_MAC_ADDRESS) += -DWLAN_TRACE_HIDE_MAC_ADDRESS +cppflags-$(CONFIG_WLAN_FEATURE_CAL_FAILURE_TRIGGER) += -DWLAN_FEATURE_CAL_FAILURE_TRIGGER cppflags-$(CONFIG_LITHIUM) += -DFIX_TXDMA_LIMITATION cppflags-$(CONFIG_LITHIUM) += -DFEATURE_AST diff --git a/configs/default_defconfig b/configs/default_defconfig index 84d823a15564..ea8ff6dbd2d9 100644 --- a/configs/default_defconfig +++ b/configs/default_defconfig @@ -1231,3 +1231,5 @@ ifeq ($(CONFIG_FW_THERMAL_THROTTLE), y) CONFIG_WLAN_THERMAL_MULTI_CLIENT_SUPPORT := y endif endif + +CONFIG_WLAN_FEATURE_CAL_FAILURE_TRIGGER := y diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 5877b6be9a15..9c0a6e88d35f 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -14001,6 +14001,31 @@ static void hdd_thermal_stats_cmd_init(struct hdd_context *hdd_ctx) } #endif +#ifdef WLAN_FEATURE_CAL_FAILURE_TRIGGER +/** + * hdd_cal_fail_send_event()- send calibration failure information + * @cal_type: calibration type + * @reason: reason for calibration failure + * + * This Function sends calibration failure diag event + * + * Return: void. + */ +static void hdd_cal_fail_send_event(uint8_t cal_type, uint8_t reason) +{ + /* + * For now we are going with the print. Once CST APK has support to + * read the diag events then we will add the diag event here. + */ + hdd_debug("Received cal failure event with cal_type:%x reason:%x", + cal_type, reason); +} +#else +static inline void hdd_cal_fail_send_event(uint8_t cal_type, uint8_t reason) +{ +} +#endif + /** * hdd_features_init() - Init features * @hdd_ctx: HDD context @@ -14116,6 +14141,8 @@ static int hdd_features_init(struct hdd_context *hdd_ctx) ALLOWED_KEYMGMT_6G_MASK); } hdd_thermal_stats_cmd_init(hdd_ctx); + sme_set_cal_failure_event_cb(hdd_ctx->mac_handle, + hdd_cal_fail_send_event); hdd_exit(); return 0; diff --git a/core/mac/inc/ani_global.h b/core/mac/inc/ani_global.h index ed0dad085d3e..979b89e15093 100644 --- a/core/mac/inc/ani_global.h +++ b/core/mac/inc/ani_global.h @@ -1,5 +1,6 @@ /* - * Copyright (c) 2012-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -818,6 +819,10 @@ struct mac_context { #ifdef FEATURE_ANI_LEVEL_REQUEST struct ani_level_params ani_params; #endif + +#ifdef WLAN_FEATURE_CAL_FAILURE_TRIGGER + void (*cal_failure_event_cb)(uint8_t cal_type, uint8_t reason); +#endif }; #ifdef FEATURE_WLAN_TDLS diff --git a/core/sme/inc/sme_api.h b/core/sme/inc/sme_api.h index e23169a00cf2..6386522603a3 100644 --- a/core/sme/inc/sme_api.h +++ b/core/sme/inc/sme_api.h @@ -2506,6 +2506,27 @@ sme_set_del_peers_ind_callback(mac_handle_t mac_handle, void sme_set_chan_info_callback(mac_handle_t mac_handle, void (*callback)(struct scan_chan_info *chan_info)); +#ifdef WLAN_FEATURE_CAL_FAILURE_TRIGGER +/** + * sme_set_cal_failure_event_cb() - Register calibration failure event callback + * @mac_handle - MAC global handle + * @callback - calibration failure event callback from HDD + * + * This API is invoked by HDD to register its callback to mac + * + * Return: None + */ +void sme_set_cal_failure_event_cb( + mac_handle_t mac_handle, + void (*callback)(uint8_t cal_type, uint8_t reason)); +#else +static inline void +sme_set_cal_failure_event_cb(mac_handle_t mac_handle, + void (*callback)(uint8_t cal_type, uint8_t reason)) +{ +} +#endif + /** * sme_get_rssi_snr_by_bssid() - gets the rssi and snr by bssid from scan cache * @mac_handle: handle returned by mac_open diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index f481eb32b0c8..b2677e0833a8 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -13622,6 +13622,30 @@ void sme_set_chan_info_callback(mac_handle_t mac_handle, mac->chan_info_cb = callback; } +#ifdef WLAN_FEATURE_CAL_FAILURE_TRIGGER +void sme_set_cal_failure_event_cb( + mac_handle_t mac_handle, + void (*callback)(uint8_t cal_type, uint8_t reason)) +{ + struct mac_context *mac; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + if (!mac_handle) { + QDF_ASSERT(0); + return; + } + mac = MAC_CONTEXT(mac_handle); + + status = sme_acquire_global_lock(&mac->sme); + if (QDF_IS_STATUS_SUCCESS(status)) { + mac->cal_failure_event_cb = callback; + sme_release_global_lock(&mac->sme); + } else { + sme_err("sme_acquire_global_lock failed"); + } +} +#endif + void sme_set_vdev_ies_per_band(mac_handle_t mac_handle, uint8_t vdev_id, enum QDF_OPMODE device_mode) { diff --git a/core/wma/inc/wma_types.h b/core/wma/inc/wma_types.h index c50a0a0bf0d5..7a298bf070b7 100644 --- a/core/wma/inc/wma_types.h +++ b/core/wma/inc/wma_types.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -442,8 +443,6 @@ enum wmamsgtype { WMA_TWT_NUDGE_DIALOG_REQUEST = SIR_HAL_TWT_NUDGE_DIALOG_REQUEST, }; -#define WMA_DATA_STALL_TRIGGER 0x1006 - /* Bit 6 will be used to control BD rate for Management frames */ #define HAL_USE_BD_RATE2_FOR_MANAGEMENT_FRAME 0x40 diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index 16812d9723fb..0b93b9086f9f 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -2007,6 +2007,57 @@ static int wma_legacy_service_ready_event_handler(uint32_t event_id, return 0; } +#ifdef WLAN_FEATURE_CAL_FAILURE_TRIGGER +/** + * wma_process_cal_fail_info() - Process cal failure event and + * send it to userspace + * @wmi_event: Cal failure event data + */ +static void wma_process_cal_fail_info(uint8_t *wmi_event) +{ + struct mac_context *mac = cds_get_context(QDF_MODULE_ID_PE); + uint8_t *buf_ptr; + wmi_debug_mesg_fw_cal_failure_param *cal_failure_event; + + if (!mac) { + wma_err("Invalid mac context"); + return; + } + + if (!mac->cal_failure_event_cb) { + wma_err("Callback not registered for cal failure event"); + return; + } + + buf_ptr = wmi_event; + buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) + + WMI_TLV_HDR_SIZE + + sizeof(wmi_debug_mesg_fw_data_stall_param) + WMI_TLV_HDR_SIZE; + + cal_failure_event = (wmi_debug_mesg_fw_cal_failure_param *)buf_ptr; + + if (((cal_failure_event->tlv_header & 0xFFFF0000) >> 16 == + WMITLV_TAG_STRUC_wmi_debug_mesg_fw_cal_failure_param)) { + /** + * Log calibration failure information received from FW + */ + wma_debug("Calibration failure event:"); + wma_debug("calType: %x calFailureReasonCode: %x", + cal_failure_event->cal_type, + cal_failure_event->cal_failure_reason_code); + mac->cal_failure_event_cb( + cal_failure_event->cal_type, + cal_failure_event->cal_failure_reason_code); + } else { + wma_err("Invalid TLV header in cal failure event"); + } +} +#else +static inline void wma_process_cal_fail_info(uint8_t *wmi_event) +{ +} +#endif + /** * wma_flush_complete_evt_handler() - FW log flush complete event handler * @handle: WMI handle @@ -2038,7 +2089,7 @@ static int wma_flush_complete_evt_handler(void *handle, reason_code = wmi_event->reserved0; wma_debug("Received reason code %d from FW", reason_code); - if (reason_code == WMA_DATA_STALL_TRIGGER) { + if (reason_code == WMI_DIAG_TRIGGER_DATA_STALL) { buf_ptr = (uint8_t *)wmi_event; buf_ptr = buf_ptr + sizeof(wmi_debug_mesg_flush_complete_fixed_param) + @@ -2047,7 +2098,7 @@ static int wma_flush_complete_evt_handler(void *handle, (wmi_debug_mesg_fw_data_stall_param *)buf_ptr; } - if (reason_code == WMA_DATA_STALL_TRIGGER && + if (reason_code == WMI_DIAG_TRIGGER_DATA_STALL && ((data_stall_event->tlv_header & 0xFFFF0000) >> 16 == WMITLV_TAG_STRUC_wmi_debug_mesg_fw_data_stall_param)) { /** @@ -2097,6 +2148,11 @@ static int wma_flush_complete_evt_handler(void *handle, data_stall_event->recovery_type); } + if (reason_code == WMI_DIAG_TRIGGER_CAL_FAILURE) { + wma_process_cal_fail_info((uint8_t *)wmi_event); + return QDF_STATUS_SUCCESS; + } + /* * reason_code = 0; Flush event in response to flush command * reason_code = other value; Asynchronous flush event for fatal events