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 support for "sai_dbg_generate_dump" API #1423

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
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
10 changes: 10 additions & 0 deletions lib/ClientSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,3 +1549,13 @@ sai_status_t ClientSai::queryApiVersion(

return SAI_STATUS_NOT_IMPLEMENTED;
}

sai_status_t ClientSai::dbgGenerateDump(
_In_ const char *dump_file_name)
{
MUTEX();
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

return SAI_STATUS_NOT_IMPLEMENTED;
}
3 changes: 3 additions & 0 deletions lib/ClientSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

private: // QUAD API helpers

sai_status_t create(
Expand Down
10 changes: 10 additions & 0 deletions lib/ClientServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,3 +638,13 @@ sai_status_t ClientServerSai::queryApiVersion(

return m_sai->queryApiVersion(version);
}

sai_status_t ClientServerSai::dbgGenerateDump(
_In_ const char *dump_file_name)
{
MUTEX();
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

return m_sai->dbgGenerateDump(dump_file_name);
}
3 changes: 3 additions & 0 deletions lib/ClientServerSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

private:

bool m_apiInitialized;
Expand Down
8 changes: 8 additions & 0 deletions lib/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ void Recorder::recordFlushFdbEntriesResponse(
recordLine("F|" + sai_serialize_status(status));
}

void Recorder::recordDbgGenDumpResponse(
_In_ sai_status_t status)
{
SWSS_LOG_ENTER();

recordLine("G|" + sai_serialize_status(status));
}

void Recorder::recordQueryAttributeCapability(
_In_ const std::string& key,
_In_ const std::vector<swss::FieldValueTuple>& arguments)
Expand Down
3 changes: 3 additions & 0 deletions lib/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ namespace sairedis
void recordFlushFdbEntriesResponse(
_In_ sai_status_t status);

void recordDbgGenDumpResponse(
_In_ sai_status_t status);

public: // SAI global interface API

void recordObjectTypeGetAvailability(
Expand Down
26 changes: 26 additions & 0 deletions lib/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1910,6 +1910,32 @@ sai_status_t RedisRemoteSaiInterface::queryApiVersion(
return SAI_STATUS_INVALID_PARAMETER;
}


sai_status_t RedisRemoteSaiInterface::dbgGenerateDump(
_In_ const char *dump_file_name)
{
SWSS_LOG_ENTER();
swss::KeyOpFieldsValuesTuple kco;
sai_status_t status = SAI_STATUS_SUCCESS;

const std::vector<swss::FieldValueTuple> entry =
{
swss::FieldValueTuple("DBG_GENERATE_DUMP", dump_file_name),
};

std::string key = "DBG_GEN_DUMP:01";
m_communicationChannel->set(key, entry, REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMP);

if (m_syncMode)
{
status = m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE, kco);
}

m_recorder->recordDbgGenDumpResponse(status);

return status;
}

sai_status_t RedisRemoteSaiInterface::sai_redis_notify_syncd(
_In_ sai_object_id_t switchId,
_In_ const sai_attribute_t *attr)
Expand Down
3 changes: 3 additions & 0 deletions lib/RedisRemoteSaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

public: // notify syncd

virtual sai_status_t notifySyncd(
Expand Down
17 changes: 17 additions & 0 deletions lib/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,23 @@ sai_status_t Sai::queryApiVersion(
return SAI_STATUS_FAILURE;
}

sai_status_t Sai::dbgGenerateDump(
_In_ const char *dump_file_name)
{
MUTEX();
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

for (auto&kvp: m_contextMap)
{
return kvp.second->m_meta->dbgGenerateDump(dump_file_name);
}

SWSS_LOG_ERROR("context map is empty");

return SAI_STATUS_FAILURE;
}

/*
* NOTE: Notifications during switch create and switch remove.
*
Expand Down
3 changes: 3 additions & 0 deletions lib/Sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

private:

sai_switch_notifications_t handle_notification(
Expand Down
29 changes: 29 additions & 0 deletions lib/ServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ sai_status_t ServerSai::queryApiVersion(
return m_sai->queryApiVersion(version);
}

sai_status_t ServerSai::dbgGenerateDump(
_In_ const char *dump_file_name)
{
MUTEX();
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

return m_sai->dbgGenerateDump(dump_file_name);
}

void ServerSai::serverThreadFunction()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -777,9 +787,28 @@ sai_status_t ServerSai::processSingleEvent(
if (op == REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_QUERY)
return processObjectTypeGetAvailabilityQuery(kco);

if (op == REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMP)
return processDbgGenerateDump(kco);

SWSS_LOG_THROW("event op '%s' is not implemented, FIXME", op.c_str());
}

sai_status_t ServerSai::processDbgGenerateDump(
_In_ const swss::KeyOpFieldsValuesTuple &kco)
{
SWSS_LOG_ENTER();

auto& fieldValues = kfvFieldsValues(kco);
auto value = fvValue(fieldValues[0]);
const char* value_cstr = value.c_str();

sai_status_t status = m_sai->dbgGenerateDump(value_cstr);

m_selectableChannel->set(sai_serialize_status(status), {} , REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE);

return status;
}

sai_status_t ServerSai::processQuadEvent(
_In_ sai_common_api_t api,
_In_ const swss::KeyOpFieldsValuesTuple &kco)
Expand Down
6 changes: 6 additions & 0 deletions lib/ServerSai.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

private:

void serverThreadFunction();
Expand Down Expand Up @@ -294,6 +297,9 @@ namespace sairedis
sai_status_t processObjectTypeGetAvailabilityQuery(
_In_ const swss::KeyOpFieldsValuesTuple &kco);

sai_status_t processDbgGenerateDump(
_In_ const swss::KeyOpFieldsValuesTuple &kco);

private:

bool m_apiInitialized;
Expand Down
3 changes: 3 additions & 0 deletions lib/sairediscommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#define REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_QUERY "object_type_get_availability_query"
#define REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE "object_type_get_availability_response"

#define REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMP "dbg_gen_dump"
#define REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE "dbg_gen_dumpresponse"

#define REDIS_FLEX_COUNTER_COMMAND_START_POLL "start_poll"
#define REDIS_FLEX_COUNTER_COMMAND_STOP_POLL "stop_poll"
#define REDIS_FLEX_COUNTER_COMMAND_SET_GROUP "set_counter_group"
Expand Down
8 changes: 8 additions & 0 deletions meta/DummySaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,14 @@ sai_status_t DummySaiInterface::queryApiVersion(
return m_status;
}

sai_status_t DummySaiInterface::dbgGenerateDump(
_In_ const char *dump_file_name)
{
SWSS_LOG_ENTER();

return m_status;
}

void DummySaiInterface::updateNotificationPointers(
_In_ uint32_t count,
_In_ const sai_attribute_t* attrs)
Expand Down
3 changes: 3 additions & 0 deletions meta/DummySaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ namespace saimeta
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

protected:

void updateNotificationPointers(
Expand Down
8 changes: 8 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,14 @@ sai_status_t Meta::queryApiVersion(
return m_implementation->queryApiVersion(version);
}

sai_status_t Meta::dbgGenerateDump(
_In_ const char *dump_file_name)
{
SWSS_LOG_ENTER();

return m_implementation->dbgGenerateDump(dump_file_name);
}

void Meta::clean_after_switch_remove(
_In_ sai_object_id_t switchId)
{
Expand Down
3 changes: 3 additions & 0 deletions meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ namespace saimeta
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

public:

void meta_init_db();
Expand Down
3 changes: 3 additions & 0 deletions meta/SaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@ namespace sairedis
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) = 0;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) = 0;

public: // non SAI API

virtual sai_log_level_t logGet(
Expand Down
26 changes: 26 additions & 0 deletions proxylib/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,35 @@ void Proxy::processSingleEvent(
if (op == "clear_stats")
return processClearStats(kco);

if (op == "dbg_gen_dump")
return processDbgGenerateDump(kco);

SWSS_LOG_THROW("event op '%s' is not implemented, FIXME", op.c_str());
}

void Proxy::processDbgGenerateDump(
_In_ const swss::KeyOpFieldsValuesTuple &kco)
{
SWSS_LOG_ENTER();

const auto& values = kfvFieldsValues(kco);
if (values.size() != 1)
{
SWSS_LOG_THROW("Invalid input: expected 1 arguments, received %zu", values.size());
}

auto& fieldValues = kfvFieldsValues(kco);

auto value = fvValue(fieldValues[0]);
const char* value_cstr = value.c_str();

sai_status_t status = m_vendorSai->dbgGenerateDump(value_cstr);

auto strStatus = sai_serialize_status(status);

m_selectableChannel->set(strStatus, {} , "dbg_gen_dumpresponse");
}

void Proxy::processCreate(
_In_ const swss::KeyOpFieldsValuesTuple &kco)
{
Expand Down
3 changes: 3 additions & 0 deletions proxylib/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ namespace saiproxy
void processClearStats(
_In_ const swss::KeyOpFieldsValuesTuple &kco);

void processDbgGenerateDump(
_In_ const swss::KeyOpFieldsValuesTuple &kco);

private: // notifications

void onFdbEvent(
Expand Down
21 changes: 21 additions & 0 deletions proxylib/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,27 @@ sai_status_t Sai::queryApiVersion(

// TODO use function from SAI metadata to populate those

sai_status_t Sai::dbgGenerateDump(
_In_ const char *dump_file_name)
{
MUTEX();
SWSS_LOG_ENTER();
PROXY_CHECK_API_INITIALIZED();

const std::vector<swss::FieldValueTuple> entry =
{
swss::FieldValueTuple("DBG_GENERATE_DUMP", dump_file_name),
};

std::string key = "DBG_GEN_DUMP:01";

m_communicationChannel->set(key, entry, "dbg_gen_dump");

swss::KeyOpFieldsValuesTuple kco;

return m_communicationChannel->wait("dbg_gen_dumpresponse", kco);
}

void Sai::updateNotifications(
_In_ uint32_t attrCount,
_In_ const sai_attribute_t *attrList)
Expand Down
3 changes: 3 additions & 0 deletions proxylib/Sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ namespace saiproxy
virtual sai_status_t queryApiVersion(
_Out_ sai_api_version_t *version) override;

virtual sai_status_t dbgGenerateDump(
_In_ const char *dump_file_name) override;

private: // QUAD helpers for entry

virtual sai_status_t create(
Expand Down
2 changes: 1 addition & 1 deletion stub.pl
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ sub CreateGlobalApis
Write " SWSS_LOG_ENTER();";
Write "";

if ($fun =~ /(bulkObjectClearStats|bulkObjectGetStats|dbgGenerateDump|getMaximumAttributeCount|getObjectKey|bulkGetAttribute|dbgGenerateDump|tamTelemetryGetData|getObjectCount|queryObjectStage)/)
if ($fun =~ /(bulkObjectClearStats|bulkObjectGetStats|getMaximumAttributeCount|getObjectKey|bulkGetAttribute|tamTelemetryGetData|getObjectCount|queryObjectStage)/)
{
Write " SWSS_LOG_ERROR(\"FIXME, no implementation for $fun!\");";
Write " return SAI_STATUS_NOT_IMPLEMENTED;";
Expand Down
Loading