Skip to content

Commit

Permalink
[vslib] add support for ACL table available entry/counter attributes
Browse files Browse the repository at this point in the history
Signed-off-by: Yakiv Huryk <[email protected]>
  • Loading branch information
Yakiv-Huryk committed Dec 11, 2023
1 parent e7ad356 commit 482b783
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
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

0 comments on commit 482b783

Please sign in to comment.