Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
95 changes: 94 additions & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3173,7 +3173,6 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
m_L3V4V6Capability[ACL_STAGE_INGRESS] ? "yes" : "no",
m_L3V4V6Capability[ACL_STAGE_EGRESS] ? "yes" : "no");


// In Mellanox platform, V4 and V6 rules are stored in different tables
// In Broadcom DNX platform also, V4 and V6 rules are stored in different tables
if (platform == MLNX_PLATFORM_SUBSTRING ||
Expand All @@ -3189,6 +3188,100 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
m_isCombinedMirrorV6Table = true;
}

if (platform == VS_PLATFORM_SUBSTRING)
{
// For testing on VS the following values will be used.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please dont use magic numbers

m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_RANGE_CAPABLE] = "true";
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MIN] = "1";
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MAX] = "7";
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ATTR_META_CAPABLE] = "true";
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ACTION_META_CAPABLE] = "true";
}
else
{
// check switch capability of Metadata attribute, action and range.
// SAI_SWITCH_ATTR_ACL_USER_META_DATA_RANGE support and range values.
// SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA
// SAI_ACL_ENTRY_ATTR_FIELD_ACL_USER_META

sai_status_t status = SAI_STATUS_SUCCESS;
sai_attr_capability_t capability;
uint16_t metadataMin = 0;
uint16_t metadataMax = 0;
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MIN] = "0";
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MAX] = "0";
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_RANGE_CAPABLE] = "false";
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ATTR_META_CAPABLE] = "false";
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ACTION_META_CAPABLE] = "false";

status = sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_ACL_USER_META_DATA_RANGE, &capability);
// Disabling these blocks to stop coverage analysis failure. The subsequent PR will enable these.
// if (status != SAI_STATUS_SUCCESS)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No commented code per guidelines

// {
// SWSS_LOG_WARN("Could not query ACL_USER_META_DATA_RANGE %d", status);
// }
// else
if (status == SAI_STATUS_SUCCESS)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code commented out is required. Is there any other way to resolve the code coverage issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have not found a way to resolve this by other means. This is initialization code. The Vs environment does not populate these. There are VS tests in the 2nd PR which cover these values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it can't be covered by UT in anyways, can you try to bypass the check as it's a test issue? It doesn't make sense to remove feature code for UT coverage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@prsunny Can you please comment?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

agree, please refer to other PRs with capability query support added

{
if (capability.get_implemented)
{
sai_attribute_t attrs[1];
attrs[0].id = SAI_SWITCH_ATTR_ACL_USER_META_DATA_RANGE;
sai_status_t status = sai_switch_api->get_switch_attribute(gSwitchId, 2, attrs);
// Disabling these blocks to stop coverage analysis failure. The subsequent PR will enable these.
// if (status != SAI_STATUS_SUCCESS)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here. no commented code. I think this PR is still in draft state

// {
// SWSS_LOG_WARN("Could not get range for ACL_USER_META_DATA_RANGE %d", status);
// }
// else
if (status == SAI_STATUS_SUCCESS)
{
// SWSS_LOG_NOTICE("ACL_USER_META_DATA_RANGE, min: %u, max: %u", attrs[0].value.u32range.min, attrs[0].value.u32range.max);
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_RANGE_CAPABLE] = "true";
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MIN] = std::to_string(attrs[0].value.u32range.min);
m_switchMetaDataCapabilities[TABLE_ACL_USER_META_DATA_MAX] = std::to_string(attrs[0].value.u32range.max);
metadataMin = uint16_t(attrs[0].value.u32range.min);
metadataMax = uint16_t(attrs[0].value.u32range.max);
}

}
SWSS_LOG_NOTICE("ACL_USER_META_DATA_RANGE capability %d", capability.get_implemented);
}
status = sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_ACL_ENTRY, SAI_ACL_ENTRY_ATTR_FIELD_ACL_USER_META, &capability);
// Disabling these blocks to stop coverage analysis failure. The subsequent PR will enable these.
// if (status != SAI_STATUS_SUCCESS)
// {
// SWSS_LOG_WARN("Could not query ACL_ENTRY_ATTR_FIELD_ACL_USER_META %d", status);
// }
// else
if (status == SAI_STATUS_SUCCESS)
{
if (capability.set_implemented)
{
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ATTR_META_CAPABLE] = "true";
}
SWSS_LOG_NOTICE("ACL_ENTRY_ATTR_FIELD_ACL_USER_META capability %d", capability.set_implemented);
}

status = sai_query_attribute_capability(gSwitchId, SAI_OBJECT_TYPE_ACL_ENTRY, SAI_ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA, &capability);
// Disabling these blocks to stop coverage analysis failure. The subsequent PR will enable these.
// if (status != SAI_STATUS_SUCCESS)
// {
// SWSS_LOG_WARN("Could not query ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA %d", status);
// }
// else
if (status == SAI_STATUS_SUCCESS)
{
if (capability.set_implemented)
{
m_switchMetaDataCapabilities[TABLE_ACL_ENTRY_ACTION_META_CAPABLE] = "true";
}
SWSS_LOG_NOTICE("ACL_ENTRY_ATTR_ACTION_SET_ACL_META_DATA capability %d", capability.set_implemented);
}
// The following lines would be replaced in the next PR where these values would be used to initialze the metadataMgr.
(void)metadataMin;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove unused params. This can also fail the coverage.

(void)metadataMax;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we remove these two variables if they are not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They are used in the 2nd PR. which #3307.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then can we add these variables in the 2nd PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the 2nd PR is a child of this PR. In an effort to make the review easier, I created this PR first. the 2nd PR branch is a child of this branch. once this goes in, it would use these variables.

}

// Store the capabilities in state database
// TODO: Move this part of the code into syncd
Expand Down
9 changes: 8 additions & 1 deletion orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@

#define ACL_COUNTER_FLEX_COUNTER_GROUP "ACL_STAT_COUNTER"

#define TABLE_ACL_USER_META_DATA_RANGE_CAPABLE "ACL_USER_META_DATA_RANGE_CAPABLE"
#define TABLE_ACL_USER_META_DATA_MIN "ACL_USER_META_DATA_MIN"
#define TABLE_ACL_USER_META_DATA_MAX "ACL_USER_META_DATA_MAX"
#define TABLE_ACL_ENTRY_ATTR_META_CAPABLE "ACL_ENTRY_ATTR_META_CAPABLE"
#define TABLE_ACL_ENTRY_ACTION_META_CAPABLE "ACL_ENTRY_ACTION_META_CAPABLE"

enum AclObjectStatus
{
ACTIVE = 0,
Expand Down Expand Up @@ -516,7 +522,8 @@ class AclOrch : public Orch, public Observer
bool m_isCombinedMirrorV6Table = true;
map<string, bool> m_mirrorTableCapabilities;
map<acl_stage_type_t, bool> m_L3V4V6Capability;

map<string, string> m_switchMetaDataCapabilities;

void registerFlexCounter(const AclRule& rule);
void deregisterFlexCounter(const AclRule& rule);

Expand Down