diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index f53fa8f4f3539..c94f867a85fc4 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -12646,6 +12646,9 @@ int hdd_register_cb(struct hdd_context *hdd_ctx) status = sme_set_lost_link_info_cb(mac_handle, hdd_lost_link_info_cb); + + wlan_hdd_register_cp_stats_cb(hdd_ctx); + /* print error and not block the startup process */ if (!QDF_IS_STATUS_SUCCESS(status)) hdd_err("set lost link info callback failed"); diff --git a/core/hdd/src/wlan_hdd_stats.c b/core/hdd/src/wlan_hdd_stats.c index fac15c4f1691a..0ea7ec99f5aa9 100644 --- a/core/hdd/src/wlan_hdd_stats.c +++ b/core/hdd/src/wlan_hdd_stats.c @@ -37,6 +37,7 @@ #include "wlan_hdd_debugfs_llstat.h" #include "wlan_reg_services_api.h" #include +#include "wlan_cp_stats_mc_ucfg_api.h" #include "wlan_mlme_ucfg_api.h" #include "wlan_mlme_ucfg_api.h" @@ -5793,3 +5794,54 @@ void wlan_hdd_display_txrx_stats(struct hdd_context *ctx) qdf_atomic_read(&ctx->disable_rx_ol_in_low_tput)); } } + +/** + * hdd_lost_link_cp_stats_info_cb() - callback function to get lost + * link information + * @stats_ev: Stats event pointer + * FW sends vdev stats on vdev down, this callback is registered + * with cp_stats component to get the last available vdev stats + * From the FW. + * + * Return: None + */ + +static void hdd_lost_link_cp_stats_info_cb(void *stats_ev) +{ + struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); + struct hdd_adapter *adapter; + struct stats_event *ev = stats_ev; + uint8_t i; + struct hdd_station_ctx *sta_ctx; + + if (wlan_hdd_validate_context(hdd_ctx)) + return; + + for (i = 0; i < ev->num_summary_stats; i++) { + adapter = hdd_get_adapter_by_vdev( + hdd_ctx, + ev->vdev_summary_stats[i].vdev_id); + if (!adapter) { + hdd_debug("invalid adapter"); + continue; + } + sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); + if ((sta_ctx) && + (eConnectionState_Associated != + sta_ctx->conn_info.conn_state)) { + adapter->rssi_on_disconnect = + ev->vdev_summary_stats[i].stats.rssi; + hdd_debug("rssi on disconnect %d for " QDF_MAC_ADDR_STR, + adapter->rssi_on_disconnect, + QDF_MAC_ADDR_ARRAY(adapter->mac_addr.bytes)); + } + } +} + +void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx) +{ + ucfg_mc_cp_stats_register_lost_link_info_cb( + hdd_ctx->psoc, + hdd_lost_link_cp_stats_info_cb); +} + diff --git a/core/hdd/src/wlan_hdd_stats.h b/core/hdd/src/wlan_hdd_stats.h index 1d087e33f92d5..1a50b49b94c98 100644 --- a/core/hdd/src/wlan_hdd_stats.h +++ b/core/hdd/src/wlan_hdd_stats.h @@ -461,4 +461,14 @@ bool hdd_report_max_rate(mac_handle_t mac_handle, uint8_t mcs_index, uint16_t fw_rate, uint8_t nss); +/** + * wlan_hdd_register_cp_stats_cb() - Register hdd stats specific + * callbacks to the cp stats component + * @hdd_ctx: hdd context + * + * Return: none + */ + +void wlan_hdd_register_cp_stats_cb(struct hdd_context *hdd_ctx); + #endif /* end #if !defined(WLAN_HDD_STATS_H) */