Skip to content

Commit 0af226a

Browse files
author
Shuotian Cheng
authored
[aclorch]: Add MIRROR_DSCP table type (#906)
Add MIRROR_DSCP table to support creating an ACL mirro table that only matches DSCP value/mask. Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
1 parent ec047cb commit 0af226a

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

orchagent/aclorch.cpp

+40-8
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ acl_dtel_flow_op_type_lookup_t aclDTelFlowOpTypeLookup =
8686

8787
static acl_table_type_lookup_t aclTableTypeLookUp =
8888
{
89-
{ TABLE_TYPE_L3, ACL_TABLE_L3 },
90-
{ TABLE_TYPE_L3V6, ACL_TABLE_L3V6 },
91-
{ TABLE_TYPE_MIRROR, ACL_TABLE_MIRROR },
92-
{ TABLE_TYPE_MIRRORV6, ACL_TABLE_MIRRORV6 },
93-
{ TABLE_TYPE_CTRLPLANE, ACL_TABLE_CTRLPLANE },
94-
{ TABLE_TYPE_DTEL_FLOW_WATCHLIST, ACL_TABLE_DTEL_FLOW_WATCHLIST },
95-
{ TABLE_TYPE_DTEL_DROP_WATCHLIST, ACL_TABLE_DTEL_DROP_WATCHLIST }
89+
{ TABLE_TYPE_L3, ACL_TABLE_L3 },
90+
{ TABLE_TYPE_L3V6, ACL_TABLE_L3V6 },
91+
{ TABLE_TYPE_MIRROR, ACL_TABLE_MIRROR },
92+
{ TABLE_TYPE_MIRRORV6, ACL_TABLE_MIRRORV6 },
93+
{ TABLE_TYPE_MIRROR_DSCP, ACL_TABLE_MIRROR_DSCP },
94+
{ TABLE_TYPE_CTRLPLANE, ACL_TABLE_CTRLPLANE },
95+
{ TABLE_TYPE_DTEL_FLOW_WATCHLIST, ACL_TABLE_DTEL_FLOW_WATCHLIST },
96+
{ TABLE_TYPE_DTEL_DROP_WATCHLIST, ACL_TABLE_DTEL_DROP_WATCHLIST }
9697
};
9798

9899
static acl_stage_type_lookup_t aclStageLookUp =
@@ -604,6 +605,7 @@ shared_ptr<AclRule> AclRule::makeShared(acl_table_type_t type, AclOrch *acl, Mir
604605
type != ACL_TABLE_L3V6 &&
605606
type != ACL_TABLE_MIRROR &&
606607
type != ACL_TABLE_MIRRORV6 &&
608+
type != ACL_TABLE_MIRROR_DSCP &&
607609
type != ACL_TABLE_DTEL_FLOW_WATCHLIST &&
608610
type != ACL_TABLE_DTEL_DROP_WATCHLIST)
609611
{
@@ -974,7 +976,14 @@ bool AclRuleMirror::validateAddMatch(string attr_name, string attr_value)
974976
if ((m_tableType == ACL_TABLE_L3 || m_tableType == ACL_TABLE_L3V6)
975977
&& attr_name == MATCH_DSCP)
976978
{
977-
SWSS_LOG_ERROR("DSCP match is not supported for the tables of type L3");
979+
SWSS_LOG_ERROR("DSCP match is not supported for the table of type L3");
980+
return false;
981+
}
982+
983+
if ((m_tableType == ACL_TABLE_MIRROR_DSCP && attr_name != MATCH_DSCP))
984+
{
985+
SWSS_LOG_ERROR("%s match is not supported for the table of type MIRROR_DSCP",
986+
attr_name.c_str());
978987
return false;
979988
}
980989

@@ -1188,6 +1197,29 @@ bool AclTable::create()
11881197
return status == SAI_STATUS_SUCCESS;
11891198
}
11901199

1200+
if (type == ACL_TABLE_MIRROR_DSCP)
1201+
{
1202+
attr.id = SAI_ACL_TABLE_ATTR_FIELD_DSCP;
1203+
attr.value.booldata = true;
1204+
table_attrs.push_back(attr);
1205+
1206+
attr.id = SAI_ACL_TABLE_ATTR_ACL_STAGE;
1207+
attr.value.s32 = stage == ACL_STAGE_INGRESS
1208+
? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
1209+
table_attrs.push_back(attr);
1210+
1211+
sai_status_t status = sai_acl_api->create_acl_table(
1212+
&m_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data());
1213+
1214+
if (status == SAI_STATUS_SUCCESS)
1215+
{
1216+
gCrmOrch->incCrmAclUsedCounter(
1217+
CrmResourceType::CRM_ACL_TABLE, (sai_acl_stage_t)attr.value.s32, SAI_ACL_BIND_POINT_TYPE_PORT);
1218+
}
1219+
1220+
return status == SAI_STATUS_SUCCESS;
1221+
}
1222+
11911223
if (type != ACL_TABLE_MIRRORV6)
11921224
{
11931225
attr.id = SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE;

orchagent/aclorch.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define TABLE_TYPE_L3V6 "L3V6"
2929
#define TABLE_TYPE_MIRROR "MIRROR"
3030
#define TABLE_TYPE_MIRRORV6 "MIRRORV6"
31+
#define TABLE_TYPE_MIRROR_DSCP "MIRROR_DSCP"
3132
#define TABLE_TYPE_PFCWD "PFCWD"
3233
#define TABLE_TYPE_CTRLPLANE "CTRLPLANE"
3334
#define TABLE_TYPE_DTEL_FLOW_WATCHLIST "DTEL_FLOW_WATCHLIST"
@@ -101,6 +102,7 @@ typedef enum
101102
ACL_TABLE_L3V6,
102103
ACL_TABLE_MIRROR,
103104
ACL_TABLE_MIRRORV6,
105+
ACL_TABLE_MIRROR_DSCP,
104106
ACL_TABLE_PFCWD,
105107
ACL_TABLE_CTRLPLANE,
106108
ACL_TABLE_DTEL_FLOW_WATCHLIST,

0 commit comments

Comments
 (0)