mirror of
https://github.com/espressif/openthread.git
synced 2026-08-05 02:17:47 +00:00
[ncp] add a new spinel property to get all MAC counters (#2489)
This commit is contained in:
committed by
Jonathan Hui
parent
c2d22744c0
commit
23069bbeec
@@ -1017,7 +1017,7 @@ typedef struct otMacCounters
|
||||
uint32_t mRxAddressFiltered; ///< The number of received packets filtered by address filter (whitelist or blacklist).
|
||||
uint32_t mRxDestAddrFiltered; ///< The number of received packets filtered by destination check.
|
||||
uint32_t mRxDuplicated; ///< The number of received duplicated packets.
|
||||
uint32_t mRxErrNoFrame; ///< The number of received packets that do not contain contents.
|
||||
uint32_t mRxErrNoFrame; ///< The number of received packets with no or malformed content.
|
||||
uint32_t mRxErrUnknownNeighbor; ///< The number of received packets from unknown neighbor.
|
||||
uint32_t mRxErrInvalidSrcAddr; ///< The number of received packets whose source address is invalid.
|
||||
uint32_t mRxErrSec; ///< The number of received packets with security error.
|
||||
|
||||
@@ -197,6 +197,7 @@ const NcpBase::PropertyHandlerEntry NcpBase::mGetPropertyHandlerTable[] =
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_BAD_FCS),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_ERR_OTHER),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_RX_PKT_DUP),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_ALL_MAC_COUNTERS),
|
||||
// NCP counters
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_IP_SEC_TOTAL),
|
||||
NCP_GET_PROP_HANDLER_ENTRY(CNTR_TX_IP_INSEC_TOTAL),
|
||||
|
||||
@@ -529,6 +529,7 @@ protected:
|
||||
NCP_GET_PROP_HANDLER(THREAD_ACTIVE_DATASET);
|
||||
NCP_GET_PROP_HANDLER(THREAD_PENDING_DATASET);
|
||||
|
||||
NCP_GET_PROP_HANDLER(CNTR_ALL_MAC_COUNTERS);
|
||||
NCP_GET_PROP_HANDLER(CNTR_TX_PKT_TOTAL);
|
||||
NCP_GET_PROP_HANDLER(CNTR_TX_PKT_ACK_REQ);
|
||||
NCP_GET_PROP_HANDLER(CNTR_TX_PKT_ACKED);
|
||||
|
||||
@@ -1771,6 +1771,61 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
otError NcpBase::GetPropertyHandler_CNTR_ALL_MAC_COUNTERS(void)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
const otMacCounters *counters = otLinkGetCounters(mInstance);
|
||||
|
||||
if (counters == NULL)
|
||||
{
|
||||
error = mEncoder.OverwriteWithLastStatusError(SPINEL_STATUS_INVALID_COMMAND_FOR_PROP);
|
||||
ExitNow();
|
||||
}
|
||||
|
||||
// Encode Tx related counters
|
||||
SuccessOrExit(error = mEncoder.OpenStruct());
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxTotal));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxUnicast));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxBroadcast));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxAckRequested));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxAcked));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxNoAckRequested));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxData));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxDataPoll));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxBeacon));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxBeaconRequest));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxOther));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxRetry));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrCca));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrAbort));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mTxErrBusyChannel));
|
||||
SuccessOrExit(error = mEncoder.CloseStruct());
|
||||
|
||||
// Encode Rx related counters
|
||||
SuccessOrExit(error = mEncoder.OpenStruct());
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxTotal));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxUnicast));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxBroadcast));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxData));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxDataPoll));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxBeacon));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxBeaconRequest));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxOther));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxAddressFiltered));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxDestAddrFiltered));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxDuplicated));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrNoFrame));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrUnknownNeighbor));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrInvalidSrcAddr));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrSec));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrFcs));
|
||||
SuccessOrExit(error = mEncoder.WriteUint32(counters->mRxErrOther));
|
||||
SuccessOrExit(error = mEncoder.CloseStruct());
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_ENABLE_MAC_FILTER
|
||||
|
||||
otError NcpBase::GetPropertyHandler_MAC_WHITELIST(void)
|
||||
|
||||
@@ -1785,6 +1785,10 @@ spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
|
||||
ret = "PROP_MSG_BUFFER_COUNTERS";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_CNTR_ALL_MAC_COUNTERS:
|
||||
ret = "PROP_CNTR_ALL_MAC_COUNTERS";
|
||||
break;
|
||||
|
||||
case SPINEL_PROP_NEST_STREAM_MFG:
|
||||
ret = "PROP_NEST_STREAM_MFG";
|
||||
break;
|
||||
|
||||
@@ -1647,6 +1647,53 @@ typedef enum
|
||||
*/
|
||||
SPINEL_PROP_MSG_BUFFER_COUNTERS = SPINEL_PROP_CNTR__BEGIN + 400,
|
||||
|
||||
/// All MAC related counters.
|
||||
/** Format: t(A(L))t(A(L)) (Read-only)
|
||||
*
|
||||
* The contents include two structs, first one corresponds to
|
||||
* all transmit related MAC counters, second one provides the
|
||||
* receive related counters.
|
||||
*
|
||||
* The transmit structure includes:
|
||||
*
|
||||
* 'L': TxTotal (The total number of transmissions).
|
||||
* 'L': TxUnicast (The total number of unicast transmissions).
|
||||
* 'L': TxBroadcast (The total number of broadcast transmissions).
|
||||
* 'L': TxAckRequested (The number of transmissions with ack request).
|
||||
* 'L': TxAcked (The number of transmissions that were acked).
|
||||
* 'L': TxNoAckRequested (The number of transmissions without ack request).
|
||||
* 'L': TxData (The number of transmitted data).
|
||||
* 'L': TxDataPoll (The number of transmitted data poll).
|
||||
* 'L': TxBeacon (The number of transmitted beacon).
|
||||
* 'L': TxBeaconRequest (The number of transmitted beacon request).
|
||||
* 'L': TxOther (The number of transmitted other types of frames).
|
||||
* 'L': TxRetry (The number of retransmission times).
|
||||
* 'L': TxErrCca (The number of CCA failure times).
|
||||
* 'L': TxErrAbort (The number of frame transmission failures due to abort error).
|
||||
* 'L': TxErrBusyChannel (The number of frames that were dropped due to a busy channel).
|
||||
*
|
||||
* The receive structure includes:
|
||||
*
|
||||
* 'L': RxTotal (The total number of received packets).
|
||||
* 'L': RxUnicast (The total number of unicast packets received).
|
||||
* 'L': RxBroadcast (The total number of broadcast packets received).
|
||||
* 'L': RxData (The number of received data).
|
||||
* 'L': RxDataPoll (The number of received data poll).
|
||||
* 'L': RxBeacon (The number of received beacon).
|
||||
* 'L': RxBeaconRequest (The number of received beacon request).
|
||||
* 'L': RxOther (The number of received other types of frames).
|
||||
* 'L': RxAddressFiltered (The number of received packets filtered by address filter (whitelist or blacklist)).
|
||||
* 'L': RxDestAddrFiltered (The number of received packets filtered by destination check).
|
||||
* 'L': RxDuplicated (The number of received duplicated packets).
|
||||
* 'L': RxErrNoFrame (The number of received packets with no or malformed content).
|
||||
* 'L': RxErrUnknownNeighbor (The number of received packets from unknown neighbor).
|
||||
* 'L': RxErrInvalidSrcAddr (The number of received packets whose source address is invalid).
|
||||
* 'L': RxErrSec (The number of received packets with security error).
|
||||
* 'L': RxErrFcs (The number of received packets with FCS error).
|
||||
* 'L': RxErrOther (The number of received packets with other error).
|
||||
*/
|
||||
SPINEL_PROP_CNTR_ALL_MAC_COUNTERS = SPINEL_PROP_CNTR__BEGIN + 401,
|
||||
|
||||
SPINEL_PROP_CNTR__END = 2048,
|
||||
|
||||
SPINEL_PROP_NEST__BEGIN = 15296,
|
||||
|
||||
Reference in New Issue
Block a user