diff --git a/lib/ClientSai.cpp b/lib/ClientSai.cpp index 74e09a3a8..279492dbf 100644 --- a/lib/ClientSai.cpp +++ b/lib/ClientSai.cpp @@ -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; +} diff --git a/lib/ClientSai.h b/lib/ClientSai.h index cbe6a3204..ba185cf92 100644 --- a/lib/ClientSai.h +++ b/lib/ClientSai.h @@ -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( diff --git a/lib/ClientServerSai.cpp b/lib/ClientServerSai.cpp index e3a9f808e..d7eb0723d 100644 --- a/lib/ClientServerSai.cpp +++ b/lib/ClientServerSai.cpp @@ -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); +} diff --git a/lib/ClientServerSai.h b/lib/ClientServerSai.h index a9163252d..a35ade869 100644 --- a/lib/ClientServerSai.h +++ b/lib/ClientServerSai.h @@ -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; diff --git a/lib/Recorder.cpp b/lib/Recorder.cpp index 1ba3828d9..643553a32 100644 --- a/lib/Recorder.cpp +++ b/lib/Recorder.cpp @@ -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& arguments) diff --git a/lib/Recorder.h b/lib/Recorder.h index f30c22b9d..59b8de635 100644 --- a/lib/Recorder.h +++ b/lib/Recorder.h @@ -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( diff --git a/lib/RedisRemoteSaiInterface.cpp b/lib/RedisRemoteSaiInterface.cpp index 4c0247109..960fc6990 100644 --- a/lib/RedisRemoteSaiInterface.cpp +++ b/lib/RedisRemoteSaiInterface.cpp @@ -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 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) diff --git a/lib/RedisRemoteSaiInterface.h b/lib/RedisRemoteSaiInterface.h index a97d34b62..edbb35219 100644 --- a/lib/RedisRemoteSaiInterface.h +++ b/lib/RedisRemoteSaiInterface.h @@ -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( diff --git a/lib/Sai.cpp b/lib/Sai.cpp index 433a421cf..dac82a255 100644 --- a/lib/Sai.cpp +++ b/lib/Sai.cpp @@ -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. * diff --git a/lib/Sai.h b/lib/Sai.h index 1b45c11e0..478858b9a 100644 --- a/lib/Sai.h +++ b/lib/Sai.h @@ -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( diff --git a/lib/ServerSai.cpp b/lib/ServerSai.cpp index 6a8f5ad92..30ffc9b61 100644 --- a/lib/ServerSai.cpp +++ b/lib/ServerSai.cpp @@ -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(); @@ -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) diff --git a/lib/ServerSai.h b/lib/ServerSai.h index e0a17eab3..3cb1a57d8 100644 --- a/lib/ServerSai.h +++ b/lib/ServerSai.h @@ -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(); @@ -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; diff --git a/lib/sairediscommon.h b/lib/sairediscommon.h index d09ddc0ab..31aabb578 100644 --- a/lib/sairediscommon.h +++ b/lib/sairediscommon.h @@ -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" diff --git a/meta/DummySaiInterface.cpp b/meta/DummySaiInterface.cpp index 63a7d62d0..6c423aefb 100644 --- a/meta/DummySaiInterface.cpp +++ b/meta/DummySaiInterface.cpp @@ -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) diff --git a/meta/DummySaiInterface.h b/meta/DummySaiInterface.h index 0a61719d6..303977ba3 100644 --- a/meta/DummySaiInterface.h +++ b/meta/DummySaiInterface.h @@ -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( diff --git a/meta/Meta.cpp b/meta/Meta.cpp index a9851d201..b914cb204 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -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) { diff --git a/meta/Meta.h b/meta/Meta.h index ce8a0a2dd..a0e1d8719 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -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(); diff --git a/meta/SaiInterface.h b/meta/SaiInterface.h index fb78e1569..00c14aadb 100644 --- a/meta/SaiInterface.h +++ b/meta/SaiInterface.h @@ -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( diff --git a/proxylib/Proxy.cpp b/proxylib/Proxy.cpp index ab3a280e0..b817b11ca 100644 --- a/proxylib/Proxy.cpp +++ b/proxylib/Proxy.cpp @@ -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) { diff --git a/proxylib/Proxy.h b/proxylib/Proxy.h index 029772634..e97b15b53 100644 --- a/proxylib/Proxy.h +++ b/proxylib/Proxy.h @@ -106,6 +106,9 @@ namespace saiproxy void processClearStats( _In_ const swss::KeyOpFieldsValuesTuple &kco); + void processDbgGenerateDump( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + private: // notifications void onFdbEvent( diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp index 4654e5acd..a4651b518 100644 --- a/proxylib/Sai.cpp +++ b/proxylib/Sai.cpp @@ -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 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) diff --git a/proxylib/Sai.h b/proxylib/Sai.h index 6208813a9..8da230741 100644 --- a/proxylib/Sai.h +++ b/proxylib/Sai.h @@ -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( diff --git a/stub.pl b/stub.pl index 237c62927..cf360022b 100755 --- a/stub.pl +++ b/stub.pl @@ -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;"; diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index e7efff34e..428d76935 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -410,9 +410,37 @@ sai_status_t Syncd::processSingleEvent( if (op == REDIS_FLEX_COUNTER_COMMAND_DEL_GROUP) return processFlexCounterGroupEvent(key, DEL_COMMAND, kfvFieldsValues(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 Syncd::processDbgGenerateDump( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const auto& values = kfvFieldsValues(kco); + 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); + + if (values.size() != 1) + { + SWSS_LOG_ERROR("Invalid input: expected 1 arguments, received %zu", values.size()); + m_selectableChannel->set(sai_serialize_status(SAI_STATUS_INVALID_PARAMETER), {} , REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE); + + return SAI_STATUS_INVALID_PARAMETER; + } + + m_selectableChannel->set(sai_serialize_status(status), {} , REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE); + + return status; +} + + sai_status_t Syncd::processAttrCapabilityQuery( _In_ const swss::KeyOpFieldsValuesTuple &kco) { diff --git a/syncd/Syncd.h b/syncd/Syncd.h index 7cbd0575c..324d4ef11 100644 --- a/syncd/Syncd.h +++ b/syncd/Syncd.h @@ -210,6 +210,9 @@ namespace syncd _In_ const std::vector &values, _In_ bool fromAsicChannel=true); + sai_status_t processDbgGenerateDump( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + private: // process quad oid sai_status_t processOidCreate( diff --git a/syncd/VendorSai.cpp b/syncd/VendorSai.cpp index 4e6ee2d8b..de4f5ba48 100644 --- a/syncd/VendorSai.cpp +++ b/syncd/VendorSai.cpp @@ -41,7 +41,7 @@ VendorSai::VendorSai() #else .bulk_object_get_stats = nullptr, #endif - .dbg_generate_dump = nullptr, + .dbg_generate_dump = &sai_dbg_generate_dump, .get_maximum_attribute_count = nullptr, .get_object_count = nullptr, .get_object_key = nullptr, @@ -1908,3 +1908,11 @@ sai_log_level_t VendorSai::logGet( return SAI_LOG_LEVEL_NOTICE; } + +sai_status_t VendorSai::dbgGenerateDump( + _In_ const char *dump_file_name) +{ + SWSS_LOG_ENTER(); + + return m_globalApis.dbg_generate_dump(dump_file_name); +} diff --git a/syncd/VendorSai.h b/syncd/VendorSai.h index 3f2ccc48c..1953a3816 100644 --- a/syncd/VendorSai.h +++ b/syncd/VendorSai.h @@ -214,6 +214,9 @@ namespace syncd 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: // extra API virtual sai_log_level_t logGet( diff --git a/unittest/lib/TestClientSai.cpp b/unittest/lib/TestClientSai.cpp index b080fd23a..b2f88ddaf 100644 --- a/unittest/lib/TestClientSai.cpp +++ b/unittest/lib/TestClientSai.cpp @@ -50,3 +50,13 @@ TEST(ClientSai, bulkGet) statuses)); } +TEST(ClientSai, dbgGenerateDump) +{ + ClientSai sai; + + sai.apiInitialize(0,&test_services); + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(sai.dbgGenerateDump(filePath.c_str()), SAI_STATUS_NOT_IMPLEMENTED); +} \ No newline at end of file diff --git a/unittest/lib/TestClientServerSai.cpp b/unittest/lib/TestClientServerSai.cpp index 1f6c06a50..7528a8ecc 100644 --- a/unittest/lib/TestClientServerSai.cpp +++ b/unittest/lib/TestClientServerSai.cpp @@ -105,6 +105,17 @@ TEST(ClientServerSai, logSet) EXPECT_EQ(SAI_STATUS_SUCCESS, css->logSet(SAI_API_PORT, SAI_LOG_LEVEL_NOTICE)); } +TEST(ClientServerSai, dbgGenerateDump) +{ + auto css = std::make_shared(); + + const std::string filePath = "/var/log/dbgGenerateDump.log"; + + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); + + EXPECT_EQ(SAI_STATUS_SUCCESS, css->dbgGenerateDump(filePath.c_str())); +} + TEST(ClientServerSai, bulkGetClearStats) { auto css = std::make_shared(); diff --git a/unittest/lib/TestRedisRemoteSaiInterface.cpp b/unittest/lib/TestRedisRemoteSaiInterface.cpp index a638228a0..0b64ae325 100644 --- a/unittest/lib/TestRedisRemoteSaiInterface.cpp +++ b/unittest/lib/TestRedisRemoteSaiInterface.cpp @@ -28,3 +28,14 @@ TEST(RedisRemoteSaiInterface, bulkGet) statuses)); } +TEST(RedisRemoteSaiInterface, dbgGenerateDump) +{ + auto ctx = ContextConfigContainer::loadFromFile("foo"); + auto rec = std::make_shared(); + + RedisRemoteSaiInterface sai(ctx->get(0), nullptr, rec); + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(sai.dbgGenerateDump(filePath.c_str()), SAI_STATUS_SUCCESS); +} diff --git a/unittest/lib/TestSai.cpp b/unittest/lib/TestSai.cpp index 9d3e11790..73766bd10 100644 --- a/unittest/lib/TestSai.cpp +++ b/unittest/lib/TestSai.cpp @@ -40,6 +40,19 @@ TEST(Sai, queryApiVersion) EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + sai.apiInitialize(0,&test_services); + + const std::string filePath = "/var/log/testDump.log"; + + auto status = sai.dbgGenerateDump(filePath.c_str()); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); +} + TEST(Sai, bulkGet) { Sai sai; diff --git a/unittest/meta/TestDummySaiInterface.cpp b/unittest/meta/TestDummySaiInterface.cpp index 4c8ca1ca5..15436dd30 100644 --- a/unittest/meta/TestDummySaiInterface.cpp +++ b/unittest/meta/TestDummySaiInterface.cpp @@ -20,6 +20,17 @@ TEST(DummySaiInterface, queryApiVersion) EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST(DummySaiInterface, dbgGenerateDump) +{ + DummySaiInterface sai; + + sai.apiInitialize(0,0); + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(sai.dbgGenerateDump(filePath.c_str()), SAI_STATUS_SUCCESS); +} + TEST(DummySaiInterface, bulkGet) { DummySaiInterface sai; diff --git a/unittest/meta/TestMeta.cpp b/unittest/meta/TestMeta.cpp index 0b0d35b25..ead3f3497 100644 --- a/unittest/meta/TestMeta.cpp +++ b/unittest/meta/TestMeta.cpp @@ -898,6 +898,15 @@ TEST(Meta, queryAttributeCapability) EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAttributeCapability(switchId, SAI_OBJECT_TYPE_ACL_ENTRY, 100000, &cap)); } +TEST(Meta, dbgGenerateDump) +{ + const std::string filePath = "/var/log/testDump.log"; + + Meta m(std::make_shared()); + + EXPECT_EQ(SAI_STATUS_SUCCESS, m.dbgGenerateDump(filePath.c_str())); +} + TEST(Meta, queryAttributeEnumValuesCapability) { Meta m(std::make_shared()); diff --git a/unittest/proxylib/TestSai.cpp b/unittest/proxylib/TestSai.cpp index 80f89b083..21f79a6b4 100644 --- a/unittest/proxylib/TestSai.cpp +++ b/unittest/proxylib/TestSai.cpp @@ -368,6 +368,29 @@ TEST(Sai, processQueryAttributeCapability) thread->join(); } +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + const std::string filePath = "/var/log/testDump.log"; + + auto status = sai.dbgGenerateDump(filePath.c_str()); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + TEST(Sai, queryAttributeEnumValuesCapability) { Sai sai; diff --git a/unittest/syncd/MockableSaiInterface.cpp b/unittest/syncd/MockableSaiInterface.cpp index df2fdc302..05e8de6b0 100644 --- a/unittest/syncd/MockableSaiInterface.cpp +++ b/unittest/syncd/MockableSaiInterface.cpp @@ -363,6 +363,18 @@ sai_status_t MockableSaiInterface::queryAttributeCapability( return SAI_STATUS_SUCCESS; } +sai_status_t MockableSaiInterface::dbgGenerateDump( + _In_ const char *dump_file_name) +{ + SWSS_LOG_ENTER(); + if (mock_dbgGenerateDump) + { + return mock_dbgGenerateDump(dump_file_name); + } + + return SAI_STATUS_SUCCESS; +} + sai_status_t MockableSaiInterface::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, diff --git a/unittest/syncd/MockableSaiInterface.h b/unittest/syncd/MockableSaiInterface.h index f6ab10def..402167255 100644 --- a/unittest/syncd/MockableSaiInterface.h +++ b/unittest/syncd/MockableSaiInterface.h @@ -220,6 +220,10 @@ class MockableSaiInterface: public saimeta::DummySaiInterface std::function mock_queryAttributeCapability; + virtual sai_status_t dbgGenerateDump( + _In_ const char *dump_file_name) override; + + std::function mock_dbgGenerateDump; virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, diff --git a/unittest/syncd/TestVendorSai.cpp b/unittest/syncd/TestVendorSai.cpp index 63977e713..4a5a8f75f 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -1543,3 +1543,10 @@ TEST(VendorSai, bulk_meter_rules) EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy0)); EXPECT_EQ(SAI_STATUS_SUCCESS, sai.remove((sai_object_type_t)SAI_OBJECT_TYPE_METER_POLICY, meter_policy1)); } + +TEST_F(VendorSaiTest, dbgGenerateDump) +{ + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(SAI_STATUS_SUCCESS, m_vsai->dbgGenerateDump(filePath.c_str())); +} diff --git a/unittest/vslib/TestSai.cpp b/unittest/vslib/TestSai.cpp index c45663de8..32d9a1a70 100644 --- a/unittest/vslib/TestSai.cpp +++ b/unittest/vslib/TestSai.cpp @@ -26,3 +26,11 @@ TEST(Sai, bulkGet) statuses)); } +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.dbgGenerateDump(filePath.c_str())); +} diff --git a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp index 445bc56b6..c07ecd16c 100644 --- a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp +++ b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp @@ -122,6 +122,13 @@ TEST_F(VirtualSwitchSaiInterfaceTest, queryApiVersion) EXPECT_EQ(m_vssai->queryApiVersion(&version), SAI_STATUS_SUCCESS); } +TEST_F(VirtualSwitchSaiInterfaceTest, dbgGenerateDump) +{ + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(m_vssai->dbgGenerateDump(filePath.c_str()), SAI_STATUS_SUCCESS); +} + TEST_F(VirtualSwitchSaiInterfaceTest, bulkGet) { sai_object_id_t oids[1] = {0}; diff --git a/vslib/Sai.cpp b/vslib/Sai.cpp index 97238f9de..4a5eb6585 100644 --- a/vslib/Sai.cpp +++ b/vslib/Sai.cpp @@ -853,6 +853,17 @@ sai_status_t Sai::queryApiVersion( return m_meta->queryApiVersion(version); } +sai_status_t Sai::dbgGenerateDump( + _In_ const char *dump_file_name) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + + std::shared_ptr Sai::getContext( _In_ uint32_t globalContext) const { diff --git a/vslib/Sai.h b/vslib/Sai.h index 191746155..41c87bd88 100644 --- a/vslib/Sai.h +++ b/vslib/Sai.h @@ -193,6 +193,9 @@ namespace saivs 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 pre sai_status_t preSet( diff --git a/vslib/VirtualSwitchSaiInterface.cpp b/vslib/VirtualSwitchSaiInterface.cpp index d866f5ac1..1a53fd531 100644 --- a/vslib/VirtualSwitchSaiInterface.cpp +++ b/vslib/VirtualSwitchSaiInterface.cpp @@ -1281,6 +1281,14 @@ sai_status_t VirtualSwitchSaiInterface::queryApiVersion( return SAI_STATUS_INVALID_PARAMETER; } +sai_status_t VirtualSwitchSaiInterface::dbgGenerateDump( + _In_ const char *dump_file_name) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_SUCCESS; +} + bool VirtualSwitchSaiInterface::writeWarmBootFile( _In_ const char* warmBootFile) const { diff --git a/vslib/VirtualSwitchSaiInterface.h b/vslib/VirtualSwitchSaiInterface.h index 25855fdec..6d0889f7e 100644 --- a/vslib/VirtualSwitchSaiInterface.h +++ b/vslib/VirtualSwitchSaiInterface.h @@ -192,6 +192,9 @@ namespace saivs 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(