diff --git a/lib/Switch.cpp b/lib/Switch.cpp index c7af4a297..90d42581d 100644 --- a/lib/Switch.cpp +++ b/lib/Switch.cpp @@ -118,6 +118,11 @@ void Switch::updateNotifications( (sai_bfd_session_state_change_notification_fn)attr.value.ptr; break; + case SAI_SWITCH_ATTR_TWAMP_SESSION_EVENT_NOTIFY: + m_switchNotifications.on_twamp_session_event = + (sai_twamp_session_event_notification_fn)attr.value.ptr; + break; + default: SWSS_LOG_ERROR("pointer for %s is not handled, FIXME!", meta->attridname); break; diff --git a/meta/Makefile.am b/meta/Makefile.am index c2de85b3f..d37803019 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -35,6 +35,7 @@ libsaimeta_la_SOURCES = \ NotificationSwitchShutdownRequest.cpp \ NotificationSwitchStateChange.cpp \ NotificationBfdSessionStateChange.cpp \ + NotificationTwampSessionEvent.cpp \ NumberOidIndexGenerator.cpp \ OidRefCounter.cpp \ PerformanceIntervalTimer.cpp \ diff --git a/meta/Meta.cpp b/meta/Meta.cpp index db1c6cc71..181b40973 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -6686,6 +6686,69 @@ void Meta::meta_sai_on_bfd_session_state_change( } } +void Meta::meta_sai_on_twamp_session_event_single( + _In_ const sai_twamp_session_event_notification_data_t& data) +{ + SWSS_LOG_ENTER(); + + auto ot = objectTypeQuery(data.twamp_session_id); + + bool valid = false; + + switch (ot) + { + // TODO hardcoded types, must advance SAI repository commit to get metadata for this + case SAI_OBJECT_TYPE_TWAMP_SESSION: + + valid = true; + break; + + default: + + SWSS_LOG_ERROR("data.twamp_session_id %s has unexpected type: %s, expected TWAMP_SESSION", + sai_serialize_object_id(data.twamp_session_id).c_str(), + sai_serialize_object_type(ot).c_str()); + break; + } + + if (valid && !m_oids.objectReferenceExists(data.twamp_session_id)) + { + SWSS_LOG_NOTICE("data.twamp_session_id new object spotted %s not present in local DB (snoop!)", + sai_serialize_object_id(data.twamp_session_id).c_str()); + + /* + * add (sai_object_type_t) for SAI_OBJECT_TYPE_TWAMP_SESSION is not defined in saitypes.h + * todo: delete (sai_object_type_t) after move SAI_OBJECT_TYPE_TWAMP_SESSION to saitypes.h + */ + sai_object_meta_key_t key = { .objecttype = (sai_object_type_t)ot, .objectkey = { .key = { .object_id = data.twamp_session_id } } }; + + m_oids.objectReferenceInsert(data.twamp_session_id); + + if (!m_saiObjectCollection.objectExists(key)) + { + m_saiObjectCollection.createObject(key); + } + } +} + +void Meta::meta_sai_on_twamp_session_event( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data) +{ + SWSS_LOG_ENTER(); + + if (count && data == NULL) + { + SWSS_LOG_ERROR("sai_twamp_session_event_notification_data_t pointer is NULL but count is %u", count); + return; + } + + for (uint32_t i = 0; i < count; ++i) + { + meta_sai_on_twamp_session_event_single(data[i]); + } +} + int32_t Meta::getObjectReferenceCount( _In_ sai_object_id_t oid) const { diff --git a/meta/Meta.h b/meta/Meta.h index 0eae42b51..da881b200 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -220,6 +220,10 @@ namespace saimeta _In_ uint32_t count, _In_ const sai_bfd_session_state_notification_t *data); + void meta_sai_on_twamp_session_event( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data); + private: // notifications helpers void meta_sai_on_fdb_flush_event_consolidated( @@ -243,6 +247,9 @@ namespace saimeta void meta_sai_on_bfd_session_state_change_single( _In_ const sai_bfd_session_state_notification_t& data); + void meta_sai_on_twamp_session_event_single( + _In_ const sai_twamp_session_event_notification_data_t& data); + private: // validation helpers sai_status_t meta_generic_validation_objlist( diff --git a/meta/NotificationFactory.cpp b/meta/NotificationFactory.cpp index 9682848d8..5fcaa523e 100644 --- a/meta/NotificationFactory.cpp +++ b/meta/NotificationFactory.cpp @@ -6,6 +6,7 @@ #include "NotificationSwitchShutdownRequest.h" #include "NotificationSwitchStateChange.h" #include "NotificationBfdSessionStateChange.h" +#include "NotificationTwampSessionEvent.h" #include "sairediscommon.h" #include "swss/logger.h" @@ -39,5 +40,8 @@ std::shared_ptr NotificationFactory::deserialize( if (name == SAI_SWITCH_NOTIFICATION_NAME_BFD_SESSION_STATE_CHANGE) return std::make_shared(serializedNotification); + if (name == SAI_SWITCH_NOTIFICATION_NAME_TWAMP_SESSION_EVENT) + return std::make_shared(serializedNotification); + SWSS_LOG_THROW("unknown notification: '%s', FIXME", name.c_str()); } diff --git a/meta/NotificationTwampSessionEvent.cpp b/meta/NotificationTwampSessionEvent.cpp new file mode 100644 index 000000000..371f7d57f --- /dev/null +++ b/meta/NotificationTwampSessionEvent.cpp @@ -0,0 +1,77 @@ +#include "NotificationTwampSessionEvent.h" + +#include "swss/logger.h" + +#include "meta/sai_serialize.h" + +using namespace sairedis; + +NotificationTwampSessionEvent::NotificationTwampSessionEvent( + _In_ const std::string& serializedNotification): + Notification( + SAI_SWITCH_NOTIFICATION_TYPE_TWAMP_SESSION_EVENT, + serializedNotification), + m_twampSessionEventNotificationData(nullptr) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_twamp_session_event_ntf( + serializedNotification, + m_count, + &m_twampSessionEventNotificationData); +} + +NotificationTwampSessionEvent::~NotificationTwampSessionEvent() +{ + SWSS_LOG_ENTER(); + + sai_deserialize_free_twamp_session_event_ntf(m_count, m_twampSessionEventNotificationData); +} + +sai_object_id_t NotificationTwampSessionEvent::getSwitchId() const +{ + SWSS_LOG_ENTER(); + + // this notification don't contain switch id field + + return SAI_NULL_OBJECT_ID; +} + +sai_object_id_t NotificationTwampSessionEvent::getAnyObjectId() const +{ + SWSS_LOG_ENTER(); + + if (m_twampSessionEventNotificationData == nullptr) + { + return SAI_NULL_OBJECT_ID; + } + + for (uint32_t idx = 0; idx < m_count; idx++) + { + if (m_twampSessionEventNotificationData[idx].twamp_session_id != SAI_NULL_OBJECT_ID) + { + return m_twampSessionEventNotificationData[idx].twamp_session_id; + } + } + + return SAI_NULL_OBJECT_ID; +} + +void NotificationTwampSessionEvent::processMetadata( + _In_ std::shared_ptr meta) const +{ + SWSS_LOG_ENTER(); + + meta->meta_sai_on_twamp_session_event(m_count, m_twampSessionEventNotificationData); +} + +void NotificationTwampSessionEvent::executeCallback( + _In_ const sai_switch_notifications_t& switchNotifications) const +{ + SWSS_LOG_ENTER(); + + if (switchNotifications.on_twamp_session_event) + { + switchNotifications.on_twamp_session_event(m_count, m_twampSessionEventNotificationData); + } +} diff --git a/meta/NotificationTwampSessionEvent.h b/meta/NotificationTwampSessionEvent.h new file mode 100644 index 000000000..3c98fab82 --- /dev/null +++ b/meta/NotificationTwampSessionEvent.h @@ -0,0 +1,35 @@ +#pragma once + +#include "Notification.h" + +namespace sairedis +{ + class NotificationTwampSessionEvent: + public Notification + { + public: + + NotificationTwampSessionEvent( + _In_ const std::string& serializedNotification); + + virtual ~NotificationTwampSessionEvent(); + + public: + + virtual sai_object_id_t getSwitchId() const override; + + virtual sai_object_id_t getAnyObjectId() const override; + + virtual void processMetadata( + _In_ std::shared_ptr meta) const override; + + virtual void executeCallback( + _In_ const sai_switch_notifications_t& switchNotifications) const override; + + private: + + uint32_t m_count; + + sai_twamp_session_event_notification_data_t *m_twampSessionEventNotificationData; + }; +} diff --git a/meta/SaiSerialize.cpp b/meta/SaiSerialize.cpp index af039526f..c89ef6182 100644 --- a/meta/SaiSerialize.cpp +++ b/meta/SaiSerialize.cpp @@ -2196,6 +2196,52 @@ std::string sai_serialize_bfd_session_state( return sai_serialize_enum(status, &sai_metadata_enum_sai_bfd_session_state_t); } +std::string sai_serialize_twamp_session_state( + _In_ sai_twamp_session_state_t status) +{ + SWSS_LOG_ENTER(); + + return sai_serialize_enum(status, &sai_metadata_enum_sai_twamp_session_state_t); +} + +std::string sai_serialize_twamp_session_stat( + _In_ sai_twamp_session_stat_t counter) +{ + SWSS_LOG_ENTER(); + + return sai_serialize_enum(counter, &sai_metadata_enum_sai_twamp_session_stat_t); +} + +static json sai_serialize_json_twamp_session_event_notification_data( + _In_ const sai_twamp_session_event_notification_data_t& twamp_session_data) +{ + SWSS_LOG_ENTER(); + + json j; + + j["twamp_session_id"] = sai_serialize_object_id(twamp_session_data.twamp_session_id); + j["session_state"] = sai_serialize_twamp_session_state(twamp_session_data.session_state); + + j["index"] = sai_serialize_number(twamp_session_data.session_stats.index); + + json arr = json::array(); + + for (uint32_t i = 0; i < twamp_session_data.session_stats.number_of_counters; ++i) + { + json item; + + item["counters_ids"] = sai_serialize_twamp_session_stat(twamp_session_data.session_stats.counters_ids[i]); + item["counters"] = sai_serialize_number(twamp_session_data.session_stats.counters[i]); + + arr.push_back(item); + } + + j["list"] = arr; + + // we don't need count since it can be deduced + return j; +} + std::string sai_serialize_fdb_event_ntf( _In_ uint32_t count, _In_ const sai_fdb_event_notification_data_t* fdb_event) @@ -2325,6 +2371,30 @@ std::string sai_serialize_bfd_session_state_ntf( return j.dump(); } +std::string sai_serialize_twamp_session_event_ntf( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t* twamp_session_event) +{ + SWSS_LOG_ENTER(); + + if (twamp_session_event == NULL) + { + SWSS_LOG_THROW("twamp_session_state pointer is null"); + } + + json j = json::array(); + + for (uint32_t i = 0; i < count; ++i) + { + json item = sai_serialize_json_twamp_session_event_notification_data(twamp_session_event[i]); + + j.push_back(item); + } + + // we don't need count since it can be deduced + return j.dump(); +} + json sai_serialize_nat_entry_key( _In_ const sai_nat_entry_key_t& nat_entry_key) { @@ -3945,6 +4015,24 @@ void sai_deserialize_bfd_session_state( sai_deserialize_enum(s, &sai_metadata_enum_sai_bfd_session_state_t, (int32_t&)state); } +void sai_deserialize_twamp_session_state( + _In_ const std::string& s, + _Out_ sai_twamp_session_state_t& state) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_enum(s, &sai_metadata_enum_sai_twamp_session_state_t, (int32_t&)state); +} + +void sai_deserialize_twamp_session_stat( + _In_ const std::string& s, + _Out_ sai_twamp_session_stat_t& stat) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_enum(s, &sai_metadata_enum_sai_twamp_session_stat_t, (int32_t&)stat); +} + void sai_deserialize_switch_oper_status( _In_ const std::string& s, _Out_ sai_object_id_t &switch_id, @@ -4031,6 +4119,60 @@ void sai_deserialize_neighbor_entry( sai_deserialize_ip_address(j["ip"], ne.ip_address); } +void sai_deserialize_twamp_session_stats_data( + _In_ const std::string& s, + _Out_ sai_twamp_session_stats_data_t &twamp_session_stats_data) +{ + SWSS_LOG_ENTER(); + + json j = json::parse(s); + + sai_deserialize_number(j["index"], twamp_session_stats_data.index); + + json arr = j["list"]; + + twamp_session_stats_data.number_of_counters = (uint32_t)arr.size(); + twamp_session_stats_data.counters_ids = new sai_twamp_session_stat_t[twamp_session_stats_data.number_of_counters]; + twamp_session_stats_data.counters = new uint64_t[twamp_session_stats_data.number_of_counters]; + + for (uint32_t i = 0; i < twamp_session_stats_data.number_of_counters; ++i) + { + const json &item = arr[i]; + + sai_deserialize_twamp_session_stat(item["counters_ids"], twamp_session_stats_data.counters_ids[i]); + + sai_deserialize_number(item["counters"], twamp_session_stats_data.counters[i]); + } +} + +void sai_deserialize_json_twamp_session_event_notification_data( + _In_ const json& j, + _Out_ sai_twamp_session_event_notification_data_t& twamp_session_data) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_object_id(j["twamp_session_id"], twamp_session_data.twamp_session_id); + sai_deserialize_twamp_session_state(j["session_state"], twamp_session_data.session_state); + + sai_deserialize_number(j["index"], twamp_session_data.session_stats.index); + + json arr = j["list"]; + + twamp_session_data.session_stats.number_of_counters = (uint32_t)arr.size(); + twamp_session_data.session_stats.counters_ids = new sai_twamp_session_stat_t[twamp_session_data.session_stats.number_of_counters]; + twamp_session_data.session_stats.counters = new uint64_t[twamp_session_data.session_stats.number_of_counters]; + + for (uint32_t i = 0; i < twamp_session_data.session_stats.number_of_counters; ++i) + { + const json &item = arr[i]; + + sai_deserialize_twamp_session_stat(item["counters_ids"], twamp_session_data.session_stats.counters_ids[i]); + + sai_deserialize_number(item["counters"], twamp_session_data.session_stats.counters[i]); + } + +} + #define EXPECT(x) { \ if (strncmp(buf, x, sizeof(x) - 1) == 0) { buf += sizeof(x) - 1; } \ else { \ @@ -4637,6 +4779,27 @@ void sai_deserialize_bfd_session_state_ntf( *bfd_session_state = data; } +void sai_deserialize_twamp_session_event_ntf( + _In_ const std::string& s, + _Out_ uint32_t &count, + _Out_ sai_twamp_session_event_notification_data_t** twamp_session_event) +{ + SWSS_LOG_ENTER(); + + json j = json::parse(s); + + count = (uint32_t)j.size(); + + auto data = new sai_twamp_session_event_notification_data_t[count]; + + for (uint32_t i = 0; i < count; ++i) + { + sai_deserialize_json_twamp_session_event_notification_data(j[i], data[i]); + } + + *twamp_session_event = data; +} + // deserialize free void sai_deserialize_free_attribute_value( @@ -4899,6 +5062,15 @@ void sai_deserialize_free_bfd_session_state_ntf( delete[] bfd_session_state; } +void sai_deserialize_free_twamp_session_event_ntf( + _In_ uint32_t count, + _In_ sai_twamp_session_event_notification_data_t* twamp_session_event) +{ + SWSS_LOG_ENTER(); + + delete[] twamp_session_event; +} + void sai_deserialize_ingress_priority_group_attr( _In_ const std::string& s, _Out_ sai_ingress_priority_group_attr_t& attr) diff --git a/meta/sai_serialize.h b/meta/sai_serialize.h index ea6a52404..a9756edc4 100644 --- a/meta/sai_serialize.h +++ b/meta/sai_serialize.h @@ -250,6 +250,9 @@ std::string sai_serialize_nat_entry_type( std::string sai_serialize_qos_map_item( _In_ const sai_qos_map_t& qosmap); +std::string sai_serialize_twamp_session_stat( + _In_ const sai_twamp_session_stat_t counter); + // serialize notifications std::string sai_serialize_fdb_event_ntf( @@ -272,6 +275,10 @@ std::string sai_serialize_bfd_session_state_ntf( _In_ uint32_t count, _In_ const sai_bfd_session_state_notification_t* bfd_session_state); +std::string sai_serialize_twamp_session_event_ntf( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t* twamp_session_event); + // sairedis std::string sai_serialize( @@ -470,6 +477,11 @@ void sai_deserialize_bfd_session_state_ntf( _Out_ uint32_t &count, _Out_ sai_bfd_session_state_notification_t** bfdsession); +void sai_deserialize_twamp_session_event_ntf( + _In_ const std::string& s, + _Out_ uint32_t &count, + _Out_ sai_twamp_session_event_notification_data_t** twamp_session_data); + // free methods void sai_deserialize_free_attribute_value( @@ -502,6 +514,10 @@ void sai_deserialize_ingress_priority_group_attr( _In_ const std::string& s, _Out_ sai_ingress_priority_group_attr_t& attr); +void sai_deserialize_free_twamp_session_event_ntf( + _In_ uint32_t count, + _In_ sai_twamp_session_event_notification_data_t* twamp_session_event); + void sai_deserialize_queue_attr( _In_ const std::string& s, _Out_ sai_queue_attr_t& attr); diff --git a/syncd/NotificationHandler.cpp b/syncd/NotificationHandler.cpp index 7e0c29573..7c6c57036 100644 --- a/syncd/NotificationHandler.cpp +++ b/syncd/NotificationHandler.cpp @@ -116,6 +116,10 @@ void NotificationHandler::updateNotificationsPointers( attr.value.ptr = (void*)m_switchNotifications.on_bfd_session_state_change; break; + case SAI_SWITCH_ATTR_TWAMP_SESSION_EVENT_NOTIFY: + attr.value.ptr = (void*)m_switchNotifications.on_twamp_session_event; + break; + default: SWSS_LOG_ERROR("pointer for %s is not handled, FIXME!", meta->attridname); @@ -224,6 +228,17 @@ void NotificationHandler::enqueueNotification( } } +void NotificationHandler::onTwampSessionEvent( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data) +{ + SWSS_LOG_ENTER(); + + std::string s = sai_serialize_twamp_session_event_ntf(count, data); + + enqueueNotification(SAI_SWITCH_NOTIFICATION_NAME_TWAMP_SESSION_EVENT, s); +} + void NotificationHandler::enqueueNotification( _In_ const std::string& op, _In_ const std::string& data) diff --git a/syncd/NotificationHandler.h b/syncd/NotificationHandler.h index 060009b49..06d7cfb26 100644 --- a/syncd/NotificationHandler.h +++ b/syncd/NotificationHandler.h @@ -75,6 +75,10 @@ namespace syncd _In_ const std::string& op, _In_ const std::string& data); + void onTwampSessionEvent( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data); + private: sai_switch_notifications_t m_switchNotifications; diff --git a/syncd/NotificationProcessor.cpp b/syncd/NotificationProcessor.cpp index 8ab4ff194..9fe3dd215 100644 --- a/syncd/NotificationProcessor.cpp +++ b/syncd/NotificationProcessor.cpp @@ -548,6 +548,36 @@ void NotificationProcessor::process_on_switch_shutdown_request( sendNotification(SAI_SWITCH_NOTIFICATION_NAME_SWITCH_SHUTDOWN_REQUEST, s); } +void NotificationProcessor::process_on_twamp_session_event( + _In_ uint32_t count, + _In_ sai_twamp_session_event_notification_data_t *data) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_DEBUG("twamp sessuin state notification count: %u", count); + + for (uint32_t i = 0; i < count; i++) + { + sai_twamp_session_event_notification_data_t *twamp_session_state = &data[i]; + + /* + * We are using switch_rid as null, since TWAMP should be already + * defined inside local db after creation. + * + * If this will be faster than return from create TWAMP then we can use + * query switch id and extract rid of switch id and then convert it to + * switch vid. + */ + + twamp_session_state->twamp_session_id = m_translator->translateRidToVid(twamp_session_state->twamp_session_id, SAI_NULL_OBJECT_ID); + } + + /* send notification to syncd */ + std::string s = sai_serialize_twamp_session_event_ntf(count, data); + + sendNotification(SAI_SWITCH_NOTIFICATION_NAME_TWAMP_SESSION_EVENT, s); +} + void NotificationProcessor::handle_switch_state_change( _In_ const std::string &data) { @@ -653,6 +683,21 @@ void NotificationProcessor::handle_switch_shutdown_request( process_on_switch_shutdown_request(switch_id); } +void NotificationProcessor::handle_twamp_session_event( + _In_ const std::string &data) +{ + SWSS_LOG_ENTER(); + + uint32_t count; + sai_twamp_session_event_notification_data_t *twampsessionevent = NULL; + + sai_deserialize_twamp_session_event_ntf(data, count, &twampsessionevent); + + process_on_twamp_session_event(count, twampsessionevent); + + sai_deserialize_free_twamp_session_event_ntf(count, twampsessionevent); +} + void NotificationProcessor::processNotification( _In_ const swss::KeyOpFieldsValuesTuple& item) { @@ -697,6 +742,10 @@ void NotificationProcessor::syncProcessNotification( { handle_bfd_session_state_change(data); } + else if (notification == SAI_SWITCH_NOTIFICATION_NAME_TWAMP_SESSION_EVENT) + { + handle_twamp_session_event(data); + } else { SWSS_LOG_ERROR("unknown notification: %s", notification.c_str()); diff --git a/syncd/NotificationProcessor.h b/syncd/NotificationProcessor.h index f7ac2c674..844f8f195 100644 --- a/syncd/NotificationProcessor.h +++ b/syncd/NotificationProcessor.h @@ -95,6 +95,10 @@ namespace syncd void process_on_switch_shutdown_request( _In_ sai_object_id_t switch_rid); + void process_on_twamp_session_event( + _In_ uint32_t count, + _In_ sai_twamp_session_event_notification_data_t *data); + private: // handlers void handle_switch_state_change( @@ -118,6 +122,9 @@ namespace syncd void handle_switch_shutdown_request( _In_ const std::string &data); + void handle_twamp_session_event( + _In_ const std::string &data); + void processNotification( _In_ const swss::KeyOpFieldsValuesTuple& item); diff --git a/syncd/SwitchNotifications.cpp b/syncd/SwitchNotifications.cpp index 75d176e74..294e056d2 100644 --- a/syncd/SwitchNotifications.cpp +++ b/syncd/SwitchNotifications.cpp @@ -106,6 +106,16 @@ void SwitchNotifications::SlotBase::onSwitchStateChange( return m_slots.at(context)->m_handler->onSwitchStateChange(switch_id, switch_oper_status); } +void SwitchNotifications::SlotBase::onTwampSessionEvent( + _In_ int context, + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data) +{ + SWSS_LOG_ENTER(); + + return m_slots.at(context)->m_handler->onTwampSessionEvent(count, data); +} + const sai_switch_notifications_t& SwitchNotifications::SlotBase::getSwitchNotifications() const { SWSS_LOG_ENTER(); diff --git a/syncd/SwitchNotifications.h b/syncd/SwitchNotifications.h index afc64c9e6..8d80b0c2a 100644 --- a/syncd/SwitchNotifications.h +++ b/syncd/SwitchNotifications.h @@ -69,6 +69,11 @@ namespace syncd _In_ uint32_t count, _In_ const sai_bfd_session_state_notification_t *data); + static void onTwampSessionEvent( + _In_ int context, + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data); + protected: SwitchNotifications* m_handler; @@ -96,7 +101,7 @@ namespace syncd .on_switch_shutdown_request = &Slot::onSwitchShutdownRequest, .on_switch_state_change = &Slot::onSwitchStateChange, .on_tam_event = nullptr, - .on_twamp_session_event = nullptr, + .on_twamp_session_event = &Slot::onTwampSessionEvent, }) { } virtual ~Slot() {} @@ -164,6 +169,15 @@ namespace syncd return SlotBase::onSwitchStateChange(context, switch_id, switch_oper_status); } + + static void onTwampSessionEvent( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data) + { + SWSS_LOG_ENTER(); + + return SlotBase::onTwampSessionEvent(context, count, data); + } }; static std::vector m_slots; @@ -180,13 +194,14 @@ namespace syncd public: // wrapped methods - std::function onFdbEvent; - std::function onNatEvent; - std::function onPortStateChange; - std::function onQueuePfcDeadlock; - std::function onSwitchShutdownRequest; - std::function onSwitchStateChange; - std::function onBfdSessionStateChange; + std::function onFdbEvent; + std::function onNatEvent; + std::function onPortStateChange; + std::function onQueuePfcDeadlock; + std::function onSwitchShutdownRequest; + std::function onSwitchStateChange; + std::function onBfdSessionStateChange; + std::function onTwampSessionEvent; private: diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 2e560d5d1..5d4f267b4 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -158,6 +158,7 @@ Syncd::Syncd( m_sn.onSwitchShutdownRequest = std::bind(&NotificationHandler::onSwitchShutdownRequest, m_handler.get(), _1); m_sn.onSwitchStateChange = std::bind(&NotificationHandler::onSwitchStateChange, m_handler.get(), _1, _2); m_sn.onBfdSessionStateChange = std::bind(&NotificationHandler::onBfdSessionStateChange, m_handler.get(), _1, _2); + m_sn.onTwampSessionEvent = std::bind(&NotificationHandler::onTwampSessionEvent, m_handler.get(), _1, _2); m_handler->setSwitchNotifications(m_sn.getSwitchNotifications()); @@ -4395,7 +4396,8 @@ void Syncd::performWarmRestartSingleSwitch( SAI_SWITCH_ATTR_NAT_EVENT_NOTIFY, SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY, SAI_SWITCH_ATTR_QUEUE_PFC_DEADLOCK_NOTIFY, - SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY + SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY, + SAI_SWITCH_ATTR_TWAMP_SESSION_EVENT_NOTIFY }; std::vector attrs;