Skip to content

Commit 53831be

Browse files
sihuihan88lguohan
authored andcommitted
[pfcwd]: create PFCWD acl instead of L3 ACL (sonic-net#479)
Signed-off-by: Sihui Han <[email protected]>
1 parent d711d2c commit 53831be

File tree

4 files changed

+59
-6
lines changed

4 files changed

+59
-6
lines changed

orchagent/aclorch.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ shared_ptr<AclRule> AclRule::makeShared(acl_table_type_t type, AclOrch *acl, Mir
498498
{
499499
return make_shared<AclRuleL3V6>(acl, rule, table, type);
500500
}
501+
/* Pfcwd rules can exist only in PFCWD table */
502+
else if (type == ACL_TABLE_PFCWD)
503+
{
504+
return make_shared<AclRulePfcwd>(acl, rule, table, type);
505+
}
501506

502507
throw runtime_error("Wrong combination of table type and action in rule " + rule);
503508
}
@@ -739,6 +744,23 @@ void AclRuleL3::update(SubjectType, void *)
739744
// Do nothing
740745
}
741746

747+
748+
AclRulePfcwd::AclRulePfcwd(AclOrch *aclOrch, string rule, string table, acl_table_type_t type) :
749+
AclRuleL3(aclOrch, rule, table, type)
750+
{
751+
}
752+
753+
bool AclRulePfcwd::validateAddMatch(string attr_name, string attr_value)
754+
{
755+
if (attr_name != MATCH_TC)
756+
{
757+
SWSS_LOG_ERROR("%s is not supported for the tables of type Pfcwd", attr_name.c_str());
758+
return false;
759+
}
760+
761+
return AclRule::validateAddMatch(attr_name, attr_value);
762+
}
763+
742764
AclRuleL3V6::AclRuleL3V6(AclOrch *aclOrch, string rule, string table, acl_table_type_t type) :
743765
AclRuleL3(aclOrch, rule, table, type)
744766
{
@@ -761,6 +783,7 @@ bool AclRuleL3V6::validateAddMatch(string attr_name, string attr_value)
761783
return AclRule::validateAddMatch(attr_name, attr_value);
762784
}
763785

786+
764787
AclRuleMirror::AclRuleMirror(AclOrch *aclOrch, MirrorOrch *mirror, string rule, string table, acl_table_type_t type) :
765788
AclRule(aclOrch, rule, table, type),
766789
m_state(false),
@@ -971,6 +994,26 @@ bool AclTable::create()
971994
attr.value.s32list.list = bpoint_list.data();
972995
table_attrs.push_back(attr);
973996

997+
if (type == ACL_TABLE_PFCWD)
998+
{
999+
attr.id = SAI_ACL_TABLE_ATTR_FIELD_TC;
1000+
attr.value.booldata = true;
1001+
table_attrs.push_back(attr);
1002+
1003+
attr.id = SAI_ACL_TABLE_ATTR_ACL_STAGE;
1004+
attr.value.s32 = stage == ACL_STAGE_INGRESS ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS;
1005+
table_attrs.push_back(attr);
1006+
1007+
sai_status_t status = sai_acl_api->create_acl_table(&m_oid, gSwitchId, (uint32_t)table_attrs.size(), table_attrs.data());
1008+
1009+
if (status == SAI_STATUS_SUCCESS)
1010+
{
1011+
gCrmOrch->incCrmAclUsedCounter(CrmResourceType::CRM_ACL_TABLE, (sai_acl_stage_t) attr.value.s32, SAI_ACL_BIND_POINT_TYPE_PORT);
1012+
}
1013+
1014+
return status == SAI_STATUS_SUCCESS;
1015+
}
1016+
9741017
attr.id = SAI_ACL_TABLE_ATTR_FIELD_ETHER_TYPE;
9751018
attr.value.booldata = true;
9761019
table_attrs.push_back(attr);

orchagent/aclorch.h

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define TABLE_TYPE_L3 "L3"
2626
#define TABLE_TYPE_L3V6 "L3V6"
2727
#define TABLE_TYPE_MIRROR "MIRROR"
28+
#define TABLE_TYPE_PFCWD "PFCWD"
2829
#define TABLE_TYPE_CTRLPLANE "CTRLPLANE"
2930

3031
#define RULE_PRIORITY "PRIORITY"
@@ -69,6 +70,7 @@ typedef enum
6970
ACL_TABLE_L3,
7071
ACL_TABLE_L3V6,
7172
ACL_TABLE_MIRROR,
73+
ACL_TABLE_PFCWD,
7274
ACL_TABLE_CTRLPLANE
7375
} acl_table_type_t;
7476

@@ -207,6 +209,14 @@ class AclRuleL3V6: public AclRuleL3
207209
bool validateAddMatch(string attr_name, string attr_value);
208210
};
209211

212+
class AclRulePfcwd: public AclRuleL3
213+
{
214+
public:
215+
AclRulePfcwd(AclOrch *m_pAclOrch, string rule, string table, acl_table_type_t type);
216+
bool validateAddMatch(string attr_name, string attr_value);
217+
};
218+
219+
210220
class AclRuleMirror: public AclRule
211221
{
212222
public:

orchagent/pfcactionhandler.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
211211
{
212212
SWSS_LOG_ENTER();
213213

214-
acl_table_type_t table_type = ACL_TABLE_L3;
214+
acl_table_type_t table_type = ACL_TABLE_PFCWD;
215215

216216
// There is one handler instance per queue ID
217217
string queuestr = to_string(queueId);
@@ -224,7 +224,7 @@ PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
224224
{
225225
// First time of handling PFC for this queue, create ACL table, and bind
226226
createPfcAclTable(port, m_strIngressTable, true);
227-
shared_ptr<AclRuleL3> newRule = make_shared<AclRuleL3>(gAclOrch, m_strRule, m_strIngressTable, table_type);
227+
shared_ptr<AclRulePfcwd> newRule = make_shared<AclRulePfcwd>(gAclOrch, m_strRule, m_strIngressTable, table_type);
228228
createPfcAclRule(newRule, queueId, m_strIngressTable);
229229
}
230230
else
@@ -238,7 +238,7 @@ PfcWdAclHandler::PfcWdAclHandler(sai_object_id_t port, sai_object_id_t queue,
238238
{
239239
// First time of handling PFC for this queue, create ACL table, and bind
240240
createPfcAclTable(port, m_strEgressTable, false);
241-
shared_ptr<AclRuleL3> newRule = make_shared<AclRuleL3>(gAclOrch, m_strRule, m_strEgressTable, table_type);
241+
shared_ptr<AclRulePfcwd> newRule = make_shared<AclRulePfcwd>(gAclOrch, m_strRule, m_strEgressTable, table_type);
242242
createPfcAclRule(newRule, queueId, m_strEgressTable);
243243
}
244244
else
@@ -281,14 +281,14 @@ void PfcWdAclHandler::createPfcAclTable(sai_object_id_t port, string strTable, b
281281
assert(inserted.second);
282282

283283
AclTable& aclTable = inserted.first->second;
284-
aclTable.type = ACL_TABLE_L3;
284+
aclTable.type = ACL_TABLE_PFCWD;
285285
aclTable.link(port);
286286
aclTable.id = strTable;
287287
aclTable.stage = ingress ? ACL_STAGE_INGRESS : ACL_STAGE_EGRESS;
288288
gAclOrch->addAclTable(aclTable, strTable);
289289
}
290290

291-
void PfcWdAclHandler::createPfcAclRule(shared_ptr<AclRuleL3> rule, uint8_t queueId, string strTable)
291+
void PfcWdAclHandler::createPfcAclRule(shared_ptr<AclRulePfcwd> rule, uint8_t queueId, string strTable)
292292
{
293293
SWSS_LOG_ENTER();
294294

orchagent/pfcactionhandler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class PfcWdAclHandler: public PfcWdLossyHandler
111111
string m_strEgressTable;
112112
string m_strRule;
113113
void createPfcAclTable(sai_object_id_t port, string strTable, bool ingress);
114-
void createPfcAclRule(shared_ptr<AclRuleL3> rule, uint8_t queueId, string strTable);
114+
void createPfcAclRule(shared_ptr<AclRulePfcwd> rule, uint8_t queueId, string strTable);
115115
};
116116

117117
// PFC queue that implements drop action by draining queue with buffer of zero size

0 commit comments

Comments
 (0)