Skip to content

Commit 6e739b5

Browse files
andriymoroz-mlnxlguohan
authored andcommitted
[crmorch]: Implement CRM feature (sonic-net#447)
Signed-off-by: Volodymyr Samotiy <[email protected]>
1 parent e32212a commit 6e739b5

12 files changed

+889
-10
lines changed

orchagent/Makefile.am

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ orchagent_SOURCES = \
3434
fdborch.cpp \
3535
aclorch.cpp \
3636
saihelper.cpp \
37-
switchorch.cpp \
37+
switchorch.cpp \
3838
pfcwdorch.cpp \
3939
pfcactionhandler.cpp \
40+
crmorch.cpp \
4041
request_parser.cpp \
4142
vrforch.cpp \
4243
acltable.h \
@@ -58,9 +59,10 @@ orchagent_SOURCES = \
5859
qosorch.h \
5960
routeorch.h \
6061
saihelper.h \
61-
switchorch.h \
62+
switchorch.h \
6263
swssnet.h \
6364
tunneldecaporch.h \
65+
crmorch.h
6466
request_parser.h \
6567
vrforch.h
6668

orchagent/aclorch.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "ipprefix.h"
88
#include "converter.h"
99
#include "timer.h"
10+
#include "crmorch.h"
1011

1112
using namespace std;
1213
using namespace swss;
@@ -26,6 +27,7 @@ extern sai_port_api_t* sai_port_api;
2627
extern sai_switch_api_t* sai_switch_api;
2728
extern sai_object_id_t gSwitchId;
2829
extern PortsOrch* gPortsOrch;
30+
extern CrmOrch *gCrmOrch;
2931

3032
acl_rule_attr_lookup_t aclMatchLookup =
3133
{
@@ -368,6 +370,8 @@ bool AclRule::create()
368370
decreaseNextHopRefCount();
369371
}
370372

373+
gCrmOrch->incCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_ENTRY, m_tableOid);
374+
371375
return (status == SAI_STATUS_SUCCESS);
372376
}
373377

@@ -412,6 +416,8 @@ bool AclRule::remove()
412416
return false;
413417
}
414418

419+
gCrmOrch->decCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_ENTRY, m_tableOid);
420+
415421
m_ruleOid = SAI_NULL_OBJECT_ID;
416422

417423
decreaseNextHopRefCount();
@@ -505,6 +511,8 @@ bool AclRule::createCounter()
505511
return false;
506512
}
507513

514+
gCrmOrch->incCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_COUNTER, m_tableOid);
515+
508516
return true;
509517
}
510518

@@ -537,6 +545,8 @@ bool AclRule::removeCounter()
537545
return false;
538546
}
539547

548+
gCrmOrch->decCrmAclTableUsedCounter(CrmResourceType::CRM_ACL_COUNTER, m_tableOid);
549+
540550
SWSS_LOG_INFO("Removing record about the counter %lX from the DB", m_counterOid);
541551
AclOrch::getCountersTable().del(getTableId() + ":" + getId());
542552

@@ -973,6 +983,12 @@ bool AclTable::create()
973983
}
974984

975985
sai_status_t status = sai_acl_api->create_acl_table(&m_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data());
986+
987+
if (status == SAI_STATUS_SUCCESS)
988+
{
989+
gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, (sai_acl_stage_t) attr.value.s32, SAI_ACL_BIND_POINT_TYPE_PORT);
990+
}
991+
976992
return status == SAI_STATUS_SUCCESS;
977993
}
978994

@@ -1388,6 +1404,10 @@ bool AclOrch::removeAclTable(string table_id)
13881404
{
13891405
SWSS_LOG_NOTICE("Successfully deleted ACL table %s", table_id.c_str());
13901406
m_AclTables.erase(table_oid);
1407+
1408+
sai_acl_stage_t stage = (m_AclTables[table_oid].stage == ACL_STAGE_INGRESS) ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
1409+
gCrmOrch->decCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, stage, SAI_ACL_BIND_POINT_TYPE_PORT, table_oid);
1410+
13911411
return true;
13921412
}
13931413
else

0 commit comments

Comments
 (0)