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

[vslib] add support for ACL table available entry/counter attributes #4

Closed
wants to merge 1 commit into from
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
47 changes: 47 additions & 0 deletions vslib/SwitchStateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2273,6 +2273,43 @@ sai_status_t SwitchStateBase::refresh_port_oper_speed(
return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchStateBase::refresh_acl_table_entries(
_In_ sai_object_id_t acl_table_id)
{
std::vector<sai_object_id_t> acl_entries;

sai_attribute_t attr;
attr.id = SAI_ACL_ENTRY_ATTR_TABLE_ID;
attr.value.oid = acl_table_id;
findObjects(SAI_OBJECT_TYPE_ACL_ENTRY, attr, acl_entries);

attr.id = SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_ENTRY;
attr.value.u32 = m_maxAclTableEntries - (uint32_t) acl_entries.size();

CHECK_STATUS(set(SAI_OBJECT_TYPE_ACL_TABLE, acl_table_id, &attr));

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchStateBase::refresh_acl_table_counters(
_In_ sai_object_id_t acl_table_id)
{
std::vector<sai_object_id_t> acl_counters;

sai_attribute_t attr;
attr.id = SAI_ACL_COUNTER_ATTR_TABLE_ID;
attr.value.oid = acl_table_id;
findObjects(SAI_OBJECT_TYPE_ACL_COUNTER, attr, acl_counters);

attr.id = SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_COUNTER;
attr.value.u32 = m_maxAclTableCounters - (uint32_t) acl_counters.size();

CHECK_STATUS(set(SAI_OBJECT_TYPE_ACL_TABLE, acl_table_id, &attr));

return SAI_STATUS_SUCCESS;
}


// XXX extra work may be needed on GET api if N on list will be > then actual

/*
Expand Down Expand Up @@ -2450,6 +2487,16 @@ sai_status_t SwitchStateBase::refresh_read_only(
return refresh_macsec_sa_stat(object_id);
}

if (meta->objecttype == SAI_OBJECT_TYPE_ACL_TABLE && meta->attrid == SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_ENTRY)
{
return refresh_acl_table_entries(object_id);
}

if (meta->objecttype == SAI_OBJECT_TYPE_ACL_TABLE && meta->attrid == SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_COUNTER)
{
return refresh_acl_table_counters(object_id);
}

auto mmeta = m_meta.lock();

if (mmeta)
Expand Down
7 changes: 7 additions & 0 deletions vslib/SwitchStateBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ namespace saivs
virtual sai_status_t refresh_port_oper_speed(
_In_ sai_object_id_t port_id);

virtual sai_status_t refresh_acl_table_entries(
_In_ sai_object_id_t acl_table_id);

virtual sai_status_t refresh_acl_table_counters(
_In_ sai_object_id_t acl_table_id);
public:

virtual sai_status_t warm_boot_initialize_objects();
Expand Down Expand Up @@ -680,6 +685,8 @@ namespace saivs

constexpr static const int m_maxAclTables = 3;
constexpr static const int m_maxAclTableGroups = 200;
constexpr static const int m_maxAclTableEntries = 1000;
constexpr static const int m_maxAclTableCounters = 1000;

protected:

Expand Down