Skip to content

Commit 1101778

Browse files
erjiaqingpull[bot]
authored andcommitted
[IM] Update GetMinSubscriptionsPerFabric (#20207)
1 parent f933501 commit 1101778

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/app/InteractionModelEngine.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <cinttypes>
2929

3030
#include <lib/core/CHIPTLVUtilities.hpp>
31+
#include <lib/support/CodeUtils.h>
3132

3233
extern bool emberAfContainsAttribute(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId);
3334

@@ -1370,19 +1371,14 @@ bool InteractionModelEngine::HasActiveRead()
13701371
}) == Loop::Break));
13711372
}
13721373

1373-
uint16_t InteractionModelEngine::GetMinSubscriptionsPerFabric() const
1374+
uint16_t InteractionModelEngine::GetMinGuaranteedSubscriptionsPerFabric() const
13741375
{
1375-
uint8_t fabricCount = mpFabricTable->FabricCount();
1376-
const size_t readHandlerPoolCapacity = GetReadHandlerPoolCapacityForSubscriptions();
1377-
1378-
if (fabricCount == 0)
1379-
{
1380-
return kMinSupportedSubscriptionsPerFabric;
1381-
}
1382-
1383-
size_t perFabricSubscriptionCapacity = readHandlerPoolCapacity / fabricCount;
1384-
1385-
return static_cast<uint16_t>(perFabricSubscriptionCapacity);
1376+
#if CHIP_SYSTEM_CONFIG_POOL_USE_HEAP
1377+
return UINT16_MAX;
1378+
#else
1379+
return static_cast<uint16_t>(
1380+
min(GetReadHandlerPoolCapacityForSubscriptions() / GetConfigMaxFabrics(), static_cast<size_t>(UINT16_MAX)));
1381+
#endif
13861382
}
13871383

13881384
size_t InteractionModelEngine::GetNumDirtySubscriptions() const

src/app/InteractionModelEngine.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
8787
* Spec 8.5.1 A publisher SHALL always ensure that every fabric the node is commissioned into can create at least three
8888
* subscriptions to the publisher and that each subscription SHALL support at least 3 attribute/event paths.
8989
*/
90-
static constexpr size_t kMinSupportedSubscriptionsPerFabric = 2;
91-
static constexpr size_t kMinSupportedPathsPerSubscription = 2;
90+
static constexpr size_t kMinSupportedSubscriptionsPerFabric = 3;
91+
static constexpr size_t kMinSupportedPathsPerSubscription = 3;
9292
static constexpr size_t kMinSupportedPathsPerReadRequest = 9;
9393
static constexpr size_t kMinSupportedReadRequestsPerFabric = 1;
9494
static constexpr size_t kReadHandlerPoolSize = CHIP_IM_MAX_NUM_SUBSCRIPTIONS + CHIP_IM_MAX_NUM_READS;
@@ -260,7 +260,13 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
260260
*/
261261
bool TrimFabricForRead(FabricIndex aFabricIndex);
262262

263-
uint16_t GetMinSubscriptionsPerFabric() const;
263+
/**
264+
* Returns the minimal value of guaranteed subscriptions per fabic. UINT16_MAX will be returned if current app is configured to
265+
* use heap for the object pools used by interaction model engine.
266+
*
267+
* @retval the minimal value of guaranteed subscriptions per fabic.
268+
*/
269+
uint16_t GetMinGuaranteedSubscriptionsPerFabric() const;
264270

265271
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
266272
//

src/app/clusters/basic/basic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ CHIP_ERROR BasicAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attrib
275275
constexpr uint16_t kMinCaseSessionsPerFabricMandatedBySpec = 3;
276276

277277
capabilityMinima.caseSessionsPerFabric = kMinCaseSessionsPerFabricMandatedBySpec;
278-
capabilityMinima.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinSubscriptionsPerFabric();
278+
capabilityMinima.subscriptionsPerFabric = InteractionModelEngine::GetInstance()->GetMinGuaranteedSubscriptionsPerFabric();
279279

280280
status = aEncoder.Encode(capabilityMinima);
281281
break;

0 commit comments

Comments
 (0)