Skip to content

Commit

Permalink
add orchagent for debug generate dump
Browse files Browse the repository at this point in the history
This update introduces support for the sai_dbg_gen_dump API
The general process is as follows:
The filename is written to configDB.
This action triggers the dbgGenDumpOrch to write the necessary data to ASIC DB.
The syncd process reads from ASIC DB and invokes the SAI.
SAI processes the request and returns a response.
syncd writes the response back to redis.
dbgGenDumpOrch retrieves the response and informs the caller by writing to configDB.
The caller then removes the data from configDB.
  • Loading branch information
aviramd committed Sep 25, 2024
1 parent 29cea04 commit 17e7551
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ orchagent_SOURCES = \
response_publisher.cpp \
nvgreorch.cpp \
zmqorch.cpp \
dbggendumporch.cpp\
dash/dashorch.cpp \
dash/dashrouteorch.cpp \
dash/dashvnetorch.cpp \
Expand Down
60 changes: 60 additions & 0 deletions orchagent/dbggendumporch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "dbggendumporch.h"
#include "schema.h"

using namespace std;
using namespace swss;

DbgGenDumpOrch::DbgGenDumpOrch(TableConnector stateDbConnector):
Orch(stateDbConnector.first, stateDbConnector.second),
m_stateDbDumpStatsTable(stateDbConnector.first, STATE_DBG_GEN_DUMP_STATS_TABLE_NAME)
{
SWSS_LOG_ENTER();
}

DbgGenDumpOrch::~DbgGenDumpOrch()
{
SWSS_LOG_ENTER();
}

void DbgGenDumpOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
auto it = consumer.m_toSync.begin();
while (it != consumer.m_toSync.end())
{
if (consumer.getTableName() == STATE_DBG_GEN_DUMP_TABLE_NAME)
{
KeyOpFieldsValuesTuple t = it->second;
string op = kfvOp(t);
if (op == SET_COMMAND)
{
auto& fieldValues = kfvFieldsValues(t);
auto value = fvValue(fieldValues[0]);
const char* value_cstr = value.c_str();
SWSS_LOG_INFO("call sai_dbg_generate_dump with file %s\n", value_cstr);
sai_status_t ret = sai_dbg_generate_dump(value_cstr);
if (ret != SAI_STATUS_SUCCESS)
{
SWSS_LOG_ERROR("Failed to generate dbg dump file %s\n", value_cstr);
}
else
{
SWSS_LOG_DEBUG("generate dbg dump file %s successfully\n", value_cstr);
}

//write to state DB the return status to inform the caller
string ret_str = std::to_string(ret);
string key = kfvKey(t);
std::vector<swss::FieldValueTuple> fvTuples;
fvTuples.push_back(swss::FieldValueTuple("status", ret_str));
m_stateDbDumpStatsTable.set(key, fvTuples);
}
}
consumer.m_toSync.erase(it++);
}
}





30 changes: 30 additions & 0 deletions orchagent/dbggendumporch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef SWSS_DBG_GEN_DUMP_H
#define SWSS_DBG_GEN_DUMP_H

#include "orch.h"
#include "dbconnector.h"
#include "table.h"
#include <string>

using namespace std;
using namespace swss;

extern "C" {
#include "sai.h"
}

class DbgGenDumpOrch : public Orch
{
public:
DbgGenDumpOrch(TableConnector stateDbConnector);

~DbgGenDumpOrch();

void doTask(Consumer& consumer);

private:
Table m_stateDbDumpStatsTable;

};

#endif /* SWSS_DBG_GEN_DUMP_H */
4 changes: 4 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ bool OrchDaemon::init()
TwampOrch *twamp_orch = new TwampOrch(confDbTwampTable, stateDbTwampTable, gSwitchOrch, gPortsOrch, vrf_orch);
m_orchList.push_back(twamp_orch);

TableConnector stateDbDgbGenDumpTable(m_stateDb, STATE_DBG_GEN_DUMP_TABLE_NAME);
auto* gDbgGenDumpOrch = new DbgGenDumpOrch(stateDbDgbGenDumpTable);
m_orchList.push_back(gDbgGenDumpOrch);

if (WarmStart::isWarmStart())
{
bool suc = warmRestoreAndSyncUp();
Expand Down
1 change: 1 addition & 0 deletions orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "dash/dashrouteorch.h"
#include "dash/dashvnetorch.h"
#include <sairedis.h>
#include <dbggendumporch.h>

using namespace swss;

Expand Down
1 change: 1 addition & 0 deletions tests/mock_tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ tests_SOURCES = aclorch_ut.cpp \
$(top_srcdir)/orchagent/vxlanorch.cpp \
$(top_srcdir)/orchagent/vnetorch.cpp \
$(top_srcdir)/orchagent/dtelorch.cpp \
$(top_srcdir)/orchagent/dbggendumporch.cpp \
$(top_srcdir)/orchagent/flexcounterorch.cpp \
$(top_srcdir)/orchagent/watermarkorch.cpp \
$(top_srcdir)/orchagent/chassisorch.cpp \
Expand Down

0 comments on commit 17e7551

Please sign in to comment.