Skip to content

Commit

Permalink
[spinel] define a new spinel-specific configuration value for source …
Browse files Browse the repository at this point in the history
…match table size

Avoids any confusion with `OPENTHREAD_CONFIG_MLE_MAX_CHILDREN`:

* `OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES` in `openthread-spinel-config.h` defines size of the local source match table used by RadioSpinel when `OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT` is used.
* For OpenThread, the default value of this config is `OPENTHREAD_CONFIG_MLE_MAX_CHILDREN`.
* Other protocols (in case of MultiPAN with spinel) can define whatever value they want for the size of the table using this config.
  • Loading branch information
suveshpratapa committed Oct 4, 2024
1 parent 262b998 commit 5e99dcc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/lib/spinel/openthread-spinel-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@
#define OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT 0
#endif

/**
* @def OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES
*
* Defines size of the local source match table used by RadioSpinel
* when OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT is used.
*/
#ifndef OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES
#define OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
#endif

/**
* @def OPENTHREAD_SPINEL_CONFIG_ABORT_ON_UNEXPECTED_RCP_RESET_ENABLE
*
Expand Down
4 changes: 2 additions & 2 deletions src/lib/spinel/radio_spinel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ otError RadioSpinel::AddSrcMatchShortEntry(uint16_t aShortAddress)
EXPECT_NO_ERROR(error = Insert(SPINEL_PROP_MAC_SRC_MATCH_SHORT_ADDRESSES, SPINEL_DATATYPE_UINT16_S, aShortAddress));

#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0
assert(mSrcMatchShortEntryCount < OPENTHREAD_CONFIG_MLE_MAX_CHILDREN);
assert(mSrcMatchShortEntryCount < OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES);

for (int i = 0; i < mSrcMatchShortEntryCount; ++i)
{
Expand All @@ -1009,7 +1009,7 @@ otError RadioSpinel::AddSrcMatchExtEntry(const otExtAddress &aExtAddress)
Insert(SPINEL_PROP_MAC_SRC_MATCH_EXTENDED_ADDRESSES, SPINEL_DATATYPE_EUI64_S, aExtAddress.m8));

#if OPENTHREAD_SPINEL_CONFIG_RCP_RESTORATION_MAX_COUNT > 0
assert(mSrcMatchExtEntryCount < OPENTHREAD_CONFIG_MLE_MAX_CHILDREN);
assert(mSrcMatchExtEntryCount < OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES);

for (int i = 0; i < mSrcMatchExtEntryCount; ++i)
{
Expand Down
16 changes: 9 additions & 7 deletions src/lib/spinel/radio_spinel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,14 +1213,16 @@ class RadioSpinel : private Logger
uint8_t mRcpFailure : 2; ///< RCP failure reason, should recover and retry operation.

// Properties set by core.
uint8_t mKeyIdMode;
uint8_t mKeyId;
otMacKey mPrevKey;
otMacKey mCurrKey;
otMacKey mNextKey;
uint16_t mSrcMatchShortEntries[OPENTHREAD_CONFIG_MLE_MAX_CHILDREN];
uint8_t mKeyIdMode;
uint8_t mKeyId;
otMacKey mPrevKey;
otMacKey mCurrKey;
otMacKey mNextKey;
static_assert(OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES >= OPENTHREAD_CONFIG_MLE_MAX_CHILDREN,
"SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES is not large enough to cover MLE_MAX_CHILDREN");
uint16_t mSrcMatchShortEntries[OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES];
int16_t mSrcMatchShortEntryCount;
otExtAddress mSrcMatchExtEntries[OPENTHREAD_CONFIG_MLE_MAX_CHILDREN];
otExtAddress mSrcMatchExtEntries[OPENTHREAD_SPINEL_CONFIG_MAX_SRC_MATCH_ENTRIES];
int16_t mSrcMatchExtEntryCount;
uint8_t mScanChannel;
uint16_t mScanDuration;
Expand Down

0 comments on commit 5e99dcc

Please sign in to comment.