From 18cd02e6b12fb6fb42f19a2fa9716df5767746a8 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Thu, 8 Aug 2019 08:31:12 -0700 Subject: [PATCH] [mac] update the log message for frame tx failure (#4059) The new model handles the case where frame retries are not handled by sub-mac layer (e.g., delegated to radio platform). This helps improve the log message in posix-app model where the retx is handled by the RCP and not on the host side. --- src/core/mac/mac.cpp | 13 ++++++++----- src/core/mac/mac.hpp | 2 +- src/core/mac/sub_mac.hpp | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/mac/mac.cpp b/src/core/mac/mac.cpp index 7623e73a4..26e93f21b 100644 --- a/src/core/mac/mac.cpp +++ b/src/core/mac/mac.cpp @@ -1182,7 +1182,7 @@ void Mac::RecordFrameTransmitStatus(const TxFrame &aFrame, if (aError != OT_ERROR_NONE) { - LogFrameTxFailure(aFrame, aError, aRetryCount); + LogFrameTxFailure(aFrame, aError, aRetryCount, aWillRetx); otDumpDebgMac("TX ERR", aFrame.GetHeader(), 16); if (aWillRetx) @@ -1947,10 +1947,13 @@ void Mac::LogFrameRxFailure(const RxFrame *aFrame, otError aError) const } } -void Mac::LogFrameTxFailure(const TxFrame &aFrame, otError aError, uint8_t aRetryCount) const +void Mac::LogFrameTxFailure(const TxFrame &aFrame, otError aError, uint8_t aRetryCount, bool aWillRetx) const { - otLogInfoMac("Frame tx failed, error:%s, retries:%d/%d, %s", otThreadErrorToString(aError), aRetryCount, - aFrame.GetMaxFrameRetries(), aFrame.ToInfoString().AsCString()); + uint8_t maxAttempts = aFrame.GetMaxFrameRetries() + 1; + uint8_t curAttempt = aWillRetx ? (aRetryCount + 1) : maxAttempts; + + otLogInfoMac("Frame tx attempt %d/%d failed, error:%s, %s", curAttempt, maxAttempts, otThreadErrorToString(aError), + aFrame.ToInfoString().AsCString()); } void Mac::LogBeacon(const char *aActionText, const BeaconPayload &aBeaconPayload) const @@ -1968,7 +1971,7 @@ void Mac::LogBeacon(const char *, const BeaconPayload &) const { } -void Mac::LogFrameTxFailure(const TxFrame &, otError, uint8_t) const +void Mac::LogFrameTxFailure(const TxFrame &, otError, uint8_t, bool) const { } diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 57ec6dd9c..d30040114 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -674,7 +674,7 @@ private: void ReportEnergyScanResult(int8_t aRssi); void LogFrameRxFailure(const RxFrame *aFrame, otError aError) const; - void LogFrameTxFailure(const TxFrame &aFrame, otError aError, uint8_t aRetryCount) const; + void LogFrameTxFailure(const TxFrame &aFrame, otError aError, uint8_t aRetryCount, bool aWillRetx) const; void LogBeacon(const char *aActionText, const BeaconPayload &aBeaconPayload) const; #if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE diff --git a/src/core/mac/sub_mac.hpp b/src/core/mac/sub_mac.hpp index 6cdfb4b8e..53bac3ab2 100644 --- a/src/core/mac/sub_mac.hpp +++ b/src/core/mac/sub_mac.hpp @@ -135,7 +135,7 @@ public: * OT_ERROR_NO_ACK when the frame was transmitted but no ACK was received, * OT_ERROR_CHANNEL_ACCESS_FAILURE tx failed due to activity on the channel, * OT_ERROR_ABORT when transmission was aborted for other reasons. - * @param[in] aRetryCount Number of transmission retries for this frame. + * @param[in] aRetryCount Current retry count. This is valid only when sub-mac handles frame re-transmissions. * @param[in] aWillRetx Indicates whether frame will be retransmitted or not. This is applicable only * when there was an error in current transmission attempt. *