Skip to content

Commit

Permalink
[sairedis] Record create, remove and set response in sync mode (sonic…
Browse files Browse the repository at this point in the history
…-net#869)

Start recording CRS operations response to sairedis.rec but only when response is not success.
  • Loading branch information
kcudnik authored Jul 30, 2021
1 parent f50dba7 commit f56a39e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/inc/Recorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ namespace sairedis
_In_ sai_status_t status,
_In_ const std::vector<swss::FieldValueTuple>& arguments);

void recordGenericResponse(
_In_ sai_status_t status);

public: // create ENTRY

SAI_REDIS_RECORDER_DECLARE_RECORD_CREATE(fdb_entry);
Expand Down Expand Up @@ -263,6 +266,11 @@ namespace sairedis
_In_ uint32_t objectCount,
_In_ const sai_status_t *objectStatuses);

void recordBulkGenericResponse(
_In_ sai_status_t status,
_In_ uint32_t objectCount,
_In_ const sai_status_t *objectStatuses);

public: // SAI query interface API

void recordFlushFdbEntries(
Expand Down
36 changes: 36 additions & 0 deletions lib/src/Recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,3 +1117,39 @@ void Recorder::recordStats(

m_recordStats = enable;
}


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

if (status != SAI_STATUS_SUCCESS)
{
// record only when response is not success

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

void Recorder::recordBulkGenericResponse(
_In_ sai_status_t status,
_In_ uint32_t objectCount,
_In_ const sai_status_t *objectStatuses)
{
SWSS_LOG_ENTER();

if (status != SAI_STATUS_SUCCESS)
{
// record only when response is not success

std::string statuses = "";

for (uint32_t i = 0; i < objectCount; i++)
{
statuses += "|" + sai_serialize_status(objectStatuses[i]);
}

recordLine("E|" + sai_serialize_status(status) + "|" + statuses);
}
}
4 changes: 4 additions & 0 deletions lib/src/RedisRemoteSaiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ sai_status_t RedisRemoteSaiInterface::waitForResponse(

auto status = m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_GETRESPONSE, kco);

m_recorder->recordGenericResponse(status);

return status;
}

Expand Down Expand Up @@ -1347,6 +1349,8 @@ sai_status_t RedisRemoteSaiInterface::waitForBulkResponse(
sai_deserialize_status(fvField(values[idx]), object_statuses[idx]);
}

m_recorder->recordBulkGenericResponse(status, object_count, object_statuses);

return status;
}

Expand Down

0 comments on commit f56a39e

Please sign in to comment.