Skip to content

[orchagent/dash]: Changes to support gNMI feedback for DASH objects #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orchagent/dash/dashaclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ inline void lexical_convert(const string &buffer, DashAclStage &stage)

}

DashAclOrch::DashAclOrch(DBConnector *db, const vector<string> &tables, DashOrch *dash_orch, ZmqServer *zmqServer) :
DashAclOrch::DashAclOrch(DBConnector *db, const vector<string> &tables, DashOrch *dash_orch, DBConnector *app_state_db, ZmqServer *zmqServer) :
ZmqOrch(db, tables, zmqServer),
m_dash_orch(dash_orch),
m_group_mgr(db, dash_orch, this),
Expand Down
2 changes: 1 addition & 1 deletion orchagent/dash/dashaclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DashAclOrch : public ZmqOrch
public:
using TaskArgs = std::vector<swss::FieldValueTuple>;

DashAclOrch(swss::DBConnector *db, const std::vector<std::string> &tables, DashOrch *dash_orch, swss::ZmqServer *zmqServer);
DashAclOrch(swss::DBConnector *db, const std::vector<std::string> &tables, DashOrch *dash_orch, swss::DBConnector *app_state_db, swss::ZmqServer *zmqServer);
DashAclGroupMgr& getDashAclGroupMgr();
DashTagMgr& getDashAclTagMgr();

Expand Down
36 changes: 32 additions & 4 deletions orchagent/dash/dashorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ static std::unordered_map<string, sai_dash_eni_mac_override_type_t> sMacOverride
{ "dst_mac", SAI_DASH_ENI_MAC_OVERRIDE_TYPE_DST_MAC}
};

DashOrch::DashOrch(DBConnector *db, vector<string> &tableName, ZmqServer *zmqServer) :
DashOrch::DashOrch(DBConnector *db, vector<string> &tableName, DBConnector *app_state_db, ZmqServer *zmqServer) :
ZmqOrch(db, tableName, zmqServer),
m_eni_stat_manager(ENI_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, ENI_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false)
{
SWSS_LOG_ENTER();

m_asic_db = std::shared_ptr<DBConnector>(new DBConnector("ASIC_DB", 0));
m_counter_db = std::shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
m_eni_name_table = std::unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_ENI_NAME_MAP));
m_eni_name_table = make_unique<Table>(m_counter_db.get(), COUNTERS_ENI_NAME_MAP);
dash_eni_result_table_ = make_unique<Table>(app_state_db, APP_DASH_ENI_TABLE_NAME);
dash_eni_route_result_table_ = make_unique<Table>(app_state_db, APP_DASH_ENI_ROUTE_TABLE_NAME);
dash_qos_result_table_ = make_unique<Table>(app_state_db, APP_DASH_QOS_TABLE_NAME);
dash_appliance_result_table_ = make_unique<Table>(app_state_db, APP_DASH_APPLIANCE_TABLE_NAME);
dash_routing_type_result_table_ = make_unique<Table>(app_state_db, APP_DASH_ROUTING_TYPE_TABLE_NAME);

if (gTraditionalFlexCounter)
{
Expand Down Expand Up @@ -260,11 +265,13 @@ void DashOrch::doTaskApplianceTable(ConsumerBase& consumer)
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
uint32_t result;
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string appliance_id = kfvKey(t);
string op = kfvOp(t);
result = DASH_RESULT_SUCCESS;

if (op == SET_COMMAND)
{
Expand All @@ -283,14 +290,17 @@ void DashOrch::doTaskApplianceTable(ConsumerBase& consumer)
}
else
{
result = DASH_RESULT_FAILURE;
it++;
}
writeResultToDB(dash_appliance_result_table_, appliance_id, result);
}
else if (op == DEL_COMMAND)
{
if (removeApplianceEntry(appliance_id))
{
it = consumer.m_toSync.erase(it);
removeResultFromDB(dash_appliance_result_table_, appliance_id);
}
else
{
Expand Down Expand Up @@ -342,12 +352,14 @@ void DashOrch::doTaskRoutingTypeTable(ConsumerBase& consumer)
SWSS_LOG_ENTER();

auto it = consumer.m_toSync.begin();
uint32_t result;
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string routing_type_str = kfvKey(t);
string op = kfvOp(t);
dash::route_type::RoutingType routing_type;
result = DASH_RESULT_SUCCESS;

std::transform(routing_type_str.begin(), routing_type_str.end(), routing_type_str.begin(), ::toupper);
routing_type_str = "ROUTING_TYPE_" + routing_type_str;
Expand Down Expand Up @@ -376,14 +388,17 @@ void DashOrch::doTaskRoutingTypeTable(ConsumerBase& consumer)
}
else
{
result = DASH_RESULT_FAILURE;
it++;
}
writeResultToDB(dash_routing_type_result_table_, routing_type_str, result);
}
else if (op == DEL_COMMAND)
{
if (removeRoutingTypeEntry(routing_type))
{
it = consumer.m_toSync.erase(it);
removeResultFromDB(dash_routing_type_result_table_, routing_type_str);
}
else
{
Expand Down Expand Up @@ -677,14 +692,14 @@ void DashOrch::doTaskEniTable(ConsumerBase& consumer)
{
SWSS_LOG_ENTER();

const auto& tn = consumer.getTableName();

auto it = consumer.m_toSync.begin();
uint32_t result;
while (it != consumer.m_toSync.end())
{
auto t = it->second;
string eni = kfvKey(t);
string op = kfvOp(t);
result = DASH_RESULT_SUCCESS;
if (op == SET_COMMAND)
{
EniEntry entry;
Expand All @@ -702,14 +717,17 @@ void DashOrch::doTaskEniTable(ConsumerBase& consumer)
}
else
{
result = DASH_RESULT_FAILURE;
it++;
}
writeResultToDB(dash_eni_result_table_, eni, result);
}
else if (op == DEL_COMMAND)
{
if (removeEni(eni))
{
it = consumer.m_toSync.erase(it);
removeResultFromDB(dash_eni_result_table_, eni);
}
else
{
Expand Down Expand Up @@ -756,11 +774,13 @@ bool DashOrch::removeQosEntry(const string& qos_name)
void DashOrch::doTaskQosTable(ConsumerBase& consumer)
{
auto it = consumer.m_toSync.begin();
uint32_t result;
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string qos_name = kfvKey(t);
string op = kfvOp(t);
result = DASH_RESULT_SUCCESS;

if (op == SET_COMMAND)
{
Expand All @@ -779,14 +799,17 @@ void DashOrch::doTaskQosTable(ConsumerBase& consumer)
}
else
{
result = DASH_RESULT_FAILURE;
it++;
}
writeResultToDB(dash_qos_result_table_, qos_name, result);
}
else if (op == DEL_COMMAND)
{
if (removeQosEntry(qos_name))
{
it = consumer.m_toSync.erase(it);
removeResultFromDB(dash_qos_result_table_, qos_name);
}
else
{
Expand Down Expand Up @@ -904,11 +927,13 @@ bool DashOrch::removeEniRoute(const std::string& eni)
void DashOrch::doTaskEniRouteTable(ConsumerBase& consumer)
{
auto it = consumer.m_toSync.begin();
uint32_t result;
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;
string eni = kfvKey(t);
string op = kfvOp(t);
result = DASH_RESULT_SUCCESS;

if (op == SET_COMMAND)
{
Expand All @@ -927,14 +952,17 @@ void DashOrch::doTaskEniRouteTable(ConsumerBase& consumer)
}
else
{
result = DASH_RESULT_FAILURE;
it++;
}
writeResultToDB(dash_eni_route_result_table_, eni, result);
}
else if (op == DEL_COMMAND)
{
if (removeEniRoute(eni))
{
it = consumer.m_toSync.erase(it);
removeResultFromDB(dash_eni_route_result_table_, eni);
}
else
{
Expand Down
10 changes: 9 additions & 1 deletion orchagent/dash/dashorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#define ENI_STAT_COUNTER_FLEX_COUNTER_GROUP "ENI_STAT_COUNTER"
#define ENI_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000

#define DASH_RESULT_SUCCESS 0
#define DASH_RESULT_FAILURE 1

struct EniEntry
{
sai_object_id_t eni_id;
Expand All @@ -49,7 +52,7 @@ typedef std::map<std::string, dash::eni_route::EniRoute> EniRouteTable;
class DashOrch : public ZmqOrch
{
public:
DashOrch(swss::DBConnector *db, std::vector<std::string> &tables, swss::ZmqServer *zmqServer);
DashOrch(swss::DBConnector *db, std::vector<std::string> &tables, swss::DBConnector *app_state_db, swss::ZmqServer *zmqServer);
const EniEntry *getEni(const std::string &eni) const;
bool getRouteTypeActions(dash::route_type::RoutingType routing_type, dash::route_type::RouteType& route_type);
void handleFCStatusUpdate(bool is_enabled);
Expand All @@ -62,6 +65,11 @@ class DashOrch : public ZmqOrch
EniTable eni_entries_;
QosTable qos_entries_;
EniRouteTable eni_route_entries_;
std::unique_ptr<swss::Table> dash_eni_result_table_;
std::unique_ptr<swss::Table> dash_qos_result_table_;
std::unique_ptr<swss::Table> dash_appliance_result_table_;
std::unique_ptr<swss::Table> dash_eni_route_result_table_;
std::unique_ptr<swss::Table> dash_routing_type_result_table_;
void doTask(ConsumerBase &consumer);
void doTaskApplianceTable(ConsumerBase &consumer);
void doTaskRoutingTypeTable(ConsumerBase &consumer);
Expand Down
Loading
Loading