diff --git a/lib/Switch.cpp b/lib/Switch.cpp index 4968a0289..8c198e2f0 100644 --- a/lib/Switch.cpp +++ b/lib/Switch.cpp @@ -123,6 +123,11 @@ void Switch::updateNotifications( (sai_port_host_tx_ready_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 d604241b2..8947603ca 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -35,6 +35,7 @@ libsaimeta_la_SOURCES = \ NotificationSwitchShutdownRequest.cpp \ NotificationSwitchStateChange.cpp \ NotificationBfdSessionStateChange.cpp \ + NotificationTwampSessionEvent.cpp \ NotificationPortHostTxReadyEvent.cpp \ NumberOidIndexGenerator.cpp \ OidRefCounter.cpp \ diff --git a/meta/Meta.cpp b/meta/Meta.cpp index b9d03a3a2..db9e6854e 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -6729,6 +6729,84 @@ 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; + } + + // check if all counter ids are in enum range + for (uint32_t idx = 0; idx < data.session_stats.number_of_counters; idx++) + { + if (!sai_metadata_get_enum_value_name(&sai_metadata_enum_sai_twamp_session_stat_t, data.session_stats.counters_ids[idx])) + { + SWSS_LOG_ERROR("value %d is not in range on sai_twamp_session_stat_t ", data.session_stats.counters_ids[idx]); + + return; + } + } + + 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()); + + 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); + } + } + + if (!sai_metadata_get_enum_value_name( + &sai_metadata_enum_sai_twamp_session_state_t, + data.session_state)) + { + SWSS_LOG_WARN("session_state value (%d) not found sai_twamp_session_state_t", + data.session_state); + } +} + +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 e018624e6..a30fc53ff 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -225,6 +225,10 @@ namespace saimeta _In_ sai_object_id_t switch_id, _In_ sai_port_host_tx_ready_status_t host_tx_ready_status); + 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( @@ -248,6 +252,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 456af8891..6381bd16b 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 "NotificationPortHostTxReadyEvent.h" #include "sairediscommon.h" @@ -43,5 +44,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 158789153..3a9e9d26b 100644 --- a/meta/SaiSerialize.cpp +++ b/meta/SaiSerialize.cpp @@ -2212,6 +2212,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) @@ -2360,6 +2406,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) { @@ -3989,6 +4059,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, @@ -4075,6 +4163,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 { \ @@ -4696,6 +4838,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( @@ -4958,6 +5121,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 7d53c11cc..a2ca39b10 100644 --- a/meta/sai_serialize.h +++ b/meta/sai_serialize.h @@ -253,6 +253,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( @@ -280,6 +283,10 @@ std::string sai_serialize_port_host_tx_ready_ntf( _In_ sai_object_id_t port_id, _In_ sai_port_host_tx_ready_status_t host_tx_ready_status); +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( @@ -485,6 +492,11 @@ void sai_deserialize_port_host_tx_ready_ntf( _Out_ sai_port_host_tx_ready_status_t& host_tx_ready_status); +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( @@ -517,6 +529,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 ff2aeae59..9e535aa20 100644 --- a/syncd/NotificationHandler.cpp +++ b/syncd/NotificationHandler.cpp @@ -120,6 +120,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); @@ -240,6 +244,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 9e093a47e..a7909b4df 100644 --- a/syncd/NotificationHandler.h +++ b/syncd/NotificationHandler.h @@ -69,6 +69,10 @@ namespace syncd _In_ uint32_t count, _In_ const sai_bfd_session_state_notification_t *data); + void onTwampSessionEvent( + _In_ uint32_t count, + _In_ const sai_twamp_session_event_notification_data_t *data); + private: void enqueueNotification( diff --git a/syncd/NotificationProcessor.cpp b/syncd/NotificationProcessor.cpp index ccdfdb02d..4fbd56750 100644 --- a/syncd/NotificationProcessor.cpp +++ b/syncd/NotificationProcessor.cpp @@ -535,7 +535,7 @@ void NotificationProcessor::process_on_bfd_session_state_change( { SWSS_LOG_ENTER(); - SWSS_LOG_DEBUG("bfd sessuin state notification count: %u", count); + SWSS_LOG_DEBUG("bfd session state notification count: %u", count); for (uint32_t i = 0; i < count; i++) { @@ -570,6 +570,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 session 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) { @@ -689,6 +719,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) { @@ -737,6 +782,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 1a6d86ef7..15d44daaa 100644 --- a/syncd/NotificationProcessor.h +++ b/syncd/NotificationProcessor.h @@ -100,6 +100,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( @@ -126,6 +130,9 @@ namespace syncd void handle_port_host_tx_ready_change( _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 bf2a9ba40..1c470a989 100644 --- a/syncd/SwitchNotifications.cpp +++ b/syncd/SwitchNotifications.cpp @@ -117,6 +117,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 f289936ed..a2a82c089 100644 --- a/syncd/SwitchNotifications.h +++ b/syncd/SwitchNotifications.h @@ -76,6 +76,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; @@ -103,7 +108,7 @@ namespace syncd .on_nat_event = &Slot::onNatEvent, .on_switch_asic_sdk_health_event = nullptr, .on_port_host_tx_ready = &Slot::onPortHostTxReady, - .on_twamp_session_event = nullptr, + .on_twamp_session_event = &Slot::onTwampSessionEvent, }) { } virtual ~Slot() {} @@ -181,6 +186,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; @@ -205,6 +219,7 @@ namespace syncd std::function onSwitchShutdownRequest; std::function onSwitchStateChange; std::function onBfdSessionStateChange; + std::function onTwampSessionEvent; private: diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index a54384e82..f24be0381 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -159,6 +159,7 @@ Syncd::Syncd( 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.onPortHostTxReady = std::bind(&NotificationHandler::onPortHostTxReady, m_handler.get(), _1, _2, _3); + m_sn.onTwampSessionEvent = std::bind(&NotificationHandler::onTwampSessionEvent, m_handler.get(), _1, _2); m_handler->setSwitchNotifications(m_sn.getSwitchNotifications()); diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index f7832828d..256c8ae9d 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -471,3 +471,4 @@ zmq ZMQ ZMQ uncreated +TWAMP