Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CRM][DASH] Add the possibility of querying availability for OIDs. #1245

Merged
merged 7 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Comment on lines +850 to +858
Copy link
Collaborator

@kcudnik kcudnik Aug 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why those specific types ? do they need to be listed explicitly, seems like all of t hem are experimental objects, maybe you could use compare ?
you could get object_info from sai_metadata_get_object_type_info(ot) (check for null) on top of the function and then use info->isexperimental flag,
or if objectType >= SAI_OBJECT_TYPE_MAX

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are the DASH objects that we use and want to test in CRM DASH VS tests. Not all experimental objects are resources, so info->isexperimental flag and objectType >= SAI_OBJECT_TYPE_MAX are redundant.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then use flag md->isresourcetype ?

{
*count = 100000;
return SAI_STATUS_SUCCESS;
}

return SAI_STATUS_NOT_SUPPORTED;
}
Expand Down