Skip to content

Commit

Permalink
ADD VOQ COUNTERS(SAI_SWITCH_STAT_PACKET_INTEGRITY_DROP, SAI_QUEUE_STA…
Browse files Browse the repository at this point in the history
…T_CREDIT_WD_DELETED_PACKETS) suuport for VOQ/Fabric switches

Signed-off-by: saksarav <[email protected]>
  • Loading branch information
saksarav-nokia committed May 15, 2024
1 parent 2f8bd9c commit 490e70e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
29 changes: 29 additions & 0 deletions orchagent/fabricportsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define FABRIC_PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000
#define FABRIC_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP "FABRIC_QUEUE_STAT_COUNTER"
#define FABRIC_QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 100000
#define DEBUG_COUNTER_FLEX_COUNTER_GROUP "SWITCH_DEBUG_COUNTER"
#define SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS 100000
#define FABRIC_DEBUG_POLLING_INTERVAL_DEFAULT (60)
#define FABRIC_MONITOR_DATA "FABRIC_MONITOR_DATA"
#define APPL_FABRIC_PORT_PREFIX "Fabric"
Expand All @@ -37,6 +39,11 @@
#define ERROR_RATE_RX_CELLS_CFG 61035156
#define FABRIC_LINK_RATE 44316

const vector<sai_switch_stat_t> switch_voq_counter_ids =
{
SAI_SWITCH_STAT_PACKET_INTEGRITY_DROP
};

extern sai_object_id_t gSwitchId;
extern sai_switch_api_t *sai_switch_api;
extern sai_port_api_t *sai_port_api;
Expand Down Expand Up @@ -68,6 +75,8 @@ FabricPortsOrch::FabricPortsOrch(DBConnector *appl_db, vector<table_name_with_pr
FABRIC_PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
queue_stat_manager(FABRIC_QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
FABRIC_QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, true),
switch_drop_counter_manager(DEBUG_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ,
SWITCH_DEBUG_COUNTER_POLLING_INTERVAL_MS, true),
m_timer(new SelectableTimer(timespec { .tv_sec = FABRIC_POLLING_INTERVAL_DEFAULT, .tv_nsec = 0 })),
m_debugTimer(new SelectableTimer(timespec { .tv_sec = FABRIC_DEBUG_POLLING_INTERVAL_DEFAULT, .tv_nsec = 0 }))
{
Expand All @@ -83,6 +92,7 @@ FabricPortsOrch::FabricPortsOrch(DBConnector *appl_db, vector<table_name_with_pr
m_portNameQueueCounterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_FABRIC_QUEUE_NAME_MAP));
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));
m_counterNameToSwitchStatMap = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_DEBUG_NAME_SWITCH_STAT_MAP));

m_flex_db = shared_ptr<DBConnector>(new DBConnector("FLEX_COUNTER_DB", 0));
m_flexCounterTable = unique_ptr<ProducerTable>(new ProducerTable(m_flex_db.get(), APP_FABRIC_PORT_TABLE_NAME));
Expand Down Expand Up @@ -1222,5 +1232,24 @@ void FabricPortsOrch::doTask(swss::SelectableTimer &timer)
updateFabricDebugCounters();
updateFabricCapacity();
}
if (!m_isSwitchStatsGenerated)
{
createSwitchVoqCounters();
}
}
}

void FabricPortsOrch::createSwitchVoqCounters(void)
{
std::unordered_set<std::string> counter_stats;
for (const auto& it: switch_voq_counter_ids)
{
counter_stats.emplace(sai_serialize_switch_stat(it));
}
switch_drop_counter_manager.setCounterIdList(gSwitchId, CounterType::SWITCH_DEBUG, counter_stats);

vector<FieldValueTuple> switchNameSwitchCounterMap;
switchNameSwitchCounterMap.emplace_back("SWITCH_ID", sai_serialize_object_id(gSwitchId));
m_counterNameToSwitchStatMap->set("", switchNameSwitchCounterMap);
m_isSwitchStatsGenerated = true;
}
4 changes: 4 additions & 0 deletions orchagent/fabricportsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FabricPortsOrch : public Orch, public Subject
bool fabricPortStatEnabled=true, bool fabricQueueStatEnabled=true);
bool allPortsReady();
void generateQueueStats();
void createSwitchVoqCounters(void);

private:
bool m_fabricPortStatEnabled;
Expand All @@ -37,12 +38,14 @@ class FabricPortsOrch : public Orch, public Subject
unique_ptr<Table> m_fabricCapacityTable;
unique_ptr<Table> m_applMonitorConstTable;
unique_ptr<ProducerTable> m_flexCounterTable;
shared_ptr<Table> m_counterNameToSwitchStatMap;

swss::SelectableTimer *m_timer = nullptr;
swss::SelectableTimer *m_debugTimer = nullptr;

FlexCounterManager port_stat_manager;
FlexCounterManager queue_stat_manager;
FlexCounterManager switch_drop_counter_manager;

sai_uint32_t m_fabricPortCount;
map<int, sai_object_id_t> m_fabricLanePortMap;
Expand All @@ -52,6 +55,7 @@ class FabricPortsOrch : public Orch, public Subject

bool m_getFabricPortListDone = false;
bool m_isQueueStatsGenerated = false;
bool m_isSwitchStatsGenerated = false;

string m_defaultPollWithErrors = "0";
string m_defaultPollWithNoErrors = "8";
Expand Down
1 change: 1 addition & 0 deletions orchagent/port/port_capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern "C" {
#include <saiobject.h>
#include <saitypes.h>
#include <saiport.h>
#include <saiqueue.h>
}

class PortCapabilities final
Expand Down
9 changes: 9 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ static const vector<sai_queue_stat_t> queue_stat_ids =
SAI_QUEUE_STAT_DROPPED_PACKETS,
SAI_QUEUE_STAT_DROPPED_BYTES,
};
static const vector<sai_queue_stat_t> voq_stat_ids =
{
SAI_QUEUE_STAT_CREDIT_WD_DELETED_PACKETS
};


static const vector<sai_queue_stat_t> queueWatermarkStatIds =
{
Expand Down Expand Up @@ -7011,6 +7016,10 @@ void PortsOrch::addQueueFlexCountersPerPortPerQueueIndex(const Port& port, size_
}
if (voq)
{
for (const auto& voq_it: voq_stat_ids)
{
counter_stats.emplace(sai_serialize_queue_stat(voq_it));
}
queue_ids = m_port_voq_ids[port.m_alias];
}
else
Expand Down

0 comments on commit 490e70e

Please sign in to comment.