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

add orchagent for debug generate dump #3301

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -768,6 +768,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 @@ -112,6 +112,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