Skip to content

Commit

Permalink
[CRM][DASH] Add the possibility of querying availability for OIDs. (#…
Browse files Browse the repository at this point in the history
…1245)

- Add support for DASH resource availability to VirtualSwitchSaiInterface.
  • Loading branch information
oleksandrivantsiv authored Sep 13, 2023
1 parent 9547060 commit 8046908
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,13 @@ sai_status_t Meta::objectTypeGetAvailability(

break;

case SAI_ATTR_VALUE_TYPE_OBJECT_ID:
{
sai_object_type_t ot = objectTypeQuery(attrList[idx].value.oid);
PARAMETER_CHECK_OBJECT_TYPE_VALID(ot);
PARAMETER_CHECK_OID_EXISTS(attrList[idx].value.oid, ot);
break;
}
default:

META_LOG_THROW(*mdp, "value type %s not supported yet, FIXME!",
Expand Down
26 changes: 26 additions & 0 deletions unittest/meta/TestMetaDash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ static void remove_eni(Meta &m, sai_object_id_t eni)
EXPECT_EQ(SAI_STATUS_SUCCESS, m.remove((sai_object_type_t)SAI_OBJECT_TYPE_ENI, eni));
}

TEST(Meta, dash_get_availability)
{
Meta m(std::make_shared<MetaTestSaiInterface>());

sai_object_id_t switchid = create_switch(m);

sai_attribute_t attr;
attr.id = SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID;
attr.value.oid = 0;

uint64_t count = 0;
EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.objectTypeGetAvailability(switchid, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE, 1, &attr, &count));

attr.id = SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID;
attr.value.oid = 0xFFFFFFF;

EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.objectTypeGetAvailability(switchid, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE, 1, &attr, &count));
}


TEST(Meta, quad_dash_direction_lookup)
{
Meta m(std::make_shared<MetaTestSaiInterface>());
Expand Down Expand Up @@ -714,6 +734,12 @@ TEST(Meta, quad_dash_acl_rule)
attr.value.s32 = SAI_DASH_ACL_RULE_ACTION_DENY_AND_CONTINUE;
EXPECT_EQ(SAI_STATUS_SUCCESS, m.set((sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE, acl, &attr));

attr.id = SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID;
attr.value.oid = acl;
uint64_t count = 0;

EXPECT_EQ(SAI_STATUS_SUCCESS, m.objectTypeGetAvailability(switchid, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE, 1, &attr, &count));

EXPECT_EQ(SAI_STATUS_SUCCESS, m.remove((sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE, acl));
remove_counter(m, counter);
EXPECT_EQ(SAI_STATUS_SUCCESS, m.remove((sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_GROUP, group));
Expand Down
13 changes: 13 additions & 0 deletions vslib/VirtualSwitchSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,19 @@ sai_status_t VirtualSwitchSaiInterface::objectTypeGetAvailability(
*count = 512;
return SAI_STATUS_SUCCESS;
}
else if ((objectType == (sai_object_type_t)SAI_OBJECT_TYPE_VNET) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_ENI_ETHER_ADDRESS_MAP_ENTRY) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_INBOUND_ROUTING_ENTRY) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_PA_VALIDATION_ENTRY) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_OUTBOUND_CA_TO_PA_ENTRY) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_GROUP) ||
(objectType == (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE))
{
*count = 100000;
return SAI_STATUS_SUCCESS;
}

return SAI_STATUS_NOT_SUPPORTED;
}
Expand Down

0 comments on commit 8046908

Please sign in to comment.