Skip to content

Commit

Permalink
[crmorch]: Implement CRM feature (sonic-net#447)
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Samotiy <[email protected]>
  • Loading branch information
andriymoroz-mlnx authored and lguohan committed Mar 5, 2018
1 parent e32212a commit 6e739b5
Show file tree
Hide file tree
Showing 12 changed files with 889 additions and 10 deletions.
6 changes: 4 additions & 2 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ orchagent_SOURCES = \
fdborch.cpp \
aclorch.cpp \
saihelper.cpp \
switchorch.cpp \
switchorch.cpp \
pfcwdorch.cpp \
pfcactionhandler.cpp \
crmorch.cpp \
request_parser.cpp \
vrforch.cpp \
acltable.h \
Expand All @@ -58,9 +59,10 @@ orchagent_SOURCES = \
qosorch.h \
routeorch.h \
saihelper.h \
switchorch.h \
switchorch.h \
swssnet.h \
tunneldecaporch.h \
crmorch.h
request_parser.h \
vrforch.h

Expand Down
20 changes: 20 additions & 0 deletions orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ipprefix.h"
#include "converter.h"
#include "timer.h"
#include "crmorch.h"

using namespace std;
using namespace swss;
Expand All @@ -26,6 +27,7 @@ extern sai_port_api_t* sai_port_api;
extern sai_switch_api_t* sai_switch_api;
extern sai_object_id_t gSwitchId;
extern PortsOrch* gPortsOrch;
extern CrmOrch *gCrmOrch;

acl_rule_attr_lookup_t aclMatchLookup =
{
Expand Down Expand Up @@ -368,6 +370,8 @@ bool AclRule::create()
decreaseNextHopRefCount();
}

gCrmOrch->incCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_ENTRY, m_tableOid);

return (status == SAI_STATUS_SUCCESS);
}

Expand Down Expand Up @@ -412,6 +416,8 @@ bool AclRule::remove()
return false;
}

gCrmOrch->decCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_ENTRY, m_tableOid);

m_ruleOid = SAI_NULL_OBJECT_ID;

decreaseNextHopRefCount();
Expand Down Expand Up @@ -505,6 +511,8 @@ bool AclRule::createCounter()
return false;
}

gCrmOrch->incCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_COUNTER, m_tableOid);

return true;
}

Expand Down Expand Up @@ -537,6 +545,8 @@ bool AclRule::removeCounter()
return false;
}

gCrmOrch->decCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_COUNTER, m_tableOid);

SWSS_LOG_INFO("Removing record about the counter %lX from the DB", m_counterOid);
AclOrch::getCountersTable().del(getTableId() + ":" + getId());

Expand Down Expand Up @@ -973,6 +983,12 @@ bool AclTable::create()
}

sai_status_t status = sai_acl_api->create_acl_table(&m_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data());

if (status == SAI_STATUS_SUCCESS)
{
gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, (sai_acl_stage_t) attr.value.s32, SAI_ACL_BIND_POINT_TYPE_PORT);
}

return status == SAI_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -1388,6 +1404,10 @@ bool AclOrch::removeAclTable(string table_id)
{
SWSS_LOG_NOTICE("Successfully deleted ACL table %s", table_id.c_str());
m_AclTables.erase(table_oid);

sai_acl_stage_t stage = (m_AclTables[table_oid].stage == ACL_STAGE_INGRESS) ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
gCrmOrch->decCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, stage, SAI_ACL_BIND_POINT_TYPE_PORT, table_oid);

return true;
}
else
Expand Down
Loading

0 comments on commit 6e739b5

Please sign in to comment.