Skip to content

Commit

Permalink
refresh FC
Browse files Browse the repository at this point in the history
  • Loading branch information
sundar-pds committed Dec 2, 2024
1 parent 1be87d8 commit 484dbaa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
26 changes: 17 additions & 9 deletions orchagent/dash/dashmeterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,10 @@ void DashMeterOrch::doTask(ConsumerBase& consumer)

void DashMeterOrch::addEniToMeterFC(sai_object_id_t oid, const string &name)
{
if (!m_meter_fc_status)
{
return;
}
auto was_empty = m_meter_stat_work_queue.empty();
m_meter_stat_work_queue[oid] = name;
if (was_empty)
Expand Down Expand Up @@ -683,28 +687,32 @@ void DashMeterOrch::removeEniFromMeterFC(sai_object_id_t oid, const string &name

m_eni_name_table->hdel("", name);
m_meter_stat_manager.clearCounterIdList(oid);
SWSS_LOG_DEBUG("Unregistered eni %s from meter Flex counter", name.c_str());
SWSS_LOG_INFO("Unregistering FC for ENI %s, oid %s", name.c_str(), sai_serialize_object_id(oid).c_str());
}


void DashMeterOrch::clearMeterFCStats()
#if 0
void DashMeterOrch::refreshMeterFCStats(bool install)
{
DashOrch *dash_orch = gDirectory.get<DashOrch*>();
dash_orch->clearMeterFCStats();
dash_orch->refreshMeterFCStats(install);
}
#endif

void DashMeterOrch::handleMeterFCStatusUpdate(bool enabled)
{
if (!enabled && m_meter_fc_status)
DashOrch *dash_orch = gDirectory.get<DashOrch*>();
bool prev_enabled = m_meter_fc_status;
m_meter_fc_status = enabled; /* Update the status */
if (!enabled && prev_enabled)
{
m_meter_fc_update_timer->stop();
clearMeterFCStats();
dash_orch->refreshMeterFCStats(false); /* Clear any existing FC entries */
}
else if (enabled && !m_meter_fc_status)
else if (enabled && !prev_enabled)
{
dash_orch->refreshMeterFCStats(true);
m_meter_fc_update_timer->start();
}
m_meter_fc_status = enabled;
}

void DashMeterOrch::doTask(SelectableTimer &timer)
Expand All @@ -725,7 +733,7 @@ void DashMeterOrch::doTask(SelectableTimer &timer)
{
// TBD.. ENI_NAME_MAP entry is added/deleted by DashOrch Code.

SWSS_LOG_INFO("Registering %s, id %s", it->second.c_str(), id.c_str());
SWSS_LOG_INFO("Registering FC for ENI %s, oid %s", it->second.c_str(), id.c_str());
std::vector<FieldValueTuple> eniNameFvs;
eniNameFvs.emplace_back(it->second, id);
m_eni_name_table->set("", eniNameFvs);
Expand Down
2 changes: 1 addition & 1 deletion orchagent/dash/dashmeterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,5 @@ class DashMeterOrch : public ZmqOrch
std::shared_ptr<swss::DBConnector> m_counter_db;
std::shared_ptr<swss::DBConnector> m_asic_db;
swss::SelectableTimer* m_meter_fc_update_timer = nullptr;
void clearMeterFCStats();
//void refreshMeterFCStats(bool install);
};
11 changes: 9 additions & 2 deletions orchagent/dash/dashorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1049,12 +1049,19 @@ void DashOrch::refreshEniFCStats(bool install)
}
}

void DashOrch::clearMeterFCStats()
void DashOrch::refreshMeterFCStats(bool install)
{
DashMeterOrch *dash_meter_orch = gDirectory.get<DashMeterOrch*>();
for (auto it = eni_entries_.begin(); it != eni_entries_.end(); it++)
{
dash_meter_orch->removeEniFromMeterFC(it->second.eni_id, it->first);
if (install)
{
dash_meter_orch->addEniToMeterFC(it->second.eni_id, it->first);
}
else
{
dash_meter_orch->removeEniFromMeterFC(it->second.eni_id, it->first);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion orchagent/dash/dashorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DashOrch : public ZmqOrch
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);
void clearMeterFCStats();
void refreshMeterFCStats(bool);

private:
ApplianceTable appliance_entries_;
Expand Down

0 comments on commit 484dbaa

Please sign in to comment.