Skip to content
Merged
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
1 change: 1 addition & 0 deletions meta/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ libsaimeta_la_SOURCES = \
NotificationIcmpEchoSessionStateChange.cpp \
NotificationHaSetEvent.cpp \
NotificationHaScopeEvent.cpp \
NotificationFlowBulkGetSessionEvent.cpp \
NotificationTwampSessionEvent.cpp \
NotificationPortHostTxReadyEvent.cpp \
NotificationTamTelTypeConfigChange.cpp \
Expand Down
42 changes: 42 additions & 0 deletions meta/Meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7233,6 +7233,48 @@ void Meta::meta_sai_on_twamp_session_event(
}
}

void Meta::meta_sai_on_flow_bulk_get_session_event(
_In_ sai_object_id_t flow_bulk_session_id,
_In_ uint32_t count,
_In_ const sai_flow_bulk_get_session_event_data_t *data)
{
SWSS_LOG_ENTER();

if (count && data == NULL)
{
SWSS_LOG_ERROR("sai_flow_bulk_get_session_event_data_t pointer is NULL but count is %u", count);
return;
}

if (flow_bulk_session_id != SAI_NULL_OBJECT_ID)
{
auto ot = objectTypeQuery(flow_bulk_session_id);

if (ot != (sai_object_type_t)SAI_OBJECT_TYPE_FLOW_ENTRY_BULK_GET_SESSION)
{
SWSS_LOG_ERROR("flow_bulk_session_id %s has unexpected type: %s",
sai_serialize_object_id(flow_bulk_session_id).c_str(),
sai_serialize_object_type(ot).c_str());
return ;
}

if (!m_oids.objectReferenceExists(flow_bulk_session_id))
{
SWSS_LOG_NOTICE("flow_bulk_session_id new object spotted %s not present in local DB (snoop!)",
sai_serialize_object_id(flow_bulk_session_id).c_str());

sai_object_meta_key_t key = { .objecttype = ot, .objectkey = { .key = { .object_id = flow_bulk_session_id } } };

m_oids.objectReferenceInsert(flow_bulk_session_id);

if (!m_saiObjectCollection.objectExists(key))
{
m_saiObjectCollection.createObject(key);
}
}
}
}

void Meta::meta_sai_on_tam_tel_type_config_change(_In_ sai_object_id_t m_tam_id)
{
SWSS_LOG_ENTER();
Expand Down
5 changes: 5 additions & 0 deletions meta/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ namespace saimeta
_In_ uint32_t count,
_In_ const sai_twamp_session_event_notification_data_t *data);

void meta_sai_on_flow_bulk_get_session_event(
_In_ sai_object_id_t flow_bulk_session_id,
_In_ uint32_t count,
_In_ const sai_flow_bulk_get_session_event_data_t *data);

void meta_sai_on_tam_tel_type_config_change(_In_ sai_object_id_t m_tam_id);

private: // notifications helpers
Expand Down
4 changes: 4 additions & 0 deletions meta/NotificationFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "NotificationTamTelTypeConfigChange.h"
#include "NotificationHaSetEvent.h"
#include "NotificationHaScopeEvent.h"
#include "NotificationFlowBulkGetSessionEvent.h"
#include "NotificationSwitchMacsecPostStatus.h"
#include "NotificationMacsecPostStatus.h"
#include "sairediscommon.h"
Expand Down Expand Up @@ -63,6 +64,9 @@ std::shared_ptr<Notification> NotificationFactory::deserialize(
if (name == SAI_SWITCH_NOTIFICATION_NAME_HA_SCOPE_EVENT)
return std::make_shared<NotificationHaScopeEvent>(serializedNotification);

if (name == SAI_SWITCH_NOTIFICATION_NAME_FLOW_BULK_GET_SESSION_EVENT)
return std::make_shared<NotificationFlowBulkGetSessionEvent>(serializedNotification);

if (name == SAI_SWITCH_NOTIFICATION_NAME_TWAMP_SESSION_EVENT)
return std::make_shared<NotificationTwampSessionEvent>(serializedNotification);

Expand Down
80 changes: 80 additions & 0 deletions meta/NotificationFlowBulkGetSessionEvent.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include "NotificationFlowBulkGetSessionEvent.h"

#include "swss/logger.h"

#include "meta/sai_serialize.h"
#include "sairediscommon.h"

using namespace sairedis;

NotificationFlowBulkGetSessionEvent::NotificationFlowBulkGetSessionEvent(
_In_ const std::string& serializeNotification):
Notification(
SAI_SWITCH_NOTIFICATION_TYPE_FLOW_BULK_GET_SESSION_EVENT,
serializeNotification),
m_flow_bulk_session_id(SAI_NULL_OBJECT_ID),
m_count(0),
m_data(nullptr)
{
SWSS_LOG_ENTER();

sai_deserialize_flow_bulk_get_session_event_ntf(
serializeNotification,
m_flow_bulk_session_id,
m_count,
&m_data);
}

NotificationFlowBulkGetSessionEvent::~NotificationFlowBulkGetSessionEvent()
{
SWSS_LOG_ENTER();

sai_deserialize_free_flow_bulk_get_session_event_ntf(m_count, m_data);
}

sai_object_id_t NotificationFlowBulkGetSessionEvent::getSwitchId() const
{
SWSS_LOG_ENTER();

// Flow bulk get session event does not have switch id directly
// We can extract it from flow_bulk_session_id if needed
return SAI_NULL_OBJECT_ID;
}

sai_object_id_t NotificationFlowBulkGetSessionEvent::getAnyObjectId() const
{
SWSS_LOG_ENTER();

if (m_flow_bulk_session_id != SAI_NULL_OBJECT_ID)
{
return m_flow_bulk_session_id;
}

return SAI_NULL_OBJECT_ID;
}

void NotificationFlowBulkGetSessionEvent::processMetadata(
_In_ std::shared_ptr<saimeta::Meta> meta) const
{
SWSS_LOG_ENTER();

meta->meta_sai_on_flow_bulk_get_session_event(
m_flow_bulk_session_id,
m_count,
m_data);
}

void NotificationFlowBulkGetSessionEvent::executeCallback(
_In_ const sai_switch_notifications_t& switchNotifications) const
{
SWSS_LOG_ENTER();

if (switchNotifications.on_flow_bulk_get_session_event)
{
switchNotifications.on_flow_bulk_get_session_event(
m_flow_bulk_session_id,
m_count,
m_data);
}
}

38 changes: 38 additions & 0 deletions meta/NotificationFlowBulkGetSessionEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "Notification.h"

namespace sairedis
{
class NotificationFlowBulkGetSessionEvent:
public Notification
{
public:

NotificationFlowBulkGetSessionEvent(
_In_ const std::string& serializedNotification);

virtual ~NotificationFlowBulkGetSessionEvent();

public:

virtual sai_object_id_t getSwitchId() const override;

virtual sai_object_id_t getAnyObjectId() const override;

virtual void processMetadata(
_In_ std::shared_ptr<saimeta::Meta> meta) const override;

virtual void executeCallback(
_In_ const sai_switch_notifications_t& switchNotifications) const override;

private:

sai_object_id_t m_flow_bulk_session_id;

uint32_t m_count;

sai_flow_bulk_get_session_event_data_t* m_data;
};
}

105 changes: 105 additions & 0 deletions meta/SaiSerialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,14 @@ std::string sai_serialize_ha_scope_event(
return sai_serialize_enum(event, &sai_metadata_enum_sai_ha_scope_event_t);
}

std::string sai_serialize_flow_bulk_get_session_event(
_In_ sai_flow_bulk_get_session_event_t event)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(event, &sai_metadata_enum_sai_flow_bulk_get_session_event_t);
}

std::string sai_serialize_ha_role(
_In_ sai_dash_ha_role_t role)
{
Expand Down Expand Up @@ -2750,6 +2758,44 @@ std::string sai_serialize_ha_scope_event_ntf(
return j.dump();
}

std::string sai_serialize_flow_bulk_get_session_event_ntf(
_In_ sai_object_id_t flow_bulk_session_id,
_In_ uint32_t count,
_In_ const sai_flow_bulk_get_session_event_data_t* data)
{
SWSS_LOG_ENTER();

if (data == NULL)
{
SWSS_LOG_THROW("flow_bulk_get_session_event_data_t pointer is null");
}

/*
* NOTE: Only event_type is serialized here. The flow_entry, attr_count, and attr
* fields are NOT serialized as they are only populated for Flow Dump
* Due to performance reasons, they are not serialized and are not sent to orchagent.
*/

json j;

j["bulk_session_id"] = sai_serialize_object_id(flow_bulk_session_id);

json arr = json::array();

for (uint32_t i = 0; i < count; ++i)
{
json item;

item["event_type"] = sai_serialize_flow_bulk_get_session_event(data[i].event_type);

arr.push_back(item);
}

j["data"] = arr;

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)
Expand Down Expand Up @@ -4813,6 +4859,15 @@ void sai_deserialize_ha_scope_event(
sai_deserialize_enum(s, &sai_metadata_enum_sai_ha_scope_event_t, (int32_t&)event);
}

void sai_deserialize_flow_bulk_get_session_event(
_In_ const std::string& s,
_Out_ sai_flow_bulk_get_session_event_t& event)
{
SWSS_LOG_ENTER();

sai_deserialize_enum(s, &sai_metadata_enum_sai_flow_bulk_get_session_event_t, (int32_t&)event);
}

void sai_deserialize_ha_role(
_In_ const std::string& s,
_Out_ sai_dash_ha_role_t& role)
Expand Down Expand Up @@ -5846,6 +5901,42 @@ void sai_deserialize_ha_scope_event_ntf(
*ha_scope_event = data;
}

void sai_deserialize_flow_bulk_get_session_event_ntf(
_In_ const std::string& s,
_Out_ sai_object_id_t& flow_bulk_session_id,
_Out_ uint32_t& count,
_Out_ sai_flow_bulk_get_session_event_data_t** data)
{
SWSS_LOG_ENTER();

/*
* NOTE: Only event_type is deserialized here. The flow_entry, attr_count, and attr
* fields are set to default/null values as they are only populated for Flow Dump
* purposes and are not sent to SAIREDIS Client.
*/

json j = json::parse(s);

sai_deserialize_object_id(j["bulk_session_id"], flow_bulk_session_id);

json arr = j["data"];

count = (uint32_t)arr.size();

auto event_data = new sai_flow_bulk_get_session_event_data_t[count];

for (uint32_t i = 0; i < count; ++i)
{
sai_deserialize_flow_bulk_get_session_event(arr[i]["event_type"], event_data[i].event_type);

memset(&event_data[i].flow_entry, 0, sizeof(event_data[i].flow_entry));
event_data[i].attr_count = 0;
event_data[i].attr = nullptr;
}

*data = event_data;
}

void sai_deserialize_twamp_session_event_ntf(
_In_ const std::string& s,
_Out_ uint32_t &count,
Expand Down Expand Up @@ -6220,6 +6311,20 @@ void sai_deserialize_free_twamp_session_event_ntf(
delete[] twamp_session_event;
}

void sai_deserialize_free_flow_bulk_get_session_event_ntf(
_In_ uint32_t count,
_In_ sai_flow_bulk_get_session_event_data_t* data)
{
SWSS_LOG_ENTER();

if (data == nullptr)
{
return;
}

delete[] data;
}

void sai_deserialize_ingress_priority_group_attr(
_In_ const std::string& s,
_Out_ sai_ingress_priority_group_attr_t& attr)
Expand Down
15 changes: 15 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ std::string sai_serialize_ha_scope_event_ntf(
_In_ uint32_t count,
_In_ const sai_ha_scope_event_data_t* ha_scope_event);

std::string sai_serialize_flow_bulk_get_session_event_ntf(
_In_ sai_object_id_t flow_bulk_session_id,
_In_ uint32_t count,
_In_ const sai_flow_bulk_get_session_event_data_t* data);

std::string sai_serialize_port_host_tx_ready_ntf(
_In_ sai_object_id_t switch_id,
_In_ sai_object_id_t port_id,
Expand Down Expand Up @@ -649,6 +654,12 @@ void sai_deserialize_ha_scope_event_ntf(
_Out_ uint32_t &count,
_Out_ sai_ha_scope_event_data_t** ha_scope_event);

void sai_deserialize_flow_bulk_get_session_event_ntf(
_In_ const std::string& s,
_Out_ sai_object_id_t& flow_bulk_session_id,
_Out_ uint32_t& count,
_Out_ sai_flow_bulk_get_session_event_data_t** data);

void sai_deserialize_port_host_tx_ready_ntf(
_In_ const std::string& s,
_Out_ sai_object_id_t& switch_id,
Expand Down Expand Up @@ -712,6 +723,10 @@ 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_free_flow_bulk_get_session_event_ntf(
_In_ uint32_t count,
_In_ sai_flow_bulk_get_session_event_data_t* data);

void sai_deserialize_queue_attr(
_In_ const std::string& s,
_Out_ sai_queue_attr_t& attr);
Expand Down
Loading
Loading