Skip to content

Commit

Permalink
DPB ACL dependency implementation and test cases (sonic-net#11)
Browse files Browse the repository at this point in the history
* DPB ACL dependency implemenatation and test cases

* Code-review comments addressed

* ACL empty port list support, Codereview comments, and Bug fixes
  • Loading branch information
vasant17 authored and zhenggen-xu committed Nov 22, 2019
1 parent 6a6c46e commit 61fed20
Show file tree
Hide file tree
Showing 13 changed files with 935 additions and 316 deletions.
272 changes: 209 additions & 63 deletions orchagent/aclorch.cpp

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@ class AclTable {
bool unbind();
// Link the ACL table with a port, for future bind or unbind
void link(sai_object_id_t portOid);
// Unlink the ACL table from a port after unbind
void unlink(sai_object_id_t portOid);
// Add or overwrite a rule into the ACL table
bool add(shared_ptr<AclRule> newRule);
// Remove a rule from the ACL table
Expand Down Expand Up @@ -396,8 +398,9 @@ class AclOrch : public Orch, public Observer
RouteOrch *m_routeOrch;
DTelOrch *m_dTelOrch;

bool addAclTable(AclTable &aclTable, string table_id);
bool addAclTable(AclTable &aclTable);
bool removeAclTable(string table_id);
bool updateAclTable(AclTable &currentTable, AclTable &newTable);
bool addAclRule(shared_ptr<AclRule> aclRule, string table_id);
bool removeAclRule(string table_id, string rule_id);

Expand Down Expand Up @@ -430,13 +433,20 @@ class AclOrch : public Orch, public Observer
static void collectCountersThread(AclOrch *pAclOrch);

bool createBindAclTable(AclTable &aclTable, sai_object_id_t &table_oid);
sai_status_t bindAclTable(sai_object_id_t table_oid, AclTable &aclTable, bool bind = true);
sai_status_t bindAclTable(AclTable &aclTable, bool bind = true);
sai_status_t deleteUnbindAclTable(sai_object_id_t table_oid);

bool isAclTableTypeUpdated(acl_table_type_t table_type, AclTable &aclTable);
bool processAclTableType(string type, acl_table_type_t &table_type);
bool isAclTableStageUpdated(acl_stage_type_t acl_stage, AclTable &aclTable);
bool processAclTableStage(string stage, acl_stage_type_t &acl_stage);
bool processAclTablePorts(string portList, AclTable &aclTable);
bool validateAclTable(AclTable &aclTable);
bool updateAclTablePorts(AclTable &newTable, AclTable &curTable);
void getAddDeletePorts(AclTable &newT,
AclTable &curT,
set<string> &addSet,
set<string> &delSet);
sai_status_t createDTelWatchListTables();
sai_status_t deleteDTelWatchListTables();

Expand Down
2 changes: 1 addition & 1 deletion orchagent/pfcactionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void PfcWdAclHandler::createPfcAclTable(sai_object_id_t port, string strTable, b
aclTable.link(port);
aclTable.id = strTable;
aclTable.stage = ingress ? ACL_STAGE_INGRESS : ACL_STAGE_EGRESS;
gAclOrch->addAclTable(aclTable, strTable);
gAclOrch->addAclTable(aclTable);
}

void PfcWdAclHandler::createPfcAclRule(shared_ptr<AclRulePfcwd> rule, uint8_t queueId, string strTable)
Expand Down
7 changes: 2 additions & 5 deletions orchagent/pfcwdorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,8 @@ bool PfcWdSwOrch<DropHandler, ForwardHandler>::registerInWdDb(const Port& port,
sai_serialize_object_id(queueId));
}

// Create egress ACL table group for each port of pfcwd's interest
sai_object_id_t groupId;
gPortsOrch->createBindAclTableGroup(port.m_port_id, groupId, ACL_STAGE_INGRESS);
gPortsOrch->createBindAclTableGroup(port.m_port_id, groupId, ACL_STAGE_EGRESS);

// We do NOT need to create ACL table group here. It will be
// done when ACL tables are bound to ports
return true;
}

Expand Down
26 changes: 26 additions & 0 deletions orchagent/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ extern "C" {
#include <string>
#include <vector>
#include <map>
#include <bitset>

#define DEFAULT_PORT_VLAN_ID 1
/*
Expand Down Expand Up @@ -47,6 +48,14 @@ class Port
UNKNOWN
} ;

enum Dependency {
ACL_DEP,
FDB_DEP,
INTF_DEP,
LAG_DEP,
VLAN_DEP
};

Port() {};
Port(std::string alias, Type type) :
m_alias(alias), m_type(type) {};
Expand Down Expand Up @@ -86,12 +95,29 @@ class Port
sai_object_id_t m_ingress_acl_table_group_id = 0;
sai_object_id_t m_egress_acl_table_group_id = 0;
vlan_members_t m_vlan_members;

uint32_t m_dependency_bitmap = 0;
sai_port_oper_status_t m_oper_status = SAI_PORT_OPER_STATUS_UNKNOWN;
std::set<std::string> m_members;
std::vector<sai_object_id_t> m_queue_ids;
std::vector<sai_object_id_t> m_priority_group_ids;
sai_port_priority_flow_control_mode_t m_pfc_asym = SAI_PORT_PRIORITY_FLOW_CONTROL_MODE_COMBINED;
uint8_t m_pfc_bitmask = 0;
std::unordered_set<sai_object_id_t> m_ingress_acl_tables_uset;
std::unordered_set<sai_object_id_t> m_egress_acl_tables_uset;

inline void set_dependency(Dependency dep)
{
m_dependency_bitmap |= (1 << dep);
}
inline void clear_dependency(Dependency dep)
{
m_dependency_bitmap &= ~(1 << dep);
}
inline bool has_dependency()
{
return (m_dependency_bitmap != 0);
}
};

}
Expand Down
Loading

0 comments on commit 61fed20

Please sign in to comment.