Skip to content

Commit

Permalink
Fix the p4orch test failure
Browse files Browse the repository at this point in the history
Signed-off-by: saksarav <[email protected]>
  • Loading branch information
saksarav-nokia committed May 31, 2024
1 parent 62e7b8d commit 11d393e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 57 deletions.
12 changes: 7 additions & 5 deletions orchagent/fabricportsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#define FABRIC_MONITOR_DATA "FABRIC_MONITOR_DATA"
#define APPL_FABRIC_PORT_PREFIX "Fabric"
#define SWITCH_DEBUG_COUNTER_FLEX_COUNTER_GROUP "SWITCH_DEBUG_COUNTER"
#define SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 60000
#define SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 500
#define FABRIC_SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 60000
#define SWITCH_STANDARD_DROP_COUNTERS "SWITCH_STD_DROP_COUNTER-"

// constants for link monitoring
Expand Down Expand Up @@ -95,11 +96,12 @@ FabricPortsOrch::FabricPortsOrch(DBConnector *appl_db, vector<table_name_with_pr
m_portNamePortCounterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_FABRIC_PORT_NAME_MAP));
m_fabricCounterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_TABLE));

// Create Switch level drop counters for fabric switch. switchorch adds for other switch types
if (gMySwitchType == "fabric")
// Create Switch level drop counters for voq & fabric switch.
if ((gMySwitchType == "voq") || (gMySwitchType == "fabric"))
{
auto timer = ((gMySwitchType == "voq") ? SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS : FABRIC_SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS);
switch_drop_counter_manager = new FlexCounterManager(SWITCH_DEBUG_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS, true);
timer, true);
m_counterNameToSwitchStatMap = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_DEBUG_NAME_SWITCH_STAT_MAP));
}

Expand Down Expand Up @@ -1521,7 +1523,7 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
updateFabricCapacity();
updateFabricRate();
}
if ((gMySwitchType == "fabric") && (!m_isSwitchStatsGenerated))
if (((gMySwitchType == "voq") || (gMySwitchType == "fabric")) && (!m_isSwitchStatsGenerated))
{
createSwitchDropCounters();
m_isSwitchStatsGenerated = true;
Expand Down
42 changes: 2 additions & 40 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extern MacAddress gVxlanMacAddress;
extern CrmOrch *gCrmOrch;
extern event_handle_t g_events_handle;
extern string gMyAsicName;
extern string gMySwitchType;

const map<string, sai_switch_attr_t> switch_attribute_map =
{
Expand Down Expand Up @@ -93,10 +92,6 @@ const std::set<sai_switch_asic_sdk_health_category_t> switch_asic_sdk_health_eve
SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_CPU_HW,
SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_ASIC_HW
};
const vector<sai_switch_stat_t> switch_drop_counter_ids =
{
SAI_SWITCH_STAT_PACKET_INTEGRITY_DROP
};

const std::set<std::string> switch_non_sai_attribute_set = {"ordered_ecmp"};

Expand Down Expand Up @@ -129,11 +124,7 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector<TableConnector>& connectors, Tabl
m_asicSensorsTable(new Table(m_stateDb.get(), ASIC_TEMPERATURE_INFO_TABLE_NAME)),
m_sensorsPollerTimer (new SelectableTimer((timespec { .tv_sec = DEFAULT_ASIC_SENSORS_POLLER_INTERVAL, .tv_nsec = 0 }))),
m_stateDbForNotification(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)),
m_asicSdkHealthEventTable(new Table(m_stateDbForNotification.get(), STATE_ASIC_SDK_HEALTH_EVENT_TABLE_NAME)),
switch_drop_counter_manager(SWITCH_DEBUG_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS, true),
m_switchDropCntrPollEnableTimer (new SelectableTimer((timespec { .tv_sec = DEFAULT_SWITCH_DROP_COUNTER_POLL_ENABLE_TIMER_INTERVAL,
.tv_nsec = 0 })))
m_asicSdkHealthEventTable(new Table(m_stateDbForNotification.get(), STATE_ASIC_SDK_HEALTH_EVENT_TABLE_NAME))
{
m_restartCheckNotificationConsumer = new NotificationConsumer(db, "RESTARTCHECK");
auto restartCheckNotifier = new Notifier(m_restartCheckNotificationConsumer, this, "RESTARTCHECK");
Expand All @@ -148,16 +139,6 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector<TableConnector>& connectors, Tabl

auto executorT = new ExecutableTimer(m_sensorsPollerTimer, this, "ASIC_SENSORS_POLL_TIMER");
Orch::addExecutor(executorT);

// Add Switch level drop counters to FLEX_COUNTER_DB only for VOQ switch type since it is supported by only VOQ/fabric switches now.
if(gMySwitchType == "voq")
{
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
m_counterNameToSwitchStatMap = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_DEBUG_NAME_SWITCH_STAT_MAP));
auto executorSwitchT = new ExecutableTimer(m_switchDropCntrPollEnableTimer, this, "SWITCH_DROP_COUNTER_TIMER");
Orch::addExecutor(executorSwitchT);
m_switchDropCntrPollEnableTimer->start();
}
}

void SwitchOrch::initAsicSdkHealthEventNotification()
Expand Down Expand Up @@ -1316,12 +1297,7 @@ void SwitchOrch::doTask(SelectableTimer &timer)
SWSS_LOG_INFO("Eliminate ASIC/SDK health %s", str.c_str());
}
}
else if (&timer == m_switchDropCntrPollEnableTimer)
{
createSwitchDropCounters();
m_switchDropCntrPollEnableTimer->stop();
}
}
}

void SwitchOrch::initSensorsTable()
{
Expand Down Expand Up @@ -1539,17 +1515,3 @@ bool SwitchOrch::querySwitchCapability(sai_object_type_t sai_object, sai_attr_id
}
}
}

void SwitchOrch::createSwitchDropCounters(void)
{
std::unordered_set<std::string> counter_stats;
for (const auto& it: switch_drop_counter_ids)
{
std::string drop_stats = sai_serialize_switch_stat(it);
counter_stats.emplace(drop_stats);
vector<FieldValueTuple> switchNameSwitchCounterMap;
switchNameSwitchCounterMap.emplace_back((SWITCH_STANDARD_DROP_COUNTERS + drop_stats), drop_stats);
m_counterNameToSwitchStatMap->set("", switchNameSwitchCounterMap);
}
switch_drop_counter_manager.setCounterIdList(gSwitchId, CounterType::SWITCH_DEBUG, counter_stats);
}
12 changes: 0 additions & 12 deletions orchagent/switchorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
#include "timer.h"
#include "switch/switch_capabilities.h"
#include "switch/switch_helper.h"
#include "flex_counter_manager.h"

#define DEFAULT_ASIC_SENSORS_POLLER_INTERVAL 60
#define ASIC_SENSORS_POLLER_STATUS "ASIC_SENSORS_POLLER_STATUS"
#define ASIC_SENSORS_POLLER_INTERVAL "ASIC_SENSORS_POLLER_INTERVAL"

#define DEFAULT_SWITCH_DROP_COUNTER_POLL_ENABLE_TIMER_INTERVAL 180
#define SWITCH_DEBUG_COUNTER_FLEX_COUNTER_GROUP "SWITCH_DEBUG_COUNTER"
#define SWITCH_STANDARD_DROP_COUNTERS "SWITCH_STD_DROP_COUNTER-"
#define SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 60000

#define SWITCH_CAPABILITY_TABLE_PORT_TPID_CAPABLE "PORT_TPID_CAPABLE"
#define SWITCH_CAPABILITY_TABLE_LAG_TPID_CAPABLE "LAG_TPID_CAPABLE"
#define SWITCH_CAPABILITY_TABLE_ORDERED_ECMP_CAPABLE "ORDERED_ECMP_CAPABLE"
Expand Down Expand Up @@ -81,7 +75,6 @@ class SwitchOrch : public Orch
void initSensorsTable();
void querySwitchTpidCapability();
void querySwitchPortEgressSampleCapability();
void createSwitchDropCounters(void);

// Switch hash
bool setSwitchHashFieldListSai(const SwitchHash &hash, bool isEcmpHash) const;
Expand Down Expand Up @@ -117,11 +110,6 @@ class SwitchOrch : public Orch
std::shared_ptr<swss::DBConnector> m_stateDb = nullptr;
std::shared_ptr<swss::Table> m_asicSensorsTable= nullptr;
swss::SelectableTimer* m_sensorsPollerTimer = nullptr;
std::shared_ptr<swss::DBConnector> m_counter_db;
FlexCounterManager switch_drop_counter_manager;
std::shared_ptr<swss::Table> m_counterNameToSwitchStatMap;
swss::SelectableTimer* m_switchDropCntrPollEnableTimer = nullptr;

bool m_sensorsPollerEnabled = false;
time_t m_sensorsPollerInterval = DEFAULT_ASIC_SENSORS_POLLER_INTERVAL;
bool m_sensorsPollerIntervalChanged = false;
Expand Down

0 comments on commit 11d393e

Please sign in to comment.