From 926d9b868d0410eaed1b5c26a3d9e2ad755cf5ba Mon Sep 17 00:00:00 2001 From: Martin Girardot Date: Fri, 27 Sep 2024 17:26:26 +0200 Subject: [PATCH] [NXP] add support of new wifi diagnostics, only available with sdk 2.16.100 Signed-off-by: Martin Girardot --- .../nxp/common/DiagnosticDataProviderImpl.cpp | 35 +++++++++++++++++++ .../nxp/common/DiagnosticDataProviderImpl.h | 13 ++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp index f3bf2058b6dec9..a41a6bf1d93a88 100644 --- a/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp @@ -421,6 +421,37 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & pa return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +#if SDK_2_16_100 +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ +#ifdef CONFIG_WIFI_GET_LOG + wlan_pkt_stats_t stats; + int ret = wlan_get_log(&stats); + if (ret == WM_SUCCESS) + { + packetUnicastRxCount = stats.rx_unicast_cnt - mPacketUnicastRxCount; + return CHIP_NO_ERROR; + } +#endif /* CONFIG_WIFI_GET_LOG */ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCount) +{ +#ifdef CONFIG_WIFI_GET_LOG + wlan_pkt_stats_t stats; + int ret = wlan_get_log(&stats); + if (ret == WM_SUCCESS) + { + overrunCount = (stats.tx_overrun_cnt + stats.rx_overrun_cnt) - mOverrunCount; + return CHIP_NO_ERROR; + } +#endif /* CONFIG_WIFI_GET_LOG */ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +#endif + CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts(void) { #ifdef CONFIG_WIFI_GET_LOG @@ -433,6 +464,10 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts(void) mPacketMulticastRxCount = stats.mcast_rx_frame; mBeaconRxCount = stats.bcn_rcv_cnt; mBeaconLostCount = stats.bcn_miss_cnt; +#if SDK_2_16_100 + mPacketUnicastRxCount = stats.rx_unicast_cnt; + mOverrunCount = stats.tx_overrun_cnt + stats.rx_overrun_cnt; +#endif return CHIP_NO_ERROR; } #endif /* CONFIG_WIFI_GET_LOG */ diff --git a/src/platform/nxp/common/DiagnosticDataProviderImpl.h b/src/platform/nxp/common/DiagnosticDataProviderImpl.h index f034f1df1a9931..0475d81cbecfd0 100644 --- a/src/platform/nxp/common/DiagnosticDataProviderImpl.h +++ b/src/platform/nxp/common/DiagnosticDataProviderImpl.h @@ -65,16 +65,21 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; +#if SDK_2_16_100 + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastTxCount) override; +#endif + uint32_t mBeaconRxCount = 0; uint32_t mBeaconLostCount = 0; uint32_t mPacketMulticastRxCount = 0; uint32_t mPacketMulticastTxCount = 0; - // currently not supported by SDK - // uint32_t mPacketUnicastRxCount = 0; uint32_t mPacketUnicastTxCount = 0; - // currently not supported by SDK - // uint64_t mOverrunCount = 0; +#if SDK_2_16_100 + uint32_t mPacketUnicastRxCount = 0; + uint64_t mOverrunCount = 0; +#endif #endif /* CHIP_DEVICE_CONFIG_ENABLE_WPA */ };