From 436ed8716df8895fb1f972d9bdb419e0c717866b Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Tue, 3 Dec 2024 09:33:00 -0500 Subject: [PATCH] Wrapped tracing begin and end with maccros to reduce the amount if #if in the code --- examples/platform/silabs/BaseApplication.cpp | 17 ++--- examples/platform/silabs/MatterConfig.cpp | 19 ++---- examples/platform/silabs/main.cpp | 21 ++---- src/platform/silabs/efr32/BUILD.gn | 7 +- .../silabs/efr32/OTAImageProcessorImpl.cpp | 67 +++++-------------- src/platform/silabs/tracing/BackendImpl.h | 18 +---- src/platform/silabs/tracing/SilabsTracing.h | 38 +---------- .../silabs/tracing/SilabsTracingMacros.h | 67 +++++++++++++++++++ .../silabs/tracing/SilabsTracingTypes.h | 64 ++++++++++++++++++ .../include/matter/tracing/macros_impl.h | 2 +- 10 files changed, 172 insertions(+), 148 deletions(-) create mode 100644 src/platform/silabs/tracing/SilabsTracingMacros.h create mode 100644 src/platform/silabs/tracing/SilabsTracingTypes.h diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index 5bd90be317..1176ea6fa7 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -90,12 +90,9 @@ #endif // Tracing -#include -#if MATTER_TRACING_ENABLED -#ifdef ENABLE_CHIP_SHELL +#include +#if MATTER_TRACING_ENABLED && defined(ENABLE_CHIP_SHELL) #include -#endif // ENABLE_CHIP_SHELL -#include #endif // MATTER_TRACING_ENABLED // sl-only @@ -127,11 +124,7 @@ using namespace chip::app; using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceLayer::Silabs; -#if MATTER_TRACING_ENABLED using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation; -using SilabsTracer = chip::Tracing::Silabs::SilabsTracer; -#endif // MATTER_TRACING_ENABLED - namespace { /********************************************************** @@ -375,10 +368,8 @@ CHIP_ERROR BaseApplication::Init() void BaseApplication::InitCompleteCallback(CHIP_ERROR err) { -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kAppInit); - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END(TimeTraceOperation::kAppInit); + SILABS_TRACE_END(TimeTraceOperation::kBootup); } void BaseApplication::FunctionTimerEventHandler(void * timerCbArg) diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 63e6b2ff10..23ae8a1b39 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -48,11 +48,11 @@ #include "MemMonitoring.h" #endif -#if ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) +#if ((defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1) || defined(EXP_BOARD)) #include #if !defined(EXP_BOARD) #include -#endif //!defined(EXP_BOARD) +#endif //! defined(EXP_BOARD) #endif // ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) #include @@ -97,10 +97,9 @@ static chip::DeviceLayer::Internal::Efr32PsaOperationalKeystore gOperationalKeys #include "sl_power_manager.h" #endif -#include +#include #if MATTER_TRACING_ENABLED #include -#include #include #endif // MATTER_TRACING_ENABLED @@ -113,11 +112,7 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Credentials; using namespace chip::DeviceLayer::Silabs; - -#if MATTER_TRACING_ENABLED using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation; -using SilabsTracer = chip::Tracing::Silabs::SilabsTracer; -#endif // MATTER_TRACING_ENABLED #if CHIP_ENABLE_OPENTHREAD #include @@ -193,10 +188,8 @@ void ApplicationStart(void * unused) if (err != CHIP_NO_ERROR) appError(err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kMatterInit); - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kAppInit); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END(TimeTraceOperation::kMatterInit); + SILABS_TRACE_BEGIN(TimeTraceOperation::kAppInit); gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); @@ -381,7 +374,7 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) #endif // SL_WFX_USE_SECURE_LINK #endif // WF200_WIFI -#if ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) +#if ((defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1) || defined(EXP_BOARD)) VerifyOrReturnError(sl_matter_wifi_platform_init() == SL_STATUS_OK, CHIP_ERROR_INTERNAL); #endif // ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) diff --git a/examples/platform/silabs/main.cpp b/examples/platform/silabs/main.cpp index 6d3c6145d8..2d9f6f8ba6 100644 --- a/examples/platform/silabs/main.cpp +++ b/examples/platform/silabs/main.cpp @@ -20,28 +20,17 @@ #include "sl_system_init.h" #include "sl_system_kernel.h" #include +#include -#include -#if MATTER_TRACING_ENABLED -#include -#endif // MATTER_TRACING_ENABLED - -#if MATTER_TRACING_ENABLED using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation; -using SilabsTracer = chip::Tracing::Silabs::SilabsTracer; -#endif // MATTER_TRACING_ENABLED int main(void) { -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kBootup); - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kSilabsInit); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_BEGIN(chip::Tracing::Silabs::TimeTraceOperation::kBootup); + SILABS_TRACE_BEGIN(chip::Tracing::Silabs::TimeTraceOperation::kSilabsInit); sl_system_init(); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kSilabsInit); - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kMatterInit); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END(chip::Tracing::Silabs::TimeTraceOperation::kSilabsInit); + SILABS_TRACE_BEGIN(chip::Tracing::Silabs::TimeTraceOperation::kMatterInit); // Initialize the application. For example, create periodic timer(s) or // task(s) if the kernel is present. SilabsMatterConfig::AppInit(); diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 920168ce8a..b37b0894db 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -116,14 +116,17 @@ static_library("efr32") { "${chip_root}/src/platform/logging:headers", ] deps = [ - "${chip_root}/src/tracing", + "${chip_root}/src/tracing/silabs:silabs_tracing", "${silabs_platform_dir}/provision:provision-headers", ] public_configs = [] if (matter_enable_tracing_support) { - public_deps += [ "${chip_root}/src/platform/silabs/tracing:SilabsTracing" ] + public_deps += [ + "${chip_root}/src/platform/silabs/tracing:SilabsTracing", + "${chip_root}/src/tracing", + ] } # Add platform crypto implementation diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 47716d6383..9528c5b779 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -25,16 +25,15 @@ #include #endif // SL_WIFI -#include -#if MATTER_TRACING_ENABLED -#include -#endif // MATTER_TRACING_ENABLED +#include extern "C" { #include "btl_interface.h" #include "sl_core.h" } +using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation; + #ifdef _SILICON_LABS_32B_SERIES_2 // Series 2 bootloader_ api calls must be called from a critical section context for thread safeness #define WRAP_BL_DFU_CALL(code) \ @@ -56,11 +55,6 @@ static chip::OTAImageProcessorImpl gImageProcessor; namespace chip { -#if MATTER_TRACING_ENABLED -using TimeTraceOperation = chip::Tracing::Silabs::TimeTraceOperation; -using SilabsTracer = chip::Tracing::Silabs::SilabsTracer; -#endif // MATTER_TRACING_ENABLED - // Define static memebers uint8_t OTAImageProcessorImpl::mSlotId = 0; uint32_t OTAImageProcessorImpl::mWriteOffset = 0; @@ -168,9 +162,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) ChipLogProgress(SoftwareUpdate, "HandlePrepareDownload: started"); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kImageUpload); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_BEGIN(TimeTraceOperation::kImageUpload); #ifdef _SILICON_LABS_32B_SERIES_2 // TODO sl-temp: bootloader_init is called previously sl_platform_init(). Recalling it for series3 causes a crash. @@ -178,9 +170,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogProgress(SoftwareUpdate, "bootloader_init Failed error: %ld", err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); } #endif @@ -222,9 +212,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_pre_bootloader_spi_transfer() error: %ld", err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); return; } #endif // SL_BTLCTRL_MUX @@ -235,9 +223,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageUpload, CHIP_ERROR_INTERNAL); return; } #endif // SL_BTLCTRL_MUX @@ -245,9 +231,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) { ChipLogError(SoftwareUpdate, "bootloader_eraseWriteStorage() error: %ld", err); imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageUpload, CHIP_ERROR_WRITE_FAILED); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageUpload, CHIP_ERROR_WRITE_FAILED); return; } } @@ -255,9 +239,7 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) imageProcessor->ReleaseBlock(); ChipLogProgress(SoftwareUpdate, "OTA image downloaded successfully"); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageUpload); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END(TimeTraceOperation::kImageUpload); } // TODO: SE access is not thread safe. It assert if other tasks accesses it during bootloader_verifyImage or @@ -281,9 +263,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) uint32_t err = SL_BOOTLOADER_OK; ChipLogProgress(SoftwareUpdate, "HandleApply: verifying image"); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceBegin(TimeTraceOperation::kImageVerification); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_BEGIN(TimeTraceOperation::kImageVerification); // Force KVS to store pending keys such as data from StoreCurrentUpdateInfo() chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().ForceKeyMapSave(); @@ -292,9 +272,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_pre_bootloader_spi_transfer() error: %ld", err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification, CHIP_ERROR_INTERNAL); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageVerification, CHIP_ERROR_INTERNAL); return; } #endif // SL_BTLCTRL_MUX @@ -317,9 +295,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); } #endif // SL_BTLCTRL_MUX -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification, err); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageVerification, err); return; } ChipLogProgress(SoftwareUpdate, "Image verified, Set image to bootload"); @@ -338,9 +314,7 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); } #endif // SL_BTLCTRL_MUX -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification, err); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageVerification, err); return; } @@ -349,23 +323,16 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_STATUS_OK) { ChipLogError(SoftwareUpdate, "sl_wfx_host_post_bootloader_spi_transfer() error: %ld", err); -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification, err); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END_ERROR(TimeTraceOperation::kImageVerification, err); return; } #endif // SL_BTLCTRL_MUX -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kImageVerification); - SilabsTracer::Instance().TimeTraceInstant(TimeTraceOperation::kAppApplyTime); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_END(TimeTraceOperation::kImageVerification); + SILABS_TRACE_INSTANT(TimeTraceOperation::kAppApplyTime); ChipLogProgress(SoftwareUpdate, "Reboot and install new image..."); - -#if MATTER_TRACING_ENABLED // Flush all traces before reboot since we do not store them in NVM currently - SilabsTracer::Instance().TraceBufferFlushAll(); -#endif // MATTER_TRACING_ENABLED + SILABS_TRACE_FLUSH_ALL(); #if defined(_SILICON_LABS_32B_SERIES_3) && CHIP_PROGRESS_LOGGING osDelay(100); // sl-temp: delay for uart print before reboot #endif // _SILICON_LABS_32B_SERIES_3 && CHIP_PROGRESS_LOGGING diff --git a/src/platform/silabs/tracing/BackendImpl.h b/src/platform/silabs/tracing/BackendImpl.h index f9ae3b5e6c..0594e78bc4 100644 --- a/src/platform/silabs/tracing/BackendImpl.h +++ b/src/platform/silabs/tracing/BackendImpl.h @@ -20,20 +20,6 @@ #include #include -#define _MATTER_TRACE_DISABLE(...) \ - do \ - { \ - } while (false) - -// This gets forwarded to the multiplexed instance -#define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) -#define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) -#define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) -#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) - -// We are not using this in our current implementation, so we are disabling it. -#define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) - namespace chip { namespace Tracing { namespace Silabs { @@ -46,8 +32,8 @@ class BackendImpl : public ::chip::Tracing::Backend public: BackendImpl() = default; // TraceBegin, TraceEnd and TraceInstant are redundant with LogMetricEvent in the usecases that we are trying to track, - // so we are not implementing these at the moment to avoid duplication of the same information in the trace. We might implement them - // in the future if we want to add new traces that are not related to our metrics measurements + // so we are not implementing these at the moment to avoid duplication of the same information in the trace. We might implement + // them in the future if we want to add new traces that are not related to our metrics measurements void TraceBegin(const char * label, const char * group) override; void TraceEnd(const char * label, const char * group) override; void TraceInstant(const char * label, const char * group) override; diff --git a/src/platform/silabs/tracing/SilabsTracing.h b/src/platform/silabs/tracing/SilabsTracing.h index 8c257bb194..9f4a797271 100644 --- a/src/platform/silabs/tracing/SilabsTracing.h +++ b/src/platform/silabs/tracing/SilabsTracing.h @@ -16,6 +16,7 @@ ******************************************************************************/ #pragma once +#include "SilabsTracingTypes.h" #include #include #include @@ -36,43 +37,6 @@ namespace chip { namespace Tracing { namespace Silabs { -// Enum for the different operation to trace -enum class TimeTraceOperation : uint8_t -{ - kSpake2p, - kPake1, - kPake2, - kPake3, - kOperationalCredentials, - kAttestationVerification, - kCSR, - kNOC, - kTransportLayer, - kTransportSetup, - kFindOperational, - kCaseSession, - kSigma1, - kSigma2, - kSigma3, - kOTA, - kImageUpload, - kImageVerification, - kAppApplyTime, - kBootup, - kSilabsInit, - kMatterInit, - kAppInit, - kBufferFull, - kNumTraces, -}; - -enum class OperationType : uint8_t -{ - kBegin, - kEnd, - kInstant, -}; - struct TimeTracker { // Temporary values diff --git a/src/platform/silabs/tracing/SilabsTracingMacros.h b/src/platform/silabs/tracing/SilabsTracingMacros.h new file mode 100644 index 0000000000..e1ba1a8fc2 --- /dev/null +++ b/src/platform/silabs/tracing/SilabsTracingMacros.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * @file SilabsTracing.h + * @brief Instrumenting for matter operation tracing for the Silicon Labs platform. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#pragma once + +#define _MATTER_TRACE_DISABLE(...) \ + do \ + { \ + } while (false) + +#include "SilabsTracingTypes.h" +#include +#if MATTER_TRACING_ENABLED +#include "SilabsTracing.h" +#include +#include +#include +#include + +// This gets forwarded to the multiplexed instance +#define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group) +#define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group) +#define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group) +#define MATTER_TRACE_COUNTER(label) ::chip::Tracing::Internal::Counter(label) + +// We are not using this in our current implementation, so we are disabling it. +#define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) + +#define SILABS_TRACE_BEGIN(operation) ::chip::Tracing::Silabs::SilabsTracer::Instance().TimeTraceBegin(operation) +#define SILABS_TRACE_END(operation) ::chip::Tracing::Silabs::SilabsTracer::Instance().TimeTraceEnd(operation) +#define SILABS_TRACE_END_ERROR(operation, error) ::chip::Tracing::Silabs::SilabsTracer::Instance().TimeTraceEnd(operation, error) +#define SILABS_TRACE_INSTANT(operation) ::chip::Tracing::Silabs::SilabsTracer::Instance().TimeTraceInstant(operation) +#define SILABS_TRACE_INSTANT_ERROR(operation, error) \ + ::chip::Tracing::Silabs::SilabsTracer::Instance().TimeTraceInstant(operation, error) + +#define SILABS_TRACE_FLUSH_ALL() ::chip::Tracing::Silabs::SilabsTracer::Instance().TraceBufferFlushAll() + +#else // MATTER_TRACING_ENABLED + +#define MATTER_TRACE_BEGIN(label, group) _MATTER_TRACE_DISABLE(label, group) +#define MATTER_TRACE_END(label, group) _MATTER_TRACE_DISABLE(label, group) +#define MATTER_TRACE_INSTANT(label, group) _MATTER_TRACE_DISABLE(label, group) +#define MATTER_TRACE_COUNTER(label) _MATTER_TRACE_DISABLE(label) +#define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__) + +#define SILABS_TRACE_BEGIN(operation) _MATTER_TRACE_DISABLE(operation) +#define SILABS_TRACE_END(operation) _MATTER_TRACE_DISABLE(operation) +#define SILABS_TRACE_END_ERROR(operation, error) _MATTER_TRACE_DISABLE(operation, error) +#define SILABS_TRACE_INSTANT(operation) _MATTER_TRACE_DISABLE(operation) +#define SILABS_TRACE_INSTANT_ERROR(operation, error) _MATTER_TRACE_DISABLE(operation, error) + +#define SILABS_TRACE_FLUSH_ALL() _MATTER_TRACE_DISABLE() + +#endif // MATTER_TRACING_ENABLED diff --git a/src/platform/silabs/tracing/SilabsTracingTypes.h b/src/platform/silabs/tracing/SilabsTracingTypes.h new file mode 100644 index 0000000000..225dc15455 --- /dev/null +++ b/src/platform/silabs/tracing/SilabsTracingTypes.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * @file SilabsTracing.h + * @brief Instrumenting for matter operation tracing for the Silicon Labs platform. + ******************************************************************************* + * # License + * Copyright 2024 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ +#pragma once + +#include + +namespace chip { +namespace Tracing { +namespace Silabs { + +// Enum for the different operation to trace +enum class TimeTraceOperation : uint8_t +{ + kSpake2p, + kPake1, + kPake2, + kPake3, + kOperationalCredentials, + kAttestationVerification, + kCSR, + kNOC, + kTransportLayer, + kTransportSetup, + kFindOperational, + kCaseSession, + kSigma1, + kSigma2, + kSigma3, + kOTA, + kImageUpload, + kImageVerification, + kAppApplyTime, + kBootup, + kSilabsInit, + kMatterInit, + kAppInit, + kBufferFull, + kNumTraces, +}; + +enum class OperationType : uint8_t +{ + kBegin, + kEnd, + kInstant, +}; + +} // namespace Silabs +} // namespace Tracing +} // namespace chip \ No newline at end of file diff --git a/src/tracing/silabs/include/matter/tracing/macros_impl.h b/src/tracing/silabs/include/matter/tracing/macros_impl.h index f9ec7e5697..a267ca5077 100644 --- a/src/tracing/silabs/include/matter/tracing/macros_impl.h +++ b/src/tracing/silabs/include/matter/tracing/macros_impl.h @@ -22,4 +22,4 @@ #error "Tracing macros seem to be double defined" #endif -#include +#include