diff options
author | Zhanglong Xia <zhanglongxia@google.com> | 2023-12-18 07:09:58 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-18 07:09:58 +0000 |
commit | f39d4f7950752efa3423733d0e0f404f0fa86c7b (patch) | |
tree | 5240c776c5cc0af081cd1b57ae554a56d92cd4bb | |
parent | 4d9017d2318427f64e7d9e19b8e381d3be96c674 (diff) | |
parent | d62848a5f3682dfc302a000a8de7865e51aaa256 (diff) | |
download | openthread-f39d4f7950752efa3423733d0e0f404f0fa86c7b.tar.gz |
Merge "add the RCP interface metrics support" into main am: d62848a5f3
Original change: https://android-review.googlesource.com/c/platform/external/openthread/+/2846896
Change-Id: I2db490e927974b9ad2b095c273cc9e2f019a7367
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | src/android/thread_network_hal/hal_interface.cpp | 16 | ||||
-rw-r--r-- | src/android/thread_network_hal/hal_interface.hpp | 28 | ||||
-rw-r--r-- | src/android/thread_network_hal/vendor_interface.cpp | 5 |
3 files changed, 38 insertions, 11 deletions
diff --git a/src/android/thread_network_hal/hal_interface.cpp b/src/android/thread_network_hal/hal_interface.cpp index a4bb7928e..f1de827f0 100644 --- a/src/android/thread_network_hal/hal_interface.cpp +++ b/src/android/thread_network_hal/hal_interface.cpp @@ -62,6 +62,8 @@ HalInterface::HalInterface(const Url::Url &aRadioUrl) , mHalInterfaceId(0) { IgnoreError(aRadioUrl.ParseUint8("id", mHalInterfaceId)); + memset(&mInterfaceMetrics, 0, sizeof(mInterfaceMetrics)); + mInterfaceMetrics.mRcpInterfaceType = kSpinelInterfaceTypeVendor; } otError HalInterface::Init(SpinelInterface::ReceiveFrameCallback aCallback, @@ -227,6 +229,12 @@ otError HalInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) otLogWarnPlat("[HAL] Send frame to HAL interface failed: %s", otThreadErrorToString(error)); exit: + if (error == OT_ERROR_NONE) + { + mInterfaceMetrics.mTxFrameCount++; + mInterfaceMetrics.mTxFrameByteCount += aLength; + } + return error; } @@ -243,7 +251,7 @@ void HalInterface::ReceiveFrameCallback(const std::vector<uint8_t> &aFrame) { otLogNotePlat("[HAL] Drop the received spinel frame: %s", otThreadErrorToString(error)); mRxFrameBuffer->DiscardFrame(); - ExitNow(); + ExitNow(error = OT_ERROR_NO_BUFS); } } @@ -253,6 +261,12 @@ void HalInterface::ReceiveFrameCallback(const std::vector<uint8_t> &aFrame) } exit: + if (error == OT_ERROR_NONE) + { + mInterfaceMetrics.mRxFrameCount++; + mInterfaceMetrics.mRxFrameByteCount += aFrame.size(); + } + return; } diff --git a/src/android/thread_network_hal/hal_interface.hpp b/src/android/thread_network_hal/hal_interface.hpp index 07331e45d..ef72d0545 100644 --- a/src/android/thread_network_hal/hal_interface.hpp +++ b/src/android/thread_network_hal/hal_interface.hpp @@ -54,7 +54,7 @@ namespace Posix { * This class defines an IPC Binder interface to the Radio Co-processor (RCP). * */ -class HalInterface +class HalInterface : public ot::Spinel::SpinelInterface { public: /** @@ -87,13 +87,13 @@ public: */ otError Init(Spinel::SpinelInterface::ReceiveFrameCallback aCallback, void *aCallbackContext, - Spinel::SpinelInterface::RxFrameBuffer &aFrameBuffer); + Spinel::SpinelInterface::RxFrameBuffer &aFrameBuffer) override; /** * This method deinitializes the interface to the RCP. * */ - void Deinit(void); + void Deinit(void) override; /** * This method encodes and sends a spinel frame to Radio Co-processor (RCP) over the socket. @@ -107,7 +107,7 @@ public: * @retval OT_ERROR_FAILED Failed to call the HAL to send the frame. * */ - otError SendFrame(const uint8_t *aFrame, uint16_t aLength); + otError SendFrame(const uint8_t *aFrame, uint16_t aLength) override; /** * This method waits for receiving part or all of spinel frame within specified interval. @@ -118,7 +118,7 @@ public: * @retval OT_ERROR_RESPONSE_TIMEOUT No spinel frame is received within @p aTimeout. * */ - otError WaitForFrame(uint64_t aTimeoutUs); + otError WaitForFrame(uint64_t aTimeoutUs) override; /** * This method updates the file descriptor sets with file descriptors used by the radio driver. @@ -126,7 +126,7 @@ public: * @param[in] aMainloopContext The context containing fd_sets. * */ - void UpdateFdSet(void *aMainloopContext); + void UpdateFdSet(void *aMainloopContext) override; /** * This method performs radio driver processing. @@ -134,7 +134,7 @@ public: * @param[in] aMainloopContext The context containing fd_sets. * */ - void Process(const void *aMainloopContext); + void Process(const void *aMainloopContext) override; /** * This method returns the bus speed between the host and the radio. @@ -142,7 +142,7 @@ public: * @returns Bus speed in bits/second. * */ - uint32_t GetBusSpeed(void) const; + uint32_t GetBusSpeed(void) const override; /** * This method hardware resets the RCP. It will be called after a software reset fails. @@ -151,7 +151,15 @@ public: * @retval OT_ERROR_NOT_IMPLEMENT The hardware reset is not implemented. * */ - otError HardwareReset(void); + otError HardwareReset(void) override; + + /** + * Returns the RCP interface metrics. + * + * @returns The RCP interface metrics. + * + */ + const otRcpInterfaceMetrics *GetRcpInterfaceMetrics(void) const override { return &mInterfaceMetrics; } private: void ReceiveFrameCallback(const std::vector<uint8_t> &aFrame); @@ -185,6 +193,8 @@ private: void *mRxFrameContext; Spinel::SpinelInterface::RxFrameBuffer *mRxFrameBuffer; + otRcpInterfaceMetrics mInterfaceMetrics; + std::shared_ptr<::aidl::android::hardware::threadnetwork::IThreadChip> mThreadChip; std::shared_ptr<::aidl::android::hardware::threadnetwork::IThreadChipCallback> mThreadChipCallback; diff --git a/src/android/thread_network_hal/vendor_interface.cpp b/src/android/thread_network_hal/vendor_interface.cpp index fca1ae642..6fbc8cf4c 100644 --- a/src/android/thread_network_hal/vendor_interface.cpp +++ b/src/android/thread_network_hal/vendor_interface.cpp @@ -86,7 +86,10 @@ otError VendorInterface::SendFrame(const uint8_t *aFrame, uint16_t aLength) otError VendorInterface::HardwareReset(void) { return sHalInterface->HardwareReset(); } -const otRcpInterfaceMetrics *VendorInterface::GetRcpInterfaceMetrics(void) const { return nullptr; } +const otRcpInterfaceMetrics *VendorInterface::GetRcpInterfaceMetrics(void) const +{ + return sHalInterface->GetRcpInterfaceMetrics(); +} } // namespace Posix } // namespace ot |