Skip to content
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

orchagent for generate SAI debug dump file #3301

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ orchagent_SOURCES = \
response_publisher.cpp \
nvgreorch.cpp \
zmqorch.cpp \
dbggendumporch.cpp\
dash/dashorch.cpp \
dash/dashrouteorch.cpp \
dash/dashvnetorch.cpp \
Expand Down
55 changes: 55 additions & 0 deletions orchagent/dbggendumporch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "dbggendumporch.h"
#include "schema.h"

using namespace std;
using namespace swss;

DbgGenDumpOrch::DbgGenDumpOrch(TableConnector dbConnector, const std::string statusTableName):
Orch(dbConnector.first, dbConnector.second),
m_dbDumpTable(dbConnector.first, statusTableName)
{
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() == APP_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_dbDumpTable.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 dbConnector, const std::string statusTableName);

~DbgGenDumpOrch();

void doTask(Consumer& consumer);

private:
Table m_dbDumpTable;

};

#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 @@ -781,6 +781,10 @@ bool OrchDaemon::init()
TwampOrch *twamp_orch = new TwampOrch(confDbTwampTable, stateDbTwampTable, gSwitchOrch, gPortsOrch, vrf_orch);
m_orchList.push_back(twamp_orch);

TableConnector applDbDgbGenDumpTable(m_applDb, APP_DBG_GEN_DUMP_TABLE_NAME);
auto* gDbgGenDumpOrch = new DbgGenDumpOrch(applDbDgbGenDumpTable, APP_DBG_GEN_DUMP_STATUS_TABLE_NAME);
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 @@ -53,6 +53,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 @@ -113,6 +113,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
Loading