diff --git a/.gitignore b/.gitignore index f2dceea04..8c8bd913d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.so *.pyc *_wrap.cpp +*.bak # Packaging Files # ################### @@ -111,6 +112,8 @@ unittest/meta/tests unittest/syncd/tests unittest/vslib/tests unittest/vslib/testslibsaivs +unittest/proxylib/tests +unittest/proxylib/testslibsaiproxy vslib/tests # Temporary files # diff --git a/Makefile.am b/Makefile.am index efea0003d..618545716 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = meta lib vslib pyext +SUBDIRS = meta lib vslib pyext proxylib if SYNCD SUBDIRS += syncd saiplayer saidump saidiscovery saisdkdump saiasiccmp tests unittest diff --git a/configure.ac b/configure.ac index 4c601e0fe..43fe79fab 100644 --- a/configure.ac +++ b/configure.ac @@ -290,11 +290,13 @@ AC_OUTPUT(Makefile saidiscovery/Makefile saiasiccmp/Makefile tests/Makefile + proxylib/Makefile unittest/Makefile unittest/meta/Makefile unittest/lib/Makefile unittest/vslib/Makefile unittest/syncd/Makefile + unittest/proxylib/Makefile pyext/Makefile pyext/py2/Makefile pyext/py3/Makefile) diff --git a/proxylib/Makefile.am b/proxylib/Makefile.am new file mode 100644 index 000000000..f0aecef41 --- /dev/null +++ b/proxylib/Makefile.am @@ -0,0 +1,83 @@ +AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/lib + +lib_LTLIBRARIES = libsaiproxy.la + +noinst_LIBRARIES = libSaiProxy.a + +libSaiProxy_a_SOURCES = \ + Sai.cpp + +libsaiproxy_la_SOURCES = \ + sai_proxy_acl.cpp \ + sai_proxy_bfd.cpp \ + sai_proxy_bmtor.cpp \ + sai_proxy_bridge.cpp \ + sai_proxy_buffer.cpp \ + sai_proxy_counter.cpp \ + sai_proxy_dash_vip.cpp \ + sai_proxy_dash_pa_validation.cpp \ + sai_proxy_dash_vnet.cpp \ + sai_proxy_dash_outbound_routing.cpp \ + sai_proxy_dash_outbound_ca_to_pa.cpp \ + sai_proxy_dash_inbound_routing.cpp \ + sai_proxy_dash_eni.cpp \ + sai_proxy_dash_direction_lookup.cpp \ + sai_proxy_dash_acl.cpp \ + sai_proxy_debug_counter.cpp \ + sai_proxy_dtel.cpp \ + sai_proxy_fdb.cpp \ + sai_proxy_genericprogrammable.cpp \ + sai_proxy_hash.cpp \ + sai_proxy_hostif.cpp \ + sai_proxy_interfacequery.cpp \ + sai_proxy_ipmc.cpp \ + sai_proxy_ipmc_group.cpp \ + sai_proxy_isolation_group.cpp \ + sai_proxy_l2mc.cpp \ + sai_proxy_l2mcgroup.cpp \ + sai_proxy_lag.cpp \ + sai_proxy_macsec.cpp \ + sai_proxy_mcastfdb.cpp \ + sai_proxy_mirror.cpp \ + sai_proxy_mpls.cpp \ + sai_proxy_nat.cpp \ + sai_proxy_neighbor.cpp \ + sai_proxy_nexthop.cpp \ + sai_proxy_nexthopgroup.cpp \ + sai_proxy_policer.cpp \ + sai_proxy_port.cpp \ + sai_proxy_qosmap.cpp \ + sai_proxy_queue.cpp \ + sai_proxy_route.cpp \ + sai_proxy_router_interface.cpp \ + sai_proxy_rpfgroup.cpp \ + sai_proxy_samplepacket.cpp \ + sai_proxy_scheduler.cpp \ + sai_proxy_schedulergroup.cpp \ + sai_proxy_srv6.cpp \ + sai_proxy_stp.cpp \ + sai_proxy_switch.cpp \ + sai_proxy_system_port.cpp \ + sai_proxy_tam.cpp \ + sai_proxy_tunnel.cpp \ + sai_proxy_udf.cpp \ + sai_proxy_virtual_router.cpp \ + sai_proxy_vlan.cpp \ + sai_proxy_wred.cpp \ + sai_proxy_ipsec.cpp \ + sai_proxy_my_mac.cpp \ + sai_proxy_ars.cpp \ + sai_proxy_ars_profile.cpp \ + sai_proxy_twamp.cpp \ + sai_proxy_poe.cpp \ + sai_proxy_dash_meter.cpp + +libSaiProxy_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) +libSaiProxy_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) + +libsaiproxy_la_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) +libsaiproxy_la_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) +libsaiproxy_la_LIBADD = -lhiredis -lswsscommon libSaiProxy.a $(CODE_COVERAGE_LIBS) + +# TODO - lib sai proxy server that will accept VendorSai + diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp new file mode 100644 index 000000000..a217769a3 --- /dev/null +++ b/proxylib/Sai.cpp @@ -0,0 +1,594 @@ +#include "Sai.h" +#include "SaiInternal.h" + +#include "meta/Meta.h" +#include "meta/sai_serialize.h" + +using namespace saiproxy; +using namespace std::placeholders; + +#define PROXY_CHECK_API_INITIALIZED() \ + if (!m_apiInitialized) { \ + SWSS_LOG_ERROR("%s: api not initialized", __PRETTY_FUNCTION__); \ + return SAI_STATUS_FAILURE; } + +#define PROXY_CHECK_POINTER(pointer) \ + if ((pointer) == nullptr) { \ + SWSS_LOG_ERROR("entry pointer " # pointer " is null"); \ + return SAI_STATUS_INVALID_PARAMETER; } + +Sai::Sai() +{ + SWSS_LOG_ENTER(); + + m_apiInitialized = false; +} + +Sai::~Sai() +{ + SWSS_LOG_ENTER(); + + if (m_apiInitialized) + { + uninitialize(); + } +} + +// INITIALIZE UNINITIALIZE + +sai_status_t Sai::initialize( + _In_ uint64_t flags, + _In_ const sai_service_method_table_t *service_method_table) +{ + MUTEX(); + SWSS_LOG_ENTER(); + + if (m_apiInitialized) + { + SWSS_LOG_ERROR("%s: api already initialized", __PRETTY_FUNCTION__); + + return SAI_STATUS_FAILURE; + } + + if (flags != 0) + { + SWSS_LOG_ERROR("invalid flags passed to SAI API initialize"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if ((service_method_table == NULL) || + (service_method_table->profile_get_next_value == NULL) || + (service_method_table->profile_get_value == NULL)) + { + SWSS_LOG_ERROR("invalid service_method_table handle passed to SAI API initialize"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + memcpy(&m_service_method_table, service_method_table, sizeof(m_service_method_table)); + + // TODO move to service method table and + // TODO enable for channel to work! +// m_communicationChannel = std::make_shared<_ZeroMQChannel>( +// "/tmp/saiproxy", +// "/tmp/saiproxy_ntf", +// std::bind(&Sai::handleNotification, this, _1, _2, _3)); + + m_apiInitialized = true; + + return SAI_STATUS_SUCCESS; +} + +sai_status_t Sai::uninitialize(void) +{ + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_NOTICE("begin"); + + m_apiInitialized = false; + + SWSS_LOG_NOTICE("end"); + + return SAI_STATUS_SUCCESS; +} + +// QUAD OID + +sai_status_t Sai::create( + _In_ sai_object_type_t objectType, + _Out_ sai_object_id_t* objectId, + _In_ sai_object_id_t switchId, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::remove( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::set( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId, + _In_ const sai_attribute_t *attr) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::get( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +// QUAD ENTRY + +#define DECLARE_CREATE_ENTRY(OT,ot) \ +sai_status_t Sai::create( \ + _In_ const sai_ ## ot ## _t* entry, \ + _In_ uint32_t attr_count, \ + _In_ const sai_attribute_t *attr_list) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entry) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_CREATE_ENTRY); + +#define DECLARE_REMOVE_ENTRY(OT,ot) \ +sai_status_t Sai::remove( \ + _In_ const sai_ ## ot ## _t* entry) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entry) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_REMOVE_ENTRY); + +#define DECLARE_SET_ENTRY(OT,ot) \ +sai_status_t Sai::set( \ + _In_ const sai_ ## ot ## _t* entry, \ + _In_ const sai_attribute_t *attr) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entry) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_SET_ENTRY); + +#define DECLARE_GET_ENTRY(OT,ot) \ +sai_status_t Sai::get( \ + _In_ const sai_ ## ot ## _t* entry, \ + _In_ uint32_t attr_count, \ + _Inout_ sai_attribute_t *attr_list) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entry) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_GET_ENTRY); + +// STATS + +sai_status_t Sai::getStats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _Out_ uint64_t *counters) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::queryStatsCapability( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t objectType, + _Inout_ sai_stat_capability_list_t *stats_capability) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::getStatsExt( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::clearStats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::bulkGetStats( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::bulkClearStats( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +// BULK QUAD OID + +sai_status_t Sai::bulkCreate( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t switch_id, + _In_ uint32_t object_count, + _In_ const uint32_t *attr_count, + _In_ const sai_attribute_t **attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_object_id_t *object_id, + _Out_ sai_status_t *object_statuses) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + PROXY_CHECK_POINTER(object_id); + PROXY_CHECK_POINTER(object_statuses); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::bulkRemove( + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_id_t *object_id, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + PROXY_CHECK_POINTER(object_id); + PROXY_CHECK_POINTER(object_statuses); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::bulkSet( + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_id_t *object_id, + _In_ const sai_attribute_t *attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + PROXY_CHECK_POINTER(object_statuses); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +// BULK QUAD ENTRY + +#define DECLARE_BULK_CREATE_ENTRY(OT,ot) \ +sai_status_t Sai::bulkCreate( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t* entries, \ + _In_ const uint32_t *attr_count, \ + _In_ const sai_attribute_t **attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entries) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_CREATE_ENTRY); + +// BULK REMOVE + +#define DECLARE_BULK_REMOVE_ENTRY(OT,ot) \ +sai_status_t Sai::bulkRemove( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *entries, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entries) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_REMOVE_ENTRY); + +// BULK SET + +#define DECLARE_BULK_SET_ENTRY(OT,ot) \ +sai_status_t Sai::bulkSet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *entries, \ + _In_ const sai_attribute_t *attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + PROXY_CHECK_API_INITIALIZED(); \ + PROXY_CHECK_POINTER(entries) \ + SWSS_LOG_ERROR("not implemented, FIXME"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); + +// NON QUAD API + +sai_status_t Sai::flushFdbEntries( + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +// SAI API + +sai_status_t Sai::objectTypeGetAvailability( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t objectType, + _In_ uint32_t attrCount, + _In_ const sai_attribute_t *attrList, + _Out_ uint64_t *count) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::queryAttributeCapability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Out_ sai_attr_capability_t *capability) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t Sai::queryAattributeEnumValuesCapability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Inout_ sai_s32_list_t *enum_values_capability) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_object_type_t Sai::objectTypeQuery( + _In_ sai_object_id_t objectId) +{ + MUTEX(); + SWSS_LOG_ENTER(); + + if (!m_apiInitialized) + { + SWSS_LOG_ERROR("%s: SAI API not initialized", __PRETTY_FUNCTION__); + + return SAI_OBJECT_TYPE_NULL; + } + + //json j; + + //j["switch_id"] = sai_serialize_object_id(switch_id); + + //return j.dump(); + + // TODO implement ! + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_OBJECT_TYPE_NULL; +} + +sai_object_id_t Sai::switchIdQuery( + _In_ sai_object_id_t objectId) +{ + MUTEX(); + SWSS_LOG_ENTER(); + + if (!m_apiInitialized) + { + SWSS_LOG_ERROR("%s: SAI API not initialized", __PRETTY_FUNCTION__); + + return SAI_NULL_OBJECT_ID; + } + + // TODO implement ! + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_NULL_OBJECT_ID; +} + +sai_status_t Sai::logSet( + _In_ sai_api_t api, + _In_ sai_log_level_t log_level) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_WARN("log set not implemented for %s:%s", + sai_serialize_api(api).c_str(), + sai_serialize_log_level(log_level).c_str()); + + return SAI_STATUS_SUCCESS; +} + +//sai_switch_notifications_t Sai::handle_notification( +// _In_ std::shared_ptr notification) +//{ +// MUTEX(); +// SWSS_LOG_ENTER(); +// +// if (!m_apiInitialized) +// { +// SWSS_LOG_ERROR("%s: api not initialized", __PRETTY_FUNCTION__); +// +// return { }; +// } +// +// return context->m_redisSai->syncProcessNotification(notification); +//} +// +//void Sai::handleNotification( +// _In_ const std::string &name, +// _In_ const std::string &serializedNotification, +// _In_ const std::vector &values) +//{ +// SWSS_LOG_ENTER(); +// +// auto notification = NotificationFactory::deserialize(name, serializedNotification); +// +// if (notification) +// { +// auto _sn = m_notificationCallback(notification); // will be synchronized to api mutex +// +// // execute callback from notification thread +// +// notification->executeCallback(_sn); +// } +//} diff --git a/proxylib/Sai.h b/proxylib/Sai.h new file mode 100644 index 000000000..b06df2f55 --- /dev/null +++ b/proxylib/Sai.h @@ -0,0 +1,194 @@ +#pragma once + +#include "lib/Channel.h" +#include "meta/Meta.h" +#include "meta/Notification.h" + +#include "swss/logger.h" + +#include +#include +#include +#include +#include + +namespace saiproxy +{ + class Sai: + public sairedis::SaiInterface + { + public: + + Sai(); + + virtual ~Sai(); + + public: + + sai_status_t initialize( + _In_ uint64_t flags, + _In_ const sai_service_method_table_t *service_method_table) override; + + sai_status_t uninitialize(void) override; + + public: // SAI interface overrides + + virtual sai_status_t create( + _In_ sai_object_type_t objectType, + _Out_ sai_object_id_t* objectId, + _In_ sai_object_id_t switchId, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) override; + + virtual sai_status_t remove( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId) override; + + virtual sai_status_t set( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId, + _In_ const sai_attribute_t *attr) override; + + virtual sai_status_t get( + _In_ sai_object_type_t objectType, + _In_ sai_object_id_t objectId, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list) override; + + public: // QUAD ENTRY and BULK QUAD ENTRY + + SAIREDIS_DECLARE_EVERY_ENTRY(SAIREDIS_SAIINTERFACE_DECLARE_QUAD_ENTRY_OVERRIDE); + SAIREDIS_DECLARE_EVERY_BULK_ENTRY(SAIREDIS_SAIINTERFACE_DECLARE_BULK_ENTRY_OVERRIDE); + + public: // bulk QUAD oid + + virtual sai_status_t bulkCreate( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t switch_id, + _In_ uint32_t object_count, + _In_ const uint32_t *attr_count, + _In_ const sai_attribute_t **attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_object_id_t *object_id, + _Out_ sai_status_t *object_statuses) override; + + virtual sai_status_t bulkRemove( + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_id_t *object_id, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses) override; + + virtual sai_status_t bulkSet( + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_id_t *object_id, + _In_ const sai_attribute_t *attr_list, + _In_ sai_bulk_op_error_mode_t mode, + _Out_ sai_status_t *object_statuses) override; + + public: // stats API + + virtual sai_status_t getStats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _Out_ uint64_t *counters) override; + + virtual sai_status_t queryStatsCapability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _Inout_ sai_stat_capability_list_t *stats_capability) override; + + virtual sai_status_t getStatsExt( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Out_ uint64_t *counters) override; + + virtual sai_status_t clearStats( + _In_ sai_object_type_t object_type, + _In_ sai_object_id_t object_id, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids) override; + + virtual sai_status_t bulkGetStats( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses, + _Out_ uint64_t *counters) override; + + virtual sai_status_t bulkClearStats( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses) override; + + public: // non QUAD API + + virtual sai_status_t flushFdbEntries( + _In_ sai_object_id_t switchId, + _In_ uint32_t attrCount, + _In_ const sai_attribute_t *attrList) override; + + public: // SAI API + + virtual sai_status_t objectTypeGetAvailability( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t objectType, + _In_ uint32_t attrCount, + _In_ const sai_attribute_t *attrList, + _Out_ uint64_t *count) override; + + virtual sai_status_t queryAttributeCapability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Out_ sai_attr_capability_t *capability) override; + + virtual sai_status_t queryAattributeEnumValuesCapability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Inout_ sai_s32_list_t *enum_values_capability) override; + + virtual sai_object_type_t objectTypeQuery( + _In_ sai_object_id_t objectId) override; + + virtual sai_object_id_t switchIdQuery( + _In_ sai_object_id_t objectId) override; + + virtual sai_status_t logSet( + _In_ sai_api_t api, + _In_ sai_log_level_t log_level) override; + + private: + + sai_switch_notifications_t handle_notification( + _In_ std::shared_ptr notification); + + private: + + bool m_apiInitialized; + + std::recursive_mutex m_apimutex; + + sai_service_method_table_t m_service_method_table; + + std::shared_ptr m_communicationChannel; + + std::function)> m_notificationCallback; + }; +} diff --git a/proxylib/SaiInternal.h b/proxylib/SaiInternal.h new file mode 100644 index 000000000..5ab4da121 --- /dev/null +++ b/proxylib/SaiInternal.h @@ -0,0 +1,4 @@ +#pragma once + +#define MUTEX() std::lock_guard _lock(m_apimutex) +#define MUTEX_UNLOCK() m_apimutex.unlock() diff --git a/proxylib/sai_proxy.h b/proxylib/sai_proxy.h new file mode 100644 index 000000000..e9810523e --- /dev/null +++ b/proxylib/sai_proxy.h @@ -0,0 +1,450 @@ +#pragma once + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "meta/SaiInterface.h" + +#include "swss/logger.h" + +#include + +#define PRIVATE __attribute__((visibility("hidden"))) + +PRIVATE extern const sai_acl_api_t proxy_acl_api; +PRIVATE extern const sai_ars_api_t proxy_ars_api; +PRIVATE extern const sai_ars_profile_api_t proxy_ars_profile_api; +PRIVATE extern const sai_bfd_api_t proxy_bfd_api; +PRIVATE extern const sai_bmtor_api_t proxy_bmtor_api; +PRIVATE extern const sai_generic_programmable_api_t proxy_generic_programmable_api; +PRIVATE extern const sai_bridge_api_t proxy_bridge_api; +PRIVATE extern const sai_buffer_api_t proxy_buffer_api; +PRIVATE extern const sai_counter_api_t proxy_counter_api; +PRIVATE extern const sai_dash_vip_api_t proxy_dash_vip_api; +PRIVATE extern const sai_dash_pa_validation_api_t proxy_dash_pa_validation_api; +PRIVATE extern const sai_dash_vnet_api_t proxy_dash_vnet_api; +PRIVATE extern const sai_dash_outbound_routing_api_t proxy_dash_outbound_routing_api; +PRIVATE extern const sai_dash_outbound_ca_to_pa_api_t proxy_dash_outbound_ca_to_pa_api; +PRIVATE extern const sai_dash_inbound_routing_api_t proxy_dash_inbound_routing_api; +PRIVATE extern const sai_dash_eni_api_t proxy_dash_eni_api; +PRIVATE extern const sai_dash_direction_lookup_api_t proxy_dash_direction_lookup_api; +PRIVATE extern const sai_dash_acl_api_t proxy_dash_acl_api; +PRIVATE extern const sai_debug_counter_api_t proxy_debug_counter_api; +PRIVATE extern const sai_dtel_api_t proxy_dtel_api; +PRIVATE extern const sai_fdb_api_t proxy_fdb_api; +PRIVATE extern const sai_hash_api_t proxy_hash_api; +PRIVATE extern const sai_hostif_api_t proxy_hostif_api; +PRIVATE extern const sai_ipmc_api_t proxy_ipmc_api; +PRIVATE extern const sai_ipmc_group_api_t proxy_ipmc_group_api; +PRIVATE extern const sai_isolation_group_api_t proxy_isolation_group_api; +PRIVATE extern const sai_l2mc_api_t proxy_l2mc_api; +PRIVATE extern const sai_l2mc_group_api_t proxy_l2mc_group_api; +PRIVATE extern const sai_lag_api_t proxy_lag_api; +PRIVATE extern const sai_macsec_api_t proxy_macsec_api; +PRIVATE extern const sai_mcast_fdb_api_t proxy_mcast_fdb_api; +PRIVATE extern const sai_mirror_api_t proxy_mirror_api; +PRIVATE extern const sai_mpls_api_t proxy_mpls_api; +PRIVATE extern const sai_nat_api_t proxy_nat_api; +PRIVATE extern const sai_neighbor_api_t proxy_neighbor_api; +PRIVATE extern const sai_next_hop_api_t proxy_next_hop_api; +PRIVATE extern const sai_next_hop_group_api_t proxy_next_hop_group_api; +PRIVATE extern const sai_policer_api_t proxy_policer_api; +PRIVATE extern const sai_port_api_t proxy_port_api; +PRIVATE extern const sai_qos_map_api_t proxy_qos_map_api; +PRIVATE extern const sai_queue_api_t proxy_queue_api; +PRIVATE extern const sai_route_api_t proxy_route_api; +PRIVATE extern const sai_router_interface_api_t proxy_router_interface_api; +PRIVATE extern const sai_rpf_group_api_t proxy_rpf_group_api; +PRIVATE extern const sai_samplepacket_api_t proxy_samplepacket_api; +PRIVATE extern const sai_scheduler_api_t proxy_scheduler_api; +PRIVATE extern const sai_scheduler_group_api_t proxy_scheduler_group_api; +PRIVATE extern const sai_srv6_api_t proxy_srv6_api; +PRIVATE extern const sai_stp_api_t proxy_stp_api; +PRIVATE extern const sai_switch_api_t proxy_switch_api; +PRIVATE extern const sai_system_port_api_t proxy_system_port_api; +PRIVATE extern const sai_tam_api_t proxy_tam_api; +PRIVATE extern const sai_tunnel_api_t proxy_tunnel_api; +PRIVATE extern const sai_udf_api_t proxy_udf_api; +PRIVATE extern const sai_virtual_router_api_t proxy_virtual_router_api; +PRIVATE extern const sai_vlan_api_t proxy_vlan_api; +PRIVATE extern const sai_wred_api_t proxy_wred_api; +PRIVATE extern const sai_my_mac_api_t proxy_my_mac_api; +PRIVATE extern const sai_ipsec_api_t proxy_ipsec_api; +PRIVATE extern const sai_twamp_api_t proxy_twamp_api; +PRIVATE extern const sai_dash_meter_api_t proxy_dash_meter_api; +PRIVATE extern const sai_poe_api_t proxy_poe_api; + +PRIVATE extern std::shared_ptr proxy_sai; + +// QUAD OID + +#define PROXY_CREATE(OT,ot) \ + static sai_status_t proxy_create_ ## ot( \ + _Out_ sai_object_id_t *object_id, \ + _In_ sai_object_id_t switch_id, \ + _In_ uint32_t attr_count, \ + _In_ const sai_attribute_t *attr_list) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->create( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + switch_id, \ + attr_count, \ + attr_list); \ +} + +#define PROXY_REMOVE(OT,ot) \ + static sai_status_t proxy_remove_ ## ot( \ + _In_ sai_object_id_t object_id) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->remove( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id); \ +} + +#define PROXY_SET(OT,ot) \ + static sai_status_t proxy_set_ ## ot ## _attribute( \ + _In_ sai_object_id_t object_id, \ + _In_ const sai_attribute_t *attr) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->set( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + attr); \ +} + +#define PROXY_GET(OT,ot) \ + static sai_status_t proxy_get_ ## ot ## _attribute( \ + _In_ sai_object_id_t object_id, \ + _In_ uint32_t attr_count, \ + _Inout_ sai_attribute_t *attr_list) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->get( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + attr_count, \ + attr_list); \ +} + +// QUAD DECLARE + +#define PROXY_GENERIC_QUAD(OT,ot) \ + PROXY_CREATE(OT,ot); \ + PROXY_REMOVE(OT,ot); \ + PROXY_SET(OT,ot); \ + PROXY_GET(OT,ot); + +// QUAD ENTRY + +#define PROXY_CREATE_ENTRY(OT,ot) \ + static sai_status_t proxy_create_ ## ot( \ + _In_ const sai_ ## ot ##_t *entry, \ + _In_ uint32_t attr_count, \ + _In_ const sai_attribute_t *attr_list) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->create( \ + entry, \ + attr_count, \ + attr_list); \ +} + +#define PROXY_REMOVE_ENTRY(OT,ot) \ + static sai_status_t proxy_remove_ ## ot( \ + _In_ const sai_ ## ot ## _t *entry) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->remove( \ + entry); \ +} + +#define PROXY_SET_ENTRY(OT,ot) \ + static sai_status_t proxy_set_ ## ot ## _attribute( \ + _In_ const sai_ ## ot ## _t *entry, \ + _In_ const sai_attribute_t *attr) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->set( \ + entry, \ + attr); \ +} + +#define PROXY_GET_ENTRY(OT,ot) \ + static sai_status_t proxy_get_ ## ot ## _attribute( \ + _In_ const sai_ ## ot ## _t *entry, \ + _In_ uint32_t attr_count, \ + _Inout_ sai_attribute_t *attr_list) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->get( \ + entry, \ + attr_count, \ + attr_list); \ +} + +// QUAD ENTRY DECLARE + +#define PROXY_GENERIC_QUAD_ENTRY(OT,ot) \ + PROXY_CREATE_ENTRY(OT,ot); \ + PROXY_REMOVE_ENTRY(OT,ot); \ + PROXY_SET_ENTRY(OT,ot); \ + PROXY_GET_ENTRY(OT,ot); + +// QUAD API + +#define PROXY_GENERIC_QUAD_API(ot) \ + proxy_create_ ## ot, \ + proxy_remove_ ## ot, \ + proxy_set_ ## ot ##_attribute, \ + proxy_get_ ## ot ##_attribute, + +// STATS + +#define PROXY_GET_STATS(OT,ot) \ + static sai_status_t proxy_get_ ## ot ## _stats( \ + _In_ sai_object_id_t object_id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_stat_id_t *counter_ids, \ + _Out_ uint64_t *counters) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->getStats( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + number_of_counters, \ + counter_ids, \ + counters); \ +} + +#define PROXY_GET_STATS_EXT(OT,ot) \ + static sai_status_t proxy_get_ ## ot ## _stats_ext( \ + _In_ sai_object_id_t object_id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_stat_id_t *counter_ids, \ + _In_ sai_stats_mode_t mode, \ + _Out_ uint64_t *counters) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->getStatsExt( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + number_of_counters, \ + counter_ids, \ + mode, \ + counters); \ +} + +#define PROXY_CLEAR_STATS(OT,ot) \ + static sai_status_t proxy_clear_ ## ot ## _stats( \ + _In_ sai_object_id_t object_id, \ + _In_ uint32_t number_of_counters, \ + _In_ const sai_stat_id_t *counter_ids) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->clearStats( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_id, \ + number_of_counters, \ + counter_ids); \ +} + +// STATS DECLARE + +#define PROXY_GENERIC_STATS(OT, ot) \ + PROXY_GET_STATS(OT,ot); \ + PROXY_GET_STATS_EXT(OT,ot); \ + PROXY_CLEAR_STATS(OT,ot); + +// STATS API + +#define PROXY_GENERIC_STATS_API(ot) \ + proxy_get_ ## ot ## _stats, \ + proxy_get_ ## ot ## _stats_ext, \ + proxy_clear_ ## ot ## _stats, + +// BULK QUAD + +#define PROXY_BULK_CREATE(OT,fname) \ + static sai_status_t proxy_bulk_create_ ## fname( \ + _In_ sai_object_id_t switch_id, \ + _In_ uint32_t object_count, \ + _In_ const uint32_t *attr_count, \ + _In_ const sai_attribute_t **attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_object_id_t *object_id, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkCreate( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + switch_id, \ + object_count, \ + attr_count, \ + attr_list, \ + mode, \ + object_id, \ + object_statuses); \ +} + +#define PROXY_BULK_REMOVE(OT,fname) \ + static sai_status_t proxy_bulk_remove_ ## fname( \ + _In_ uint32_t object_count, \ + _In_ const sai_object_id_t *object_id, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkRemove( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_count, \ + object_id, \ + mode, \ + object_statuses); \ +} + +#define PROXY_BULK_SET(OT,fname) \ + static sai_status_t proxy_bulk_set_ ## fname( \ + _In_ uint32_t object_count, \ + _In_ const sai_object_id_t *object_id, \ + _In_ const sai_attribute_t *attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkSet( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + object_count, \ + object_id, \ + attr_list, \ + mode, \ + object_statuses); \ +} + +#define PROXY_BULK_GET(OT,fname) \ + static sai_status_t proxy_bulk_get_ ## fname( \ + _In_ uint32_t object_count, \ + _In_ const sai_object_id_t *object_id, \ + _In_ const uint32_t *attr_count, \ + _Inout_ sai_attribute_t **attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + SWSS_LOG_ERROR("not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +// BULK QUAD DECLARE + +#define PROXY_BULK_QUAD(OT,ot) \ + PROXY_BULK_CREATE(OT,ot); \ + PROXY_BULK_REMOVE(OT,ot); \ + PROXY_BULK_SET(OT,ot); \ + PROXY_BULK_GET(OT,ot); + +// BULK QUAD ENTRY + +#define PROXY_BULK_CREATE_ENTRY(OT,ot) \ + PROXY_BULK_CREATE_ENTRY_EX(OT, ot, ot) + +#define PROXY_BULK_CREATE_ENTRY_EX(OT,ot,fname) \ + static sai_status_t proxy_bulk_create_ ## fname(\ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *entry, \ + _In_ const uint32_t *attr_count, \ + _In_ const sai_attribute_t **attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkCreate( \ + object_count, \ + entry, \ + attr_count, \ + attr_list, \ + mode, \ + object_statuses); \ +} + +#define PROXY_BULK_REMOVE_ENTRY(OT,ot) \ + PROXY_BULK_REMOVE_ENTRY_EX(OT, ot, ot) + +#define PROXY_BULK_REMOVE_ENTRY_EX(OT,ot,fname) \ + static sai_status_t proxy_bulk_remove_ ## fname(\ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ##_t *entry, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkRemove( \ + object_count, \ + entry, \ + mode, \ + object_statuses); \ +} + +#define PROXY_BULK_SET_ENTRY(OT,ot) \ + static sai_status_t proxy_bulk_set_ ## ot( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *entry, \ + _In_ const sai_attribute_t *attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + return proxy_sai->bulkSet( \ + object_count, \ + entry, \ + attr_list, \ + mode, \ + object_statuses); \ +} + +#define PROXY_BULK_GET_ENTRY(OT,ot) \ + static sai_status_t proxy_bulk_get_ ## ot( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *entry, \ + _In_ const uint32_t *attr_count, \ + _Inout_ sai_attribute_t **attr_list, \ + _In_ sai_bulk_op_error_mode_t mode, \ + _Out_ sai_status_t *object_statuses) \ +{ \ + SWSS_LOG_ENTER(); \ + SWSS_LOG_ERROR("not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +// BULK QUAD ENTRY DECLARE + +#define PROXY_BULK_QUAD_ENTRY(OT,ot) \ + PROXY_BULK_CREATE_ENTRY(OT,ot); \ + PROXY_BULK_REMOVE_ENTRY(OT,ot); \ + PROXY_BULK_SET_ENTRY(OT,ot); \ + PROXY_BULK_GET_ENTRY(OT,ot); + +// BULK QUAD API + +#define PROXY_BULK_QUAD_API(ot) \ + proxy_bulk_create_ ## ot, \ + proxy_bulk_remove_ ## ot, \ + proxy_bulk_set_ ## ot, \ + proxy_bulk_get_ ## ot, + +// BULK get/set DECLARE + +#define PROXY_BULK_GET_SET(OT,ot) \ + PROXY_BULK_GET(OT,ot); \ + PROXY_BULK_SET(OT,ot); + +// BULK get/set API + +#define PROXY_BULK_GET_SET_API(ot) \ + proxy_bulk_get_ ## ot, \ + proxy_bulk_set_ ## ot, diff --git a/proxylib/sai_proxy_acl.cpp b/proxylib/sai_proxy_acl.cpp new file mode 100644 index 000000000..c5f653077 --- /dev/null +++ b/proxylib/sai_proxy_acl.cpp @@ -0,0 +1,20 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(ACL_TABLE,acl_table); +PROXY_GENERIC_QUAD(ACL_ENTRY,acl_entry); +PROXY_GENERIC_QUAD(ACL_COUNTER,acl_counter); +PROXY_GENERIC_QUAD(ACL_RANGE,acl_range); +PROXY_GENERIC_QUAD(ACL_TABLE_GROUP,acl_table_group); +PROXY_GENERIC_QUAD(ACL_TABLE_GROUP_MEMBER,acl_table_group_member); +PROXY_GENERIC_QUAD(ACL_TABLE_CHAIN_GROUP,acl_table_chain_group) + +const sai_acl_api_t proxy_acl_api = { + + PROXY_GENERIC_QUAD_API(acl_table) + PROXY_GENERIC_QUAD_API(acl_entry) + PROXY_GENERIC_QUAD_API(acl_counter) + PROXY_GENERIC_QUAD_API(acl_range) + PROXY_GENERIC_QUAD_API(acl_table_group) + PROXY_GENERIC_QUAD_API(acl_table_group_member) + PROXY_GENERIC_QUAD_API(acl_table_chain_group) +}; diff --git a/proxylib/sai_proxy_ars.cpp b/proxylib/sai_proxy_ars.cpp new file mode 100644 index 000000000..34f49a48d --- /dev/null +++ b/proxylib/sai_proxy_ars.cpp @@ -0,0 +1,7 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(ARS, ars); + +const sai_ars_api_t proxy_ars_api = { + PROXY_GENERIC_QUAD_API(ars) +}; diff --git a/proxylib/sai_proxy_ars_profile.cpp b/proxylib/sai_proxy_ars_profile.cpp new file mode 100644 index 000000000..e707130c5 --- /dev/null +++ b/proxylib/sai_proxy_ars_profile.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + + +PROXY_GENERIC_QUAD(ARS_PROFILE, ars_profile); + +const sai_ars_profile_api_t proxy_ars_profile_api = { + PROXY_GENERIC_QUAD_API(ars_profile) +}; diff --git a/proxylib/sai_proxy_bfd.cpp b/proxylib/sai_proxy_bfd.cpp new file mode 100644 index 000000000..1d364e1bb --- /dev/null +++ b/proxylib/sai_proxy_bfd.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(BFD_SESSION,bfd_session); +PROXY_GENERIC_STATS(BFD_SESSION,bfd_session); + +const sai_bfd_api_t proxy_bfd_api = { + + PROXY_GENERIC_QUAD_API(bfd_session) + PROXY_GENERIC_STATS_API(bfd_session) +}; diff --git a/proxylib/sai_proxy_bmtor.cpp b/proxylib/sai_proxy_bmtor.cpp new file mode 100644 index 000000000..87ab996b2 --- /dev/null +++ b/proxylib/sai_proxy_bmtor.cpp @@ -0,0 +1,18 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); +PROXY_GENERIC_STATS(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); +PROXY_GENERIC_QUAD(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); +PROXY_GENERIC_STATS(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); +PROXY_GENERIC_QUAD(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); +PROXY_GENERIC_STATS(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); + +const sai_bmtor_api_t proxy_bmtor_api = { + + PROXY_GENERIC_QUAD_API(table_bitmap_classification_entry) + PROXY_GENERIC_STATS_API(table_bitmap_classification_entry) + PROXY_GENERIC_QUAD_API(table_bitmap_router_entry) + PROXY_GENERIC_STATS_API(table_bitmap_router_entry) + PROXY_GENERIC_QUAD_API(table_meta_tunnel_entry) + PROXY_GENERIC_STATS_API(table_meta_tunnel_entry) +}; diff --git a/proxylib/sai_proxy_bridge.cpp b/proxylib/sai_proxy_bridge.cpp new file mode 100644 index 000000000..6fd48a789 --- /dev/null +++ b/proxylib/sai_proxy_bridge.cpp @@ -0,0 +1,14 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(BRIDGE,bridge); +PROXY_GENERIC_QUAD(BRIDGE_PORT,bridge_port); +PROXY_GENERIC_STATS(BRIDGE,bridge); +PROXY_GENERIC_STATS(BRIDGE_PORT,bridge_port); + +const sai_bridge_api_t proxy_bridge_api = { + + PROXY_GENERIC_QUAD_API(bridge) + PROXY_GENERIC_STATS_API(bridge) + PROXY_GENERIC_QUAD_API(bridge_port) + PROXY_GENERIC_STATS_API(bridge_port) +}; diff --git a/proxylib/sai_proxy_buffer.cpp b/proxylib/sai_proxy_buffer.cpp new file mode 100644 index 000000000..593e42532 --- /dev/null +++ b/proxylib/sai_proxy_buffer.cpp @@ -0,0 +1,16 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(BUFFER_POOL,buffer_pool); +PROXY_GENERIC_QUAD(INGRESS_PRIORITY_GROUP,ingress_priority_group); +PROXY_GENERIC_QUAD(BUFFER_PROFILE,buffer_profile); +PROXY_GENERIC_STATS(BUFFER_POOL,buffer_pool); +PROXY_GENERIC_STATS(INGRESS_PRIORITY_GROUP,ingress_priority_group); + +const sai_buffer_api_t proxy_buffer_api = { + + PROXY_GENERIC_QUAD_API(buffer_pool) + PROXY_GENERIC_STATS_API(buffer_pool) + PROXY_GENERIC_QUAD_API(ingress_priority_group) + PROXY_GENERIC_STATS_API(ingress_priority_group) + PROXY_GENERIC_QUAD_API(buffer_profile) +}; diff --git a/proxylib/sai_proxy_counter.cpp b/proxylib/sai_proxy_counter.cpp new file mode 100644 index 000000000..8a300b55c --- /dev/null +++ b/proxylib/sai_proxy_counter.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(COUNTER,counter); +PROXY_GENERIC_STATS(COUNTER,counter); + +const sai_counter_api_t proxy_counter_api = { + + PROXY_GENERIC_QUAD_API(counter) + PROXY_GENERIC_STATS_API(counter) +}; diff --git a/proxylib/sai_proxy_dash_acl.cpp b/proxylib/sai_proxy_dash_acl.cpp new file mode 100644 index 000000000..465480695 --- /dev/null +++ b/proxylib/sai_proxy_dash_acl.cpp @@ -0,0 +1,19 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(DASH_ACL_GROUP, dash_acl_group); +PROXY_BULK_CREATE(DASH_ACL_GROUP, dash_acl_groups); +PROXY_BULK_REMOVE(DASH_ACL_GROUP, dash_acl_groups); + +PROXY_GENERIC_QUAD(DASH_ACL_RULE, dash_acl_rule); +PROXY_BULK_CREATE(DASH_ACL_RULE, dash_acl_rules); +PROXY_BULK_REMOVE(DASH_ACL_RULE, dash_acl_rules); + +const sai_dash_acl_api_t proxy_dash_acl_api = { + PROXY_GENERIC_QUAD_API(dash_acl_group) + proxy_bulk_create_dash_acl_groups, + proxy_bulk_remove_dash_acl_groups, + + PROXY_GENERIC_QUAD_API(dash_acl_rule) + proxy_bulk_create_dash_acl_rules, + proxy_bulk_remove_dash_acl_rules, +}; diff --git a/proxylib/sai_proxy_dash_direction_lookup.cpp b/proxylib/sai_proxy_dash_direction_lookup.cpp new file mode 100644 index 000000000..cb3a62c92 --- /dev/null +++ b/proxylib/sai_proxy_dash_direction_lookup.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry); +PROXY_BULK_CREATE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); +PROXY_BULK_REMOVE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); + +const sai_dash_direction_lookup_api_t proxy_dash_direction_lookup_api = { + PROXY_GENERIC_QUAD_API(direction_lookup_entry) + proxy_bulk_create_direction_lookup_entries, + proxy_bulk_remove_direction_lookup_entries, +}; diff --git a/proxylib/sai_proxy_dash_eni.cpp b/proxylib/sai_proxy_dash_eni.cpp new file mode 100644 index 000000000..d6fe985d4 --- /dev/null +++ b/proxylib/sai_proxy_dash_eni.cpp @@ -0,0 +1,21 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry); +PROXY_BULK_CREATE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); +PROXY_BULK_REMOVE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); + +PROXY_GENERIC_QUAD(ENI, eni); +PROXY_GENERIC_STATS(ENI, eni); +PROXY_BULK_CREATE(ENI, enis); +PROXY_BULK_REMOVE(ENI, enis); + +const sai_dash_eni_api_t proxy_dash_eni_api = { + PROXY_GENERIC_QUAD_API(eni_ether_address_map_entry) + proxy_bulk_create_eni_ether_address_map_entries, + proxy_bulk_remove_eni_ether_address_map_entries, + + PROXY_GENERIC_QUAD_API(eni) + PROXY_GENERIC_STATS_API(eni) + proxy_bulk_create_enis, + proxy_bulk_remove_enis, +}; diff --git a/proxylib/sai_proxy_dash_inbound_routing.cpp b/proxylib/sai_proxy_dash_inbound_routing.cpp new file mode 100644 index 000000000..23267623e --- /dev/null +++ b/proxylib/sai_proxy_dash_inbound_routing.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(INBOUND_ROUTING_ENTRY, inbound_routing_entry); +PROXY_BULK_CREATE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); +PROXY_BULK_REMOVE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); + +const sai_dash_inbound_routing_api_t proxy_dash_inbound_routing_api = { + PROXY_GENERIC_QUAD_API(inbound_routing_entry) + proxy_bulk_create_inbound_routing_entries, + proxy_bulk_remove_inbound_routing_entries, +}; diff --git a/proxylib/sai_proxy_dash_meter.cpp b/proxylib/sai_proxy_dash_meter.cpp new file mode 100644 index 000000000..4a5da148c --- /dev/null +++ b/proxylib/sai_proxy_dash_meter.cpp @@ -0,0 +1,28 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(METER_BUCKET, meter_bucket); +PROXY_BULK_CREATE(METER_BUCKET, meter_buckets); +PROXY_BULK_REMOVE(METER_BUCKET, meter_buckets); + +PROXY_GENERIC_QUAD(METER_BUCKET, meter_policy); +PROXY_BULK_CREATE(METER_BUCKET, meter_policys); +PROXY_BULK_REMOVE(METER_BUCKET, meter_policys); + +PROXY_GENERIC_QUAD(METER_BUCKET, meter_rule); +PROXY_BULK_CREATE(METER_BUCKET, meter_rules); +PROXY_BULK_REMOVE(METER_BUCKET, meter_rules); + +const sai_dash_meter_api_t proxy_dash_meter_api = { + + PROXY_GENERIC_QUAD_API(meter_bucket) + proxy_bulk_create_meter_buckets, + proxy_bulk_remove_meter_buckets, + + PROXY_GENERIC_QUAD_API(meter_policy) + proxy_bulk_create_meter_policys, + proxy_bulk_remove_meter_policys, + + PROXY_GENERIC_QUAD_API(meter_rule) + proxy_bulk_create_meter_rules, + proxy_bulk_remove_meter_rules, +}; diff --git a/proxylib/sai_proxy_dash_outbound_ca_to_pa.cpp b/proxylib/sai_proxy_dash_outbound_ca_to_pa.cpp new file mode 100644 index 000000000..8a6d686d6 --- /dev/null +++ b/proxylib/sai_proxy_dash_outbound_ca_to_pa.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry); +PROXY_BULK_CREATE_ENTRY_EX(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry, outbound_ca_to_pa_entries); +PROXY_BULK_REMOVE_ENTRY_EX(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry, outbound_ca_to_pa_entries); + +const sai_dash_outbound_ca_to_pa_api_t proxy_dash_outbound_ca_to_pa_api = { + PROXY_GENERIC_QUAD_API(outbound_ca_to_pa_entry) + proxy_bulk_create_outbound_ca_to_pa_entries, + proxy_bulk_remove_outbound_ca_to_pa_entries, +}; diff --git a/proxylib/sai_proxy_dash_outbound_routing.cpp b/proxylib/sai_proxy_dash_outbound_routing.cpp new file mode 100644 index 000000000..fb7c1b93e --- /dev/null +++ b/proxylib/sai_proxy_dash_outbound_routing.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry); +PROXY_BULK_CREATE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); +PROXY_BULK_REMOVE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); + +const sai_dash_outbound_routing_api_t proxy_dash_outbound_routing_api = { + PROXY_GENERIC_QUAD_API(outbound_routing_entry) + proxy_bulk_create_outbound_routing_entries, + proxy_bulk_remove_outbound_routing_entries, +}; diff --git a/proxylib/sai_proxy_dash_pa_validation.cpp b/proxylib/sai_proxy_dash_pa_validation.cpp new file mode 100644 index 000000000..6a2223172 --- /dev/null +++ b/proxylib/sai_proxy_dash_pa_validation.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(PA_VALIDATION_ENTRY, pa_validation_entry); +PROXY_BULK_CREATE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); +PROXY_BULK_REMOVE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); + +const sai_dash_pa_validation_api_t proxy_dash_pa_validation_api = { + PROXY_GENERIC_QUAD_API(pa_validation_entry) + proxy_bulk_create_pa_validation_entries, + proxy_bulk_remove_pa_validation_entries, +}; diff --git a/proxylib/sai_proxy_dash_vip.cpp b/proxylib/sai_proxy_dash_vip.cpp new file mode 100644 index 000000000..e275a09e6 --- /dev/null +++ b/proxylib/sai_proxy_dash_vip.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(VIP_ENTRY, vip_entry); +PROXY_BULK_CREATE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); +PROXY_BULK_REMOVE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); + +const sai_dash_vip_api_t proxy_dash_vip_api = { + PROXY_GENERIC_QUAD_API(vip_entry) + proxy_bulk_create_vip_entries, + proxy_bulk_remove_vip_entries, +}; diff --git a/proxylib/sai_proxy_dash_vnet.cpp b/proxylib/sai_proxy_dash_vnet.cpp new file mode 100644 index 000000000..3e1e5a002 --- /dev/null +++ b/proxylib/sai_proxy_dash_vnet.cpp @@ -0,0 +1,11 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(VNET, vnet); +PROXY_BULK_CREATE(VNET, vnets); +PROXY_BULK_REMOVE(VNET, vnets); + +const sai_dash_vnet_api_t proxy_dash_vnet_api = { + PROXY_GENERIC_QUAD_API(vnet) + proxy_bulk_create_vnets, + proxy_bulk_remove_vnets, +}; diff --git a/proxylib/sai_proxy_debug_counter.cpp b/proxylib/sai_proxy_debug_counter.cpp new file mode 100644 index 000000000..099826d75 --- /dev/null +++ b/proxylib/sai_proxy_debug_counter.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(DEBUG_COUNTER,debug_counter); + +const sai_debug_counter_api_t proxy_debug_counter_api = { + + PROXY_GENERIC_QUAD_API(debug_counter) +}; diff --git a/proxylib/sai_proxy_dtel.cpp b/proxylib/sai_proxy_dtel.cpp new file mode 100644 index 000000000..eb27db418 --- /dev/null +++ b/proxylib/sai_proxy_dtel.cpp @@ -0,0 +1,16 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(DTEL,dtel); +PROXY_GENERIC_QUAD(DTEL_QUEUE_REPORT,dtel_queue_report); +PROXY_GENERIC_QUAD(DTEL_INT_SESSION,dtel_int_session); +PROXY_GENERIC_QUAD(DTEL_REPORT_SESSION,dtel_report_session); +PROXY_GENERIC_QUAD(DTEL_EVENT,dtel_event); + +const sai_dtel_api_t proxy_dtel_api = { + + PROXY_GENERIC_QUAD_API(dtel) + PROXY_GENERIC_QUAD_API(dtel_queue_report) + PROXY_GENERIC_QUAD_API(dtel_int_session) + PROXY_GENERIC_QUAD_API(dtel_report_session) + PROXY_GENERIC_QUAD_API(dtel_event) +}; diff --git a/proxylib/sai_proxy_fdb.cpp b/proxylib/sai_proxy_fdb.cpp new file mode 100644 index 000000000..c4fd20049 --- /dev/null +++ b/proxylib/sai_proxy_fdb.cpp @@ -0,0 +1,26 @@ +#include "sai_proxy.h" + +static sai_status_t proxy_flush_fdb_entries( + _In_ sai_object_id_t switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->flushFdbEntries( + switch_id, + attr_count, + attr_list); +} + +PROXY_GENERIC_QUAD_ENTRY(FDB_ENTRY,fdb_entry); +PROXY_BULK_QUAD_ENTRY(FDB_ENTRY,fdb_entry); + +const sai_fdb_api_t proxy_fdb_api = { + + PROXY_GENERIC_QUAD_API(fdb_entry) + + proxy_flush_fdb_entries, + + PROXY_BULK_QUAD_API(fdb_entry) +}; diff --git a/proxylib/sai_proxy_genericprogrammable.cpp b/proxylib/sai_proxy_genericprogrammable.cpp new file mode 100644 index 000000000..41cad506b --- /dev/null +++ b/proxylib/sai_proxy_genericprogrammable.cpp @@ -0,0 +1,7 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(GENERIC_PROGRAMMABLE,generic_programmable); + +const sai_generic_programmable_api_t proxy_generic_programmable_api = { + PROXY_GENERIC_QUAD_API(generic_programmable) +}; diff --git a/proxylib/sai_proxy_hash.cpp b/proxylib/sai_proxy_hash.cpp new file mode 100644 index 000000000..d25b5bd32 --- /dev/null +++ b/proxylib/sai_proxy_hash.cpp @@ -0,0 +1,9 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(HASH,hash); +PROXY_GENERIC_QUAD(FINE_GRAINED_HASH_FIELD,fine_grained_hash_field); + +const sai_hash_api_t proxy_hash_api = { + PROXY_GENERIC_QUAD_API(hash) + PROXY_GENERIC_QUAD_API(fine_grained_hash_field) +}; diff --git a/proxylib/sai_proxy_hostif.cpp b/proxylib/sai_proxy_hostif.cpp new file mode 100644 index 000000000..c41ba5be0 --- /dev/null +++ b/proxylib/sai_proxy_hostif.cpp @@ -0,0 +1,66 @@ +#include "sai_proxy.h" + +static sai_status_t proxy_recv_hostif_packet( + _In_ sai_object_id_t hostif_id, + _Inout_ sai_size_t *buffer_size, + _Out_ void *buffer, + _Inout_ uint32_t *attr_count, + _Out_ sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_send_hostif_packet( + _In_ sai_object_id_t hostif_id, + _In_ sai_size_t buffer_size, + _In_ const void *buffer, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_allocate_hostif_packet( + _In_ sai_object_id_t hostif_id, + _In_ sai_size_t buffer_size, + _Out_ void **buffer, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_free_hostif_packet( + _In_ sai_object_id_t hostif_id, + _Inout_ void *buffer) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +PROXY_GENERIC_QUAD(HOSTIF,hostif); +PROXY_GENERIC_QUAD(HOSTIF_TABLE_ENTRY,hostif_table_entry); +PROXY_GENERIC_QUAD(HOSTIF_TRAP_GROUP,hostif_trap_group); +PROXY_GENERIC_QUAD(HOSTIF_TRAP,hostif_trap); +PROXY_GENERIC_QUAD(HOSTIF_USER_DEFINED_TRAP,hostif_user_defined_trap); + +const sai_hostif_api_t proxy_hostif_api = { + + PROXY_GENERIC_QUAD_API(hostif) + PROXY_GENERIC_QUAD_API(hostif_table_entry) + PROXY_GENERIC_QUAD_API(hostif_trap_group) + PROXY_GENERIC_QUAD_API(hostif_trap) + PROXY_GENERIC_QUAD_API(hostif_user_defined_trap) + + proxy_recv_hostif_packet, + proxy_send_hostif_packet, + proxy_allocate_hostif_packet, + proxy_free_hostif_packet, +}; diff --git a/proxylib/sai_proxy_interfacequery.cpp b/proxylib/sai_proxy_interfacequery.cpp new file mode 100644 index 000000000..6a8d451d4 --- /dev/null +++ b/proxylib/sai_proxy_interfacequery.cpp @@ -0,0 +1,323 @@ +#include "sai_proxy.h" + +#include "Sai.h" + +using namespace saiproxy; + +std::shared_ptr proxy_sai = std::make_shared(); + +sai_status_t sai_api_initialize( + _In_ uint64_t flags, + _In_ const sai_service_method_table_t* service_method_table) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->initialize(flags, service_method_table); +} + +sai_status_t sai_api_uninitialize(void) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->uninitialize(); +} + +sai_status_t sai_log_set( + _In_ sai_api_t sai_api_id, + _In_ sai_log_level_t log_level) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +#define API(api) .api ## _api = const_cast(&proxy_ ## api ## _api) + +static sai_apis_t proxy_apis = { + API(switch), + API(port), + API(fdb), + API(vlan), + API(virtual_router), + API(route), + API(next_hop), + API(next_hop_group), + API(router_interface), + API(neighbor), + API(acl), + API(hostif), + API(mirror), + API(samplepacket), + API(stp), + API(lag), + API(policer), + API(wred), + API(qos_map), + API(queue), + API(scheduler), + API(scheduler_group), + API(buffer), + API(hash), + API(udf), + API(tunnel), + API(l2mc), + API(ipmc), + API(rpf_group), + API(l2mc_group), + API(ipmc_group), + API(mcast_fdb), + API(bridge), + API(tam), + API(srv6), + API(mpls), + API(dtel), + API(bfd), + API(isolation_group), + API(nat), + API(counter), + API(debug_counter), + API(macsec), + API(system_port), + API(my_mac), + API(ipsec), + API(generic_programmable), + API(ars), + API(ars_profile), + API(twamp), + API(poe), + API(bmtor), + API(dash_acl), + API(dash_direction_lookup), + API(dash_eni), + API(dash_inbound_routing), + API(dash_meter), + API(dash_outbound_ca_to_pa), + API(dash_outbound_routing), + API(dash_vnet), + API(dash_pa_validation), + API(dash_vip), +}; + +static_assert((sizeof(sai_apis_t)/sizeof(void*)) == (SAI_API_EXTENSIONS_MAX - 1)); + +sai_status_t sai_api_query( + _In_ sai_api_t sai_api_id, + _Out_ void** api_method_table) +{ + SWSS_LOG_ENTER(); + + if (api_method_table == NULL) + { + SWSS_LOG_ERROR("NULL method table passed to SAI API initialize"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if (sai_api_id == SAI_API_UNSPECIFIED) + { + SWSS_LOG_ERROR("api ID is unspecified api"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + if (sai_metadata_get_enum_value_name(&sai_metadata_enum_sai_api_t, sai_api_id)) + { + *api_method_table = ((void**)&proxy_apis)[sai_api_id - 1]; + return SAI_STATUS_SUCCESS; + } + + SWSS_LOG_ERROR("Invalid API type %d", sai_api_id); + + return SAI_STATUS_INVALID_PARAMETER; +} + +sai_status_t sai_query_attribute_capability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Out_ sai_attr_capability_t *capability) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->queryAttributeCapability( + switch_id, + object_type, + attr_id, + capability); +} + +sai_status_t sai_query_attribute_enum_values_capability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ sai_attr_id_t attr_id, + _Inout_ sai_s32_list_t *enum_values_capability) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->queryAattributeEnumValuesCapability( + switch_id, + object_type, + attr_id, + enum_values_capability); +} + +sai_status_t sai_object_type_get_availability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list, + _Out_ uint64_t *count) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->objectTypeGetAvailability( + switch_id, + object_type, + attr_count, + attr_list, + count); +} + +sai_object_type_t sai_object_type_query( + _In_ sai_object_id_t objectId) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->objectTypeQuery(objectId); +} + +sai_object_id_t sai_switch_id_query( + _In_ sai_object_id_t objectId) +{ + SWSS_LOG_ENTER(); + + return proxy_sai->switchIdQuery(objectId); +} + +sai_status_t sai_dbg_generate_dump( + _In_ const char *dump_file_name) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_bulk_get_attribute( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _Inout_ uint32_t *attr_count, + _Inout_ sai_attribute_t **attr_list, + _Inout_ sai_status_t *object_statuses) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_get_maximum_attribute_count( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _Out_ uint32_t *count) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_get_object_count( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _Out_ uint32_t *count) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_get_object_key( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _Inout_ uint32_t *object_count, + _Inout_ sai_object_key_t *object_list) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_query_stats_capability( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _Inout_ sai_stat_capability_list_t *stats_capability) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_query_api_version( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + // TODO this should be forwarded to SaiInterface object + + if (version) + { + *version = SAI_API_VERSION; + + // TODO FIXME implement proper query for syncd, currently this is not an issue since swss is not using this API + + SWSS_LOG_WARN("retruning SAI API version %d with saiproxy compiled SAI headers, not actual libsai.so", SAI_API_VERSION); + + return SAI_STATUS_SUCCESS; + } + + SWSS_LOG_ERROR("version parameter is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; +} + +sai_status_t sai_bulk_object_get_stats( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses, + _Out_ uint64_t *counters) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +sai_status_t sai_bulk_object_clear_stats( + _In_ sai_object_id_t switch_id, + _In_ sai_object_type_t object_type, + _In_ uint32_t object_count, + _In_ const sai_object_key_t *object_key, + _In_ uint32_t number_of_counters, + _In_ const sai_stat_id_t *counter_ids, + _In_ sai_stats_mode_t mode, + _Inout_ sai_status_t *object_statuses) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} diff --git a/proxylib/sai_proxy_ipmc.cpp b/proxylib/sai_proxy_ipmc.cpp new file mode 100644 index 000000000..1488a4bb4 --- /dev/null +++ b/proxylib/sai_proxy_ipmc.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(IPMC_ENTRY,ipmc_entry); + +const sai_ipmc_api_t proxy_ipmc_api = { + + PROXY_GENERIC_QUAD_API(ipmc_entry) +}; diff --git a/proxylib/sai_proxy_ipmc_group.cpp b/proxylib/sai_proxy_ipmc_group.cpp new file mode 100644 index 000000000..49dad28d1 --- /dev/null +++ b/proxylib/sai_proxy_ipmc_group.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(IPMC_GROUP,ipmc_group); +PROXY_GENERIC_QUAD(IPMC_GROUP_MEMBER,ipmc_group_member); + +const sai_ipmc_group_api_t proxy_ipmc_group_api = { + + PROXY_GENERIC_QUAD_API(ipmc_group) + PROXY_GENERIC_QUAD_API(ipmc_group_member) +}; diff --git a/proxylib/sai_proxy_ipsec.cpp b/proxylib/sai_proxy_ipsec.cpp new file mode 100644 index 000000000..5e7068426 --- /dev/null +++ b/proxylib/sai_proxy_ipsec.cpp @@ -0,0 +1,16 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(IPSEC,ipsec); +PROXY_GENERIC_QUAD(IPSEC_PORT,ipsec_port); +PROXY_GENERIC_QUAD(IPSEC_SA,ipsec_sa); +PROXY_GENERIC_STATS(IPSEC_PORT,ipsec_port); +PROXY_GENERIC_STATS(IPSEC_SA,ipsec_sa); + +const sai_ipsec_api_t proxy_ipsec_api = { + + PROXY_GENERIC_QUAD_API(ipsec) + PROXY_GENERIC_QUAD_API(ipsec_port) + PROXY_GENERIC_STATS_API(ipsec_port) + PROXY_GENERIC_QUAD_API(ipsec_sa) + PROXY_GENERIC_STATS_API(ipsec_sa) +}; diff --git a/proxylib/sai_proxy_isolation_group.cpp b/proxylib/sai_proxy_isolation_group.cpp new file mode 100644 index 000000000..220b7ebb8 --- /dev/null +++ b/proxylib/sai_proxy_isolation_group.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(ISOLATION_GROUP,isolation_group); +PROXY_GENERIC_QUAD(ISOLATION_GROUP_MEMBER,isolation_group_member); + +const sai_isolation_group_api_t proxy_isolation_group_api = { + + PROXY_GENERIC_QUAD_API(isolation_group) + PROXY_GENERIC_QUAD_API(isolation_group_member) +}; diff --git a/proxylib/sai_proxy_l2mc.cpp b/proxylib/sai_proxy_l2mc.cpp new file mode 100644 index 000000000..f62e460c8 --- /dev/null +++ b/proxylib/sai_proxy_l2mc.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(L2MC_ENTRY,l2mc_entry); + +const sai_l2mc_api_t proxy_l2mc_api = { + + PROXY_GENERIC_QUAD_API(l2mc_entry) +}; diff --git a/proxylib/sai_proxy_l2mcgroup.cpp b/proxylib/sai_proxy_l2mcgroup.cpp new file mode 100644 index 000000000..790ae1bee --- /dev/null +++ b/proxylib/sai_proxy_l2mcgroup.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(L2MC_GROUP,l2mc_group); +PROXY_GENERIC_QUAD(L2MC_GROUP_MEMBER,l2mc_group_member); + +const sai_l2mc_group_api_t proxy_l2mc_group_api = { + + PROXY_GENERIC_QUAD_API(l2mc_group) + PROXY_GENERIC_QUAD_API(l2mc_group_member) +}; diff --git a/proxylib/sai_proxy_lag.cpp b/proxylib/sai_proxy_lag.cpp new file mode 100644 index 000000000..222912644 --- /dev/null +++ b/proxylib/sai_proxy_lag.cpp @@ -0,0 +1,16 @@ +#include "sai_proxy.h" + +PROXY_BULK_CREATE(LAG_MEMBER,lag_members); +PROXY_BULK_REMOVE(LAG_MEMBER,lag_members); + +PROXY_GENERIC_QUAD(LAG,lag); +PROXY_GENERIC_QUAD(LAG_MEMBER,lag_member); + +const sai_lag_api_t proxy_lag_api = { + + PROXY_GENERIC_QUAD_API(lag) + PROXY_GENERIC_QUAD_API(lag_member) + + proxy_bulk_create_lag_members, + proxy_bulk_remove_lag_members, +}; diff --git a/proxylib/sai_proxy_macsec.cpp b/proxylib/sai_proxy_macsec.cpp new file mode 100644 index 000000000..7bf838b7d --- /dev/null +++ b/proxylib/sai_proxy_macsec.cpp @@ -0,0 +1,24 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(MACSEC,macsec); +PROXY_GENERIC_QUAD(MACSEC_PORT,macsec_port); +PROXY_GENERIC_STATS(MACSEC_PORT,macsec_port); +PROXY_GENERIC_QUAD(MACSEC_FLOW,macsec_flow); +PROXY_GENERIC_STATS(MACSEC_FLOW,macsec_flow); +PROXY_GENERIC_QUAD(MACSEC_SC,macsec_sc); +PROXY_GENERIC_STATS(MACSEC_SC,macsec_sc); +PROXY_GENERIC_QUAD(MACSEC_SA,macsec_sa); +PROXY_GENERIC_STATS(MACSEC_SA,macsec_sa); + +const sai_macsec_api_t proxy_macsec_api = { + + PROXY_GENERIC_QUAD_API(macsec) + PROXY_GENERIC_QUAD_API(macsec_port) + PROXY_GENERIC_STATS_API(macsec_port) + PROXY_GENERIC_QUAD_API(macsec_flow) + PROXY_GENERIC_STATS_API(macsec_flow) + PROXY_GENERIC_QUAD_API(macsec_sc) + PROXY_GENERIC_STATS_API(macsec_sc) + PROXY_GENERIC_QUAD_API(macsec_sa) + PROXY_GENERIC_STATS_API(macsec_sa) +}; diff --git a/proxylib/sai_proxy_mcastfdb.cpp b/proxylib/sai_proxy_mcastfdb.cpp new file mode 100644 index 000000000..1c9322df1 --- /dev/null +++ b/proxylib/sai_proxy_mcastfdb.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(MCAST_FDB_ENTRY,mcast_fdb_entry); + +const sai_mcast_fdb_api_t proxy_mcast_fdb_api = { + + PROXY_GENERIC_QUAD_API(mcast_fdb_entry) +}; diff --git a/proxylib/sai_proxy_mirror.cpp b/proxylib/sai_proxy_mirror.cpp new file mode 100644 index 000000000..977226905 --- /dev/null +++ b/proxylib/sai_proxy_mirror.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(MIRROR_SESSION,mirror_session); + +const sai_mirror_api_t proxy_mirror_api = { + + PROXY_GENERIC_QUAD_API(mirror_session) +}; diff --git a/proxylib/sai_proxy_mpls.cpp b/proxylib/sai_proxy_mpls.cpp new file mode 100644 index 000000000..78b5db280 --- /dev/null +++ b/proxylib/sai_proxy_mpls.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); +PROXY_BULK_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); + +const sai_mpls_api_t proxy_mpls_api = { + + PROXY_GENERIC_QUAD_API(inseg_entry) + PROXY_BULK_QUAD_API(inseg_entry) +}; diff --git a/proxylib/sai_proxy_my_mac.cpp b/proxylib/sai_proxy_my_mac.cpp new file mode 100644 index 000000000..ec730b8ab --- /dev/null +++ b/proxylib/sai_proxy_my_mac.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(MY_MAC,my_mac); + +const sai_my_mac_api_t proxy_my_mac_api = { + + PROXY_GENERIC_QUAD_API(my_mac) +}; diff --git a/proxylib/sai_proxy_nat.cpp b/proxylib/sai_proxy_nat.cpp new file mode 100644 index 000000000..7cfab7fe4 --- /dev/null +++ b/proxylib/sai_proxy_nat.cpp @@ -0,0 +1,12 @@ +#include "sai_proxy.h" + +PROXY_BULK_QUAD_ENTRY(NAT_ENTRY,nat_entry); +PROXY_GENERIC_QUAD_ENTRY(NAT_ENTRY,nat_entry); +PROXY_GENERIC_QUAD(NAT_ZONE_COUNTER,nat_zone_counter); + +const sai_nat_api_t proxy_nat_api = { + + PROXY_GENERIC_QUAD_API(nat_entry) + PROXY_BULK_QUAD_API(nat_entry) + PROXY_GENERIC_QUAD_API(nat_zone_counter) +}; diff --git a/proxylib/sai_proxy_neighbor.cpp b/proxylib/sai_proxy_neighbor.cpp new file mode 100644 index 000000000..0988193cd --- /dev/null +++ b/proxylib/sai_proxy_neighbor.cpp @@ -0,0 +1,20 @@ +#include "sai_proxy.h" + +static sai_status_t proxy_remove_all_neighbor_entries( + _In_ sai_object_id_t switch_id) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +PROXY_BULK_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); +PROXY_GENERIC_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); + +const sai_neighbor_api_t proxy_neighbor_api = { + + PROXY_GENERIC_QUAD_API(neighbor_entry) + proxy_remove_all_neighbor_entries, + + PROXY_BULK_QUAD_API(neighbor_entry) +}; diff --git a/proxylib/sai_proxy_nexthop.cpp b/proxylib/sai_proxy_nexthop.cpp new file mode 100644 index 000000000..25af42de8 --- /dev/null +++ b/proxylib/sai_proxy_nexthop.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(NEXT_HOP,next_hop); +PROXY_BULK_QUAD(NEXT_HOP,next_hop); + +const sai_next_hop_api_t proxy_next_hop_api = { + + PROXY_GENERIC_QUAD_API(next_hop) + PROXY_BULK_QUAD_API(next_hop) +}; diff --git a/proxylib/sai_proxy_nexthopgroup.cpp b/proxylib/sai_proxy_nexthopgroup.cpp new file mode 100644 index 000000000..f151be1cc --- /dev/null +++ b/proxylib/sai_proxy_nexthopgroup.cpp @@ -0,0 +1,21 @@ +#include "sai_proxy.h" + +PROXY_BULK_CREATE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); +PROXY_BULK_REMOVE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); +PROXY_BULK_GET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); +PROXY_BULK_SET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); +PROXY_GENERIC_QUAD(NEXT_HOP_GROUP,next_hop_group); +PROXY_GENERIC_QUAD(NEXT_HOP_GROUP_MEMBER,next_hop_group_member); +PROXY_GENERIC_QUAD(NEXT_HOP_GROUP_MAP,next_hop_group_map); + +const sai_next_hop_group_api_t proxy_next_hop_group_api = { + + PROXY_GENERIC_QUAD_API(next_hop_group) + PROXY_GENERIC_QUAD_API(next_hop_group_member) + + proxy_bulk_create_next_hop_group_members, + proxy_bulk_remove_next_hop_group_members, + PROXY_GENERIC_QUAD_API(next_hop_group_map) + proxy_bulk_set_next_hop_group_members, + proxy_bulk_get_next_hop_group_members +}; diff --git a/proxylib/sai_proxy_poe.cpp b/proxylib/sai_proxy_poe.cpp new file mode 100644 index 000000000..2f91297af --- /dev/null +++ b/proxylib/sai_proxy_poe.cpp @@ -0,0 +1,12 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(POE_DEVICE,poe_device); +PROXY_GENERIC_QUAD(POE_PSE,poe_pse); +PROXY_GENERIC_QUAD(POE_PORT,poe_port); + +const sai_poe_api_t proxy_poe_api = { + + PROXY_GENERIC_QUAD_API(poe_device) + PROXY_GENERIC_QUAD_API(poe_pse) + PROXY_GENERIC_QUAD_API(poe_port) +}; diff --git a/proxylib/sai_proxy_policer.cpp b/proxylib/sai_proxy_policer.cpp new file mode 100644 index 000000000..f1b6206b3 --- /dev/null +++ b/proxylib/sai_proxy_policer.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(POLICER,policer); +PROXY_GENERIC_STATS(POLICER,policer); + +const sai_policer_api_t proxy_policer_api = { + + PROXY_GENERIC_QUAD_API(policer) + PROXY_GENERIC_STATS_API(policer) +}; diff --git a/proxylib/sai_proxy_port.cpp b/proxylib/sai_proxy_port.cpp new file mode 100644 index 000000000..e7dcde00d --- /dev/null +++ b/proxylib/sai_proxy_port.cpp @@ -0,0 +1,33 @@ +#include "sai_proxy.h" + +static sai_status_t proxy_clear_port_all_stats( + _In_ sai_object_id_t port_id) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +PROXY_GENERIC_QUAD(PORT,port); +PROXY_GENERIC_QUAD(PORT_POOL,port_pool); +PROXY_GENERIC_QUAD(PORT_SERDES,port_serdes); +PROXY_GENERIC_QUAD(PORT_CONNECTOR,port_connector); +PROXY_GENERIC_STATS(PORT,port); +PROXY_GENERIC_STATS(PORT_POOL,port_pool); +PROXY_BULK_QUAD(PORT, ports); +PROXY_BULK_QUAD(PORT_SERDES, port_serdeses); + +const sai_port_api_t proxy_port_api = { + + PROXY_GENERIC_QUAD_API(port) + PROXY_GENERIC_STATS_API(port) + + proxy_clear_port_all_stats, + + PROXY_GENERIC_QUAD_API(port_pool) + PROXY_GENERIC_STATS_API(port_pool) + PROXY_GENERIC_QUAD_API(port_connector) + PROXY_GENERIC_QUAD_API(port_serdes) + PROXY_BULK_QUAD_API(ports) + PROXY_BULK_QUAD_API(port_serdeses) +}; diff --git a/proxylib/sai_proxy_qosmap.cpp b/proxylib/sai_proxy_qosmap.cpp new file mode 100644 index 000000000..c67bcc8d9 --- /dev/null +++ b/proxylib/sai_proxy_qosmap.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(QOS_MAP,qos_map); + +const sai_qos_map_api_t proxy_qos_map_api = { + + PROXY_GENERIC_QUAD_API(qos_map) +}; diff --git a/proxylib/sai_proxy_queue.cpp b/proxylib/sai_proxy_queue.cpp new file mode 100644 index 000000000..8136454ce --- /dev/null +++ b/proxylib/sai_proxy_queue.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(QUEUE,queue); +PROXY_GENERIC_STATS(QUEUE,queue); + +const sai_queue_api_t proxy_queue_api = { + + PROXY_GENERIC_QUAD_API(queue) + PROXY_GENERIC_STATS_API(queue) +}; diff --git a/proxylib/sai_proxy_route.cpp b/proxylib/sai_proxy_route.cpp new file mode 100644 index 000000000..07007e5e7 --- /dev/null +++ b/proxylib/sai_proxy_route.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD_ENTRY(ROUTE_ENTRY,route_entry); +PROXY_BULK_QUAD_ENTRY(ROUTE_ENTRY,route_entry); + +const sai_route_api_t proxy_route_api = { + + PROXY_GENERIC_QUAD_API(route_entry) + PROXY_BULK_QUAD_API(route_entry) +}; diff --git a/proxylib/sai_proxy_router_interface.cpp b/proxylib/sai_proxy_router_interface.cpp new file mode 100644 index 000000000..5f65618da --- /dev/null +++ b/proxylib/sai_proxy_router_interface.cpp @@ -0,0 +1,12 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(ROUTER_INTERFACE,router_interface); +PROXY_GENERIC_STATS(ROUTER_INTERFACE,router_interface); +PROXY_BULK_QUAD(ROUTER_INTERFACE,router_interfaces); + +const sai_router_interface_api_t proxy_router_interface_api = { + + PROXY_GENERIC_QUAD_API(router_interface) + PROXY_GENERIC_STATS_API(router_interface) + PROXY_BULK_QUAD_API(router_interfaces) +}; diff --git a/proxylib/sai_proxy_rpfgroup.cpp b/proxylib/sai_proxy_rpfgroup.cpp new file mode 100644 index 000000000..9933f37d5 --- /dev/null +++ b/proxylib/sai_proxy_rpfgroup.cpp @@ -0,0 +1,10 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(RPF_GROUP,rpf_group); +PROXY_GENERIC_QUAD(RPF_GROUP_MEMBER,rpf_group_member); + +const sai_rpf_group_api_t proxy_rpf_group_api = { + + PROXY_GENERIC_QUAD_API(rpf_group) + PROXY_GENERIC_QUAD_API(rpf_group_member) +}; diff --git a/proxylib/sai_proxy_samplepacket.cpp b/proxylib/sai_proxy_samplepacket.cpp new file mode 100644 index 000000000..8e0c2ca3f --- /dev/null +++ b/proxylib/sai_proxy_samplepacket.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(SAMPLEPACKET,samplepacket); + +const sai_samplepacket_api_t proxy_samplepacket_api = { + + PROXY_GENERIC_QUAD_API(samplepacket) +}; diff --git a/proxylib/sai_proxy_scheduler.cpp b/proxylib/sai_proxy_scheduler.cpp new file mode 100644 index 000000000..b193b71e0 --- /dev/null +++ b/proxylib/sai_proxy_scheduler.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(SCHEDULER,scheduler); + +const sai_scheduler_api_t proxy_scheduler_api = { + + PROXY_GENERIC_QUAD_API(scheduler) +}; diff --git a/proxylib/sai_proxy_schedulergroup.cpp b/proxylib/sai_proxy_schedulergroup.cpp new file mode 100644 index 000000000..08c79dfa5 --- /dev/null +++ b/proxylib/sai_proxy_schedulergroup.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(SCHEDULER_GROUP,scheduler_group); + +const sai_scheduler_group_api_t proxy_scheduler_group_api = { + + PROXY_GENERIC_QUAD_API(scheduler_group) +}; diff --git a/proxylib/sai_proxy_srv6.cpp b/proxylib/sai_proxy_srv6.cpp new file mode 100644 index 000000000..eedafd298 --- /dev/null +++ b/proxylib/sai_proxy_srv6.cpp @@ -0,0 +1,22 @@ +#include "sai_proxy.h" + +PROXY_BULK_CREATE(SRV6_SIDLIST, srv6_sidlist); +PROXY_BULK_REMOVE(SRV6_SIDLIST, srv6_sidlist); +PROXY_GENERIC_QUAD(SRV6_SIDLIST,srv6_sidlist); +PROXY_BULK_QUAD_ENTRY(MY_SID_ENTRY,my_sid_entry); +PROXY_GENERIC_QUAD_ENTRY(MY_SID_ENTRY,my_sid_entry); + +const sai_srv6_api_t proxy_srv6_api = { + + PROXY_GENERIC_QUAD_API(srv6_sidlist) + + proxy_bulk_create_srv6_sidlist, + proxy_bulk_remove_srv6_sidlist, + + NULL, + NULL, + NULL, + + PROXY_GENERIC_QUAD_API(my_sid_entry) + PROXY_BULK_QUAD_API(my_sid_entry) +}; diff --git a/proxylib/sai_proxy_stp.cpp b/proxylib/sai_proxy_stp.cpp new file mode 100644 index 000000000..e01a2b0bf --- /dev/null +++ b/proxylib/sai_proxy_stp.cpp @@ -0,0 +1,15 @@ +#include "sai_proxy.h" + +PROXY_BULK_CREATE(STP_PORT,stp_ports); +PROXY_BULK_REMOVE(STP_PORT,stp_ports); +PROXY_GENERIC_QUAD(STP,stp); +PROXY_GENERIC_QUAD(STP_PORT,stp_port); + +const sai_stp_api_t proxy_stp_api = { + + PROXY_GENERIC_QUAD_API(stp) + PROXY_GENERIC_QUAD_API(stp_port) + + proxy_bulk_create_stp_ports, + proxy_bulk_remove_stp_ports, +}; diff --git a/proxylib/sai_proxy_switch.cpp b/proxylib/sai_proxy_switch.cpp new file mode 100644 index 000000000..4cf80bcf0 --- /dev/null +++ b/proxylib/sai_proxy_switch.cpp @@ -0,0 +1,84 @@ +#include "sai_proxy.h" + +static sai_status_t proxy_switch_mdio_read( + _In_ sai_object_id_t switch_id, + _In_ uint32_t device_addr, + _In_ uint32_t start_reg_addr, + _In_ uint32_t number_of_registers, + _Out_ uint32_t *reg_val) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_switch_mdio_write( + _In_ sai_object_id_t switch_id, + _In_ uint32_t device_addr, + _In_ uint32_t start_reg_addr, + _In_ uint32_t number_of_registers, + _In_ const uint32_t *reg_val) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_switch_mdio_cl22_read( + _In_ sai_object_id_t switch_id, + _In_ uint32_t device_addr, + _In_ uint32_t start_reg_addr, + _In_ uint32_t number_of_registers, + _Out_ uint32_t *reg_val) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +static sai_status_t proxy_switch_mdio_cl22_write( + _In_ sai_object_id_t switch_id, + _In_ uint32_t device_addr, + _In_ uint32_t start_reg_addr, + _In_ uint32_t number_of_registers, + _In_ const uint32_t *reg_val) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +PROXY_GENERIC_QUAD(SWITCH,switch); +PROXY_GENERIC_STATS(SWITCH,switch); +PROXY_GENERIC_QUAD(SWITCH_TUNNEL,switch_tunnel); + +static sai_status_t proxy_create_switch_uniq( + _Out_ sai_object_id_t *switch_id, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + return proxy_create_switch( + switch_id, + SAI_NULL_OBJECT_ID, // no switch id since we create switch + attr_count, + attr_list); +} + +const sai_switch_api_t proxy_switch_api = { + + proxy_create_switch_uniq, + proxy_remove_switch, + proxy_set_switch_attribute, + proxy_get_switch_attribute, + + PROXY_GENERIC_STATS_API(switch) + + proxy_switch_mdio_read, + proxy_switch_mdio_write, + + PROXY_GENERIC_QUAD_API(switch_tunnel) + proxy_switch_mdio_cl22_read, + proxy_switch_mdio_cl22_write +}; diff --git a/proxylib/sai_proxy_system_port.cpp b/proxylib/sai_proxy_system_port.cpp new file mode 100644 index 000000000..45e9f68a4 --- /dev/null +++ b/proxylib/sai_proxy_system_port.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(SYSTEM_PORT,system_port); + +const sai_system_port_api_t proxy_system_port_api = { + + PROXY_GENERIC_QUAD_API(system_port) +}; diff --git a/proxylib/sai_proxy_tam.cpp b/proxylib/sai_proxy_tam.cpp new file mode 100644 index 000000000..526bca272 --- /dev/null +++ b/proxylib/sai_proxy_tam.cpp @@ -0,0 +1,42 @@ +#include "sai_proxy.h" + +sai_status_t sai_tam_telemetry_get_data( + _In_ sai_object_id_t switch_id, + _In_ sai_object_list_t obj_list, + _In_ bool clear_on_read, + _Inout_ sai_size_t *buffer_size, + _Out_ void *buffer) +{ + SWSS_LOG_ENTER(); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +PROXY_GENERIC_QUAD(TAM,tam); +PROXY_GENERIC_QUAD(TAM_MATH_FUNC,tam_math_func); +PROXY_GENERIC_QUAD(TAM_REPORT,tam_report); +PROXY_GENERIC_QUAD(TAM_EVENT_THRESHOLD,tam_event_threshold); +PROXY_GENERIC_QUAD(TAM_INT,tam_int); +PROXY_GENERIC_QUAD(TAM_TEL_TYPE,tam_tel_type); +PROXY_GENERIC_QUAD(TAM_TRANSPORT,tam_transport); +PROXY_GENERIC_QUAD(TAM_TELEMETRY,tam_telemetry); +PROXY_GENERIC_QUAD(TAM_COLLECTOR,tam_collector); +PROXY_GENERIC_QUAD(TAM_EVENT_ACTION,tam_event_action); +PROXY_GENERIC_QUAD(TAM_EVENT,tam_event); +PROXY_GENERIC_QUAD(TAM_COUNTER_SUBSCRIPTION,tam_counter_subscription); + +const sai_tam_api_t proxy_tam_api = { + + PROXY_GENERIC_QUAD_API(tam) + PROXY_GENERIC_QUAD_API(tam_math_func) + PROXY_GENERIC_QUAD_API(tam_report) + PROXY_GENERIC_QUAD_API(tam_event_threshold) + PROXY_GENERIC_QUAD_API(tam_int) + PROXY_GENERIC_QUAD_API(tam_tel_type) + PROXY_GENERIC_QUAD_API(tam_transport) + PROXY_GENERIC_QUAD_API(tam_telemetry) + PROXY_GENERIC_QUAD_API(tam_collector) + PROXY_GENERIC_QUAD_API(tam_event_action) + PROXY_GENERIC_QUAD_API(tam_event) + PROXY_GENERIC_QUAD_API(tam_counter_subscription) +}; diff --git a/proxylib/sai_proxy_tunnel.cpp b/proxylib/sai_proxy_tunnel.cpp new file mode 100644 index 000000000..f0dacf515 --- /dev/null +++ b/proxylib/sai_proxy_tunnel.cpp @@ -0,0 +1,18 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(TUNNEL_MAP,tunnel_map); +PROXY_GENERIC_QUAD(TUNNEL,tunnel); +PROXY_GENERIC_QUAD(TUNNEL_TERM_TABLE_ENTRY,tunnel_term_table_entry); +PROXY_GENERIC_QUAD(TUNNEL_MAP_ENTRY,tunnel_map_entry); +PROXY_GENERIC_STATS(TUNNEL,tunnel); +PROXY_BULK_QUAD(TUNNEL,tunnels); + +const sai_tunnel_api_t proxy_tunnel_api = { + + PROXY_GENERIC_QUAD_API(tunnel_map) + PROXY_GENERIC_QUAD_API(tunnel) + PROXY_GENERIC_STATS_API(tunnel) + PROXY_GENERIC_QUAD_API(tunnel_term_table_entry) + PROXY_GENERIC_QUAD_API(tunnel_map_entry) + PROXY_BULK_QUAD_API(tunnels) +}; diff --git a/proxylib/sai_proxy_twamp.cpp b/proxylib/sai_proxy_twamp.cpp new file mode 100644 index 000000000..7abdfc71c --- /dev/null +++ b/proxylib/sai_proxy_twamp.cpp @@ -0,0 +1,9 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(TWAMP_SESSION,twamp_session); +PROXY_GENERIC_STATS(TWAMP_SESSION,twamp_session); + +const sai_twamp_api_t proxy_twamp_api = { + PROXY_GENERIC_QUAD_API(twamp_session) + PROXY_GENERIC_STATS_API(twamp_session) +}; diff --git a/proxylib/sai_proxy_udf.cpp b/proxylib/sai_proxy_udf.cpp new file mode 100644 index 000000000..31f0da664 --- /dev/null +++ b/proxylib/sai_proxy_udf.cpp @@ -0,0 +1,12 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(UDF,udf) +PROXY_GENERIC_QUAD(UDF_MATCH,udf_match) +PROXY_GENERIC_QUAD(UDF_GROUP,udf_group) + +const sai_udf_api_t proxy_udf_api = { + + PROXY_GENERIC_QUAD_API(udf) + PROXY_GENERIC_QUAD_API(udf_match) + PROXY_GENERIC_QUAD_API(udf_group) +}; diff --git a/proxylib/sai_proxy_virtual_router.cpp b/proxylib/sai_proxy_virtual_router.cpp new file mode 100644 index 000000000..f5c775f79 --- /dev/null +++ b/proxylib/sai_proxy_virtual_router.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(VIRTUAL_ROUTER,virtual_router); + +const sai_virtual_router_api_t proxy_virtual_router_api = { + + PROXY_GENERIC_QUAD_API(virtual_router) +}; diff --git a/proxylib/sai_proxy_vlan.cpp b/proxylib/sai_proxy_vlan.cpp new file mode 100644 index 000000000..89b561a68 --- /dev/null +++ b/proxylib/sai_proxy_vlan.cpp @@ -0,0 +1,18 @@ +#include "sai_proxy.h" + +PROXY_BULK_CREATE(VLAN_MEMBER,vlan_members); +PROXY_BULK_REMOVE(VLAN_MEMBER,vlan_members); +PROXY_GENERIC_QUAD(VLAN,vlan); +PROXY_GENERIC_QUAD(VLAN_MEMBER,vlan_member); +PROXY_GENERIC_STATS(VLAN,vlan); + +const sai_vlan_api_t proxy_vlan_api = { + + PROXY_GENERIC_QUAD_API(vlan) + PROXY_GENERIC_QUAD_API(vlan_member) + + proxy_bulk_create_vlan_members, + proxy_bulk_remove_vlan_members, + + PROXY_GENERIC_STATS_API(vlan) +}; diff --git a/proxylib/sai_proxy_wred.cpp b/proxylib/sai_proxy_wred.cpp new file mode 100644 index 000000000..24dfe0b99 --- /dev/null +++ b/proxylib/sai_proxy_wred.cpp @@ -0,0 +1,8 @@ +#include "sai_proxy.h" + +PROXY_GENERIC_QUAD(WRED,wred); + +const sai_wred_api_t proxy_wred_api = { + + PROXY_GENERIC_QUAD_API(wred) +}; diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index d81392265..86403451e 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -474,3 +474,4 @@ ZMQ ZMQ uncreated TWAMP +saiproxy diff --git a/tests/checksaiapi.sh b/tests/checksaiapi.sh index 6353fbcd6..03730d8d1 100755 --- a/tests/checksaiapi.sh +++ b/tests/checksaiapi.sh @@ -36,7 +36,7 @@ REGEX=`cat SAI/meta/saimetadata.c|grep dlsym|grep handle|perl -ne 'print "$1|" i set +e find -name "*.cpp" -o -name "*.c" | xargs grep -P "$REGEX" | -grep -vP "/unittest/|/tests/|/SAI/|/pyext/|tests.cpp|sai_vs_interfacequery|sai_redis_interfacequery|saisdkdump|SWSS_LOG|.cpp:\s+\*|.cpp:\s+//|sai_status_t\s+sai_|VendorSai.cpp:.+=\s*&sai_" +grep -vP "/unittest/|/tests/|/SAI/|/pyext/|tests.cpp|sai_vs_interfacequery|sai_proxy_interfacequery|sai_redis_interfacequery|saisdkdump|SWSS_LOG|.cpp:\s+\*|.cpp:\s+//|sai_status_t\s+sai_|VendorSai.cpp:.+=\s*&sai_" if [ $? == 0 ]; then echo not allowed files are using global sai_xxx API, please correct your code, only VendorSai.cpp and saisdkdump are allowed to use global SAI apis diff --git a/unittest/Makefile.am b/unittest/Makefile.am index 9be94ee0a..8cd9711fc 100644 --- a/unittest/Makefile.am +++ b/unittest/Makefile.am @@ -1 +1 @@ -SUBDIRS = meta lib vslib syncd +SUBDIRS = meta lib vslib syncd proxylib diff --git a/unittest/proxylib/Makefile.am b/unittest/proxylib/Makefile.am new file mode 100644 index 000000000..5c7e61134 --- /dev/null +++ b/unittest/proxylib/Makefile.am @@ -0,0 +1,78 @@ +AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/proxylib -I$(top_srcdir)/lib + +bin_PROGRAMS = tests testslibsaiproxy + +LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main + +tests_SOURCES = \ + main.cpp \ + TestSai.cpp + +tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) +tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/proxylib/libSaiProxy.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) + +testslibsaiproxy_SOURCES = main_libsaiproxy.cpp \ + test_sai_proxy_acl.cpp \ + test_sai_proxy_bfd.cpp \ + test_sai_proxy_bmtor.cpp \ + test_sai_proxy_bridge.cpp \ + test_sai_proxy_buffer.cpp \ + test_sai_proxy_counter.cpp \ + test_sai_proxy_dash_vip.cpp \ + test_sai_proxy_dash_pa_validation.cpp \ + test_sai_proxy_dash_vnet.cpp \ + test_sai_proxy_dash_outbound_routing.cpp \ + test_sai_proxy_dash_outbound_ca_to_pa.cpp \ + test_sai_proxy_dash_inbound_routing.cpp \ + test_sai_proxy_dash_eni.cpp \ + test_sai_proxy_dash_direction_lookup.cpp \ + test_sai_proxy_dash_acl.cpp \ + test_sai_proxy_debug_counter.cpp \ + test_sai_proxy_dtel.cpp \ + test_sai_proxy_fdb.cpp \ + test_sai_proxy_generic_programmable.cpp \ + test_sai_proxy_ipmc.cpp \ + test_sai_proxy_l2mc.cpp \ + test_sai_proxy_l2mcgroup.cpp \ + test_sai_proxy_lag.cpp \ + test_sai_proxy_ipmc_group.cpp \ + test_sai_proxy_macsec.cpp \ + test_sai_proxy_isolation_group.cpp \ + test_sai_proxy_interfacequery.cpp \ + test_sai_proxy_mcastfdb.cpp \ + test_sai_proxy_mirror.cpp \ + test_sai_proxy_mpls.cpp \ + test_sai_proxy_nat.cpp \ + test_sai_proxy_hash.cpp \ + test_sai_proxy_neighbor.cpp \ + test_sai_proxy_nexthop.cpp \ + test_sai_proxy_nexthopgroup.cpp \ + test_sai_proxy_port.cpp \ + test_sai_proxy_qosmap.cpp \ + test_sai_proxy_policer.cpp \ + test_sai_proxy_queue.cpp \ + test_sai_proxy_route.cpp \ + test_sai_proxy_router_interface.cpp \ + test_sai_proxy_router_rpfgroup.cpp \ + test_sai_proxy_router_samplepacket.cpp \ + test_sai_proxy_schedulergroup.cpp \ + test_sai_proxy_scheduler.cpp \ + test_sai_proxy_srv6.cpp \ + test_sai_proxy_switch.cpp \ + test_sai_proxy_system_port.cpp \ + test_sai_proxy_tam.cpp \ + test_sai_proxy_tunnel.cpp \ + test_sai_proxy_stp.cpp \ + test_sai_proxy_udf.cpp \ + test_sai_proxy_virtual_router.cpp \ + test_sai_proxy_vlan.cpp \ + test_sai_proxy_hostif.cpp \ + test_sai_proxy_wred.cpp \ + test_sai_proxy_ars.cpp \ + test_sai_proxy_poe.cpp \ + test_sai_proxy_ars_profile.cpp + +testslibsaiproxy_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) +testslibsaiproxy_LDADD = $(LDADD_GTEST) -L$(top_srcdir)/proxylib/.libs -lsaiproxy -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) + +TESTS = testslibsaiproxy tests diff --git a/unittest/proxylib/TestSai.cpp b/unittest/proxylib/TestSai.cpp new file mode 100644 index 000000000..3cee8d413 --- /dev/null +++ b/unittest/proxylib/TestSai.cpp @@ -0,0 +1,50 @@ +#include + +#include +#include +#include + +#include + +#include "Sai.h" + +using namespace saiproxy; + +class SaiTest : public ::testing::Test +{ +public: + SaiTest() = default; + virtual ~SaiTest() = default; + +public: + virtual void SetUp() override + { + m_sai = std::make_shared(); + + //sai_attribute_t attr; + //attr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + //attr.value.booldata = true; + + //auto status = m_sai->create(SAI_OBJECT_TYPE_SWITCH, &m_swid, SAI_NULL_OBJECT_ID, 1, &attr); + //ASSERT_EQ(status, SAI_STATUS_SUCCESS); + } + + virtual void TearDown() override + { + //auto status = m_sai->remove(SAI_OBJECT_TYPE_SWITCH, m_swid); + //ASSERT_EQ(status, SAI_STATUS_SUCCESS); + } + +protected: + std::shared_ptr m_sai; + + sai_object_id_t m_swid = SAI_NULL_OBJECT_ID; + + const std::uint32_t m_guid = 0; // default context config id + const std::uint32_t m_scid = 0; // default switch config id +}; + +TEST_F(SaiTest, Ctr) +{ + auto s = std::make_shared(); +} diff --git a/unittest/proxylib/main.cpp b/unittest/proxylib/main.cpp new file mode 100644 index 000000000..61f8cd250 --- /dev/null +++ b/unittest/proxylib/main.cpp @@ -0,0 +1,21 @@ +#include + +#include + +class SwsscommonEnvironment: + public ::testing::Environment +{ + public: + void SetUp() override { } +}; + +int main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + + const auto env = new SwsscommonEnvironment; + + testing::AddGlobalTestEnvironment(env); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/proxylib/main_libsaiproxy.cpp b/unittest/proxylib/main_libsaiproxy.cpp new file mode 100644 index 000000000..087ec87eb --- /dev/null +++ b/unittest/proxylib/main_libsaiproxy.cpp @@ -0,0 +1,118 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +#include + +static std::map g_profileMap; +static std::map::iterator g_profileIter; + +static const char* profile_get_value( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable) +{ + SWSS_LOG_ENTER(); + + if (variable == NULL) + { + SWSS_LOG_WARN("variable is null"); + return NULL; + } + + auto it = g_profileMap.find(variable); + + if (it == g_profileMap.end()) + { + SWSS_LOG_NOTICE("%s: NULL", variable); + return NULL; + } + + SWSS_LOG_NOTICE("%s: %s", variable, it->second.c_str()); + + return it->second.c_str(); +} + +static int profile_get_next_value( + _In_ sai_switch_profile_id_t profile_id, + _Out_ const char** variable, + _Out_ const char** value) +{ + SWSS_LOG_ENTER(); + + if (value == NULL) + { + SWSS_LOG_INFO("resetting profile map iterator"); + + g_profileIter = g_profileMap.begin(); + return 0; + } + + if (variable == NULL) + { + SWSS_LOG_WARN("variable is null"); + return -1; + } + + if (g_profileIter == g_profileMap.end()) + { + SWSS_LOG_INFO("iterator reached end"); + return -1; + } + + *variable = g_profileIter->first.c_str(); + *value = g_profileIter->second.c_str(); + + SWSS_LOG_INFO("key: %s:%s", *variable, *value); + + g_profileIter++; + + return 0; +} + +static sai_service_method_table_t test_services = { + profile_get_value, + profile_get_next_value +}; + +class SaiProxyEnvironment: + public ::testing::Environment +{ + public: + + virtual void SetUp() override + { + SWSS_LOG_ENTER(); + + //g_profileMap[SAI_KEY_VS_SWITCH_TYPE] = SAI_VALUE_VS_SWITCH_TYPE_BCM56850; + + g_profileIter = g_profileMap.begin(); + + auto status = sai_api_initialize(0, (sai_service_method_table_t*)&test_services); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + } + + virtual void TearDown() override + { + SWSS_LOG_ENTER(); + + auto status = sai_api_uninitialize(); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + } +}; + +int main(int argc, char* argv[]) +{ + testing::InitGoogleTest(&argc, argv); + + const auto env = new SaiProxyEnvironment(); + + testing::AddGlobalTestEnvironment(env); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/proxylib/test_sai_proxy_acl.cpp b/unittest/proxylib/test_sai_proxy_acl.cpp new file mode 100644 index 000000000..03f3a7c8b --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_acl.cpp @@ -0,0 +1,48 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, acl) +{ + sai_acl_api_t *api = nullptr; + + sai_api_query(SAI_API_ACL, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_counter(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_counter(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_counter_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_counter_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_range(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_range(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_range_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_range_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_acl_table_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_acl_table_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_acl_table_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_acl_table_group_member_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_ars.cpp b/unittest/proxylib/test_sai_proxy_ars.cpp new file mode 100644 index 000000000..46b321dfa --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_ars.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, ars) +{ + sai_ars_api_t *api = nullptr; + + sai_api_query(SAI_API_ARS, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ars(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ars(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ars_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ars_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_ars_profile.cpp b/unittest/proxylib/test_sai_proxy_ars_profile.cpp new file mode 100644 index 000000000..4dacf0926 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_ars_profile.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, ars_profile) +{ + sai_ars_profile_api_t *api = nullptr; + + sai_api_query(SAI_API_ARS_PROFILE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ars_profile(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ars_profile(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ars_profile_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ars_profile_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_bfd.cpp b/unittest/proxylib/test_sai_proxy_bfd.cpp new file mode 100644 index 000000000..375490a0f --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_bfd.cpp @@ -0,0 +1,27 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, bfd) +{ + sai_bfd_api_t *api = nullptr; + + sai_api_query(SAI_API_BFD, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bfd_session(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bfd_session(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bfd_session_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bfd_session_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bfd_session_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_bmtor.cpp b/unittest/proxylib/test_sai_proxy_bmtor.cpp new file mode 100644 index 000000000..4cf9309cb --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_bmtor.cpp @@ -0,0 +1,46 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, bmtor) +{ + sai_bmtor_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_BMTOR, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_bitmap_classification_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_bitmap_classification_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_bitmap_classification_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_classification_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_bitmap_classification_entry_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_bitmap_router_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_bitmap_router_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_bitmap_router_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_bitmap_router_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_bitmap_router_entry_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_table_meta_tunnel_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_table_meta_tunnel_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_table_meta_tunnel_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_table_meta_tunnel_entry_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_table_meta_tunnel_entry_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_bridge.cpp b/unittest/proxylib/test_sai_proxy_bridge.cpp new file mode 100644 index 000000000..41b62018c --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_bridge.cpp @@ -0,0 +1,36 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, bridge) +{ + sai_bridge_api_t *api = nullptr; + + sai_api_query(SAI_API_BRIDGE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bridge(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bridge(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bridge_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bridge_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_bridge_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_bridge_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_bridge_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_bridge_port_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_bridge_port_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_buffer.cpp b/unittest/proxylib/test_sai_proxy_buffer.cpp new file mode 100644 index 000000000..8e94de6b2 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_buffer.cpp @@ -0,0 +1,41 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, buffer) +{ + sai_buffer_api_t *api = nullptr; + + sai_api_query(SAI_API_BUFFER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_buffer_pool(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_buffer_pool(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_buffer_pool_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_pool_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_buffer_pool_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ingress_priority_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ingress_priority_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ingress_priority_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ingress_priority_group_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_ingress_priority_group_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_buffer_profile(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_buffer_profile(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_buffer_profile_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_buffer_profile_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_counter.cpp b/unittest/proxylib/test_sai_proxy_counter.cpp new file mode 100644 index 000000000..ba9b08a2c --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_counter.cpp @@ -0,0 +1,27 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, counter) +{ + sai_counter_api_t *api = nullptr; + + sai_api_query(SAI_API_COUNTER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_counter(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_counter(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_counter_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_counter_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_counter_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_counter_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_counter_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_acl.cpp b/unittest/proxylib/test_sai_proxy_dash_acl.cpp new file mode 100644 index 000000000..0c01886ac --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_acl.cpp @@ -0,0 +1,33 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_acl) +{ + sai_dash_acl_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_ACL, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dash_acl_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dash_acl_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dash_acl_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dash_acl_group_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dash_acl_groups(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dash_acl_groups(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dash_acl_rule(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dash_acl_rule(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dash_acl_rule_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dash_acl_rule_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dash_acl_rules(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dash_acl_rules(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_direction_lookup.cpp b/unittest/proxylib/test_sai_proxy_dash_direction_lookup.cpp new file mode 100644 index 000000000..bd6a90c21 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_direction_lookup.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_direction_lookup) +{ + sai_dash_direction_lookup_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_DIRECTION_LOOKUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_direction_lookup_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_direction_lookup_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_direction_lookup_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_direction_lookup_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_direction_lookup_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_direction_lookup_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_eni.cpp b/unittest/proxylib/test_sai_proxy_dash_eni.cpp new file mode 100644 index 000000000..21d8424fa --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_eni.cpp @@ -0,0 +1,33 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_eni) +{ + sai_dash_eni_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_ENI, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_eni_ether_address_map_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_eni_ether_address_map_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_eni_ether_address_map_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_eni_ether_address_map_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_eni_ether_address_map_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_eni_ether_address_map_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_eni(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_eni(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_eni_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_eni_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_enis(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_enis(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_inbound_routing.cpp b/unittest/proxylib/test_sai_proxy_dash_inbound_routing.cpp new file mode 100644 index 000000000..4beabbfb0 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_inbound_routing.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_inbound_routing) +{ + sai_dash_inbound_routing_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_INBOUND_ROUTING, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_inbound_routing_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_inbound_routing_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_inbound_routing_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_inbound_routing_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_inbound_routing_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_inbound_routing_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_outbound_ca_to_pa.cpp b/unittest/proxylib/test_sai_proxy_dash_outbound_ca_to_pa.cpp new file mode 100644 index 000000000..672af07f8 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_outbound_ca_to_pa.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_ca_to_pa) +{ + sai_dash_outbound_ca_to_pa_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_OUTBOUND_CA_TO_PA, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_outbound_ca_to_pa_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_outbound_ca_to_pa_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_outbound_ca_to_pa_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_outbound_ca_to_pa_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_outbound_ca_to_pa_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_outbound_ca_to_pa_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_outbound_routing.cpp b/unittest/proxylib/test_sai_proxy_dash_outbound_routing.cpp new file mode 100644 index 000000000..1f660162e --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_outbound_routing.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_outbound_routing) +{ + sai_dash_outbound_routing_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_OUTBOUND_ROUTING, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_outbound_routing_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_outbound_routing_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_outbound_routing_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_outbound_routing_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_outbound_routing_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_outbound_routing_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_pa_validation.cpp b/unittest/proxylib/test_sai_proxy_dash_pa_validation.cpp new file mode 100644 index 000000000..4ae287ea9 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_pa_validation.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_pa_validation) +{ + sai_dash_pa_validation_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_PA_VALIDATION, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_pa_validation_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_pa_validation_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_pa_validation_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_pa_validation_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_pa_validation_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_pa_validation_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_vip.cpp b/unittest/proxylib/test_sai_proxy_dash_vip.cpp new file mode 100644 index 000000000..cc01068d0 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_vip.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_vip) +{ + sai_dash_vip_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_VIP, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vip_entry(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vip_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_vip_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vip_entry_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vip_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vip_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dash_vnet.cpp b/unittest/proxylib/test_sai_proxy_dash_vnet.cpp new file mode 100644 index 000000000..1b1ac4e8f --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dash_vnet.cpp @@ -0,0 +1,24 @@ +#include + +extern "C" { +#include "sai.h" +#include "saiextensions.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dash_vnet) +{ + sai_dash_vnet_api_t *api = nullptr; + + sai_api_query((sai_api_t)SAI_API_DASH_VNET, (void**)&api); + + EXPECT_NE(api, nullptr); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vnet(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vnet(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_vnet_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vnet_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vnets(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vnets(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_debug_counter.cpp b/unittest/proxylib/test_sai_proxy_debug_counter.cpp new file mode 100644 index 000000000..d00179740 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_debug_counter.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, debug_counter) +{ + sai_debug_counter_api_t *api = nullptr; + + sai_api_query(SAI_API_DEBUG_COUNTER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_debug_counter(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_debug_counter(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_debug_counter_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_debug_counter_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_dtel.cpp b/unittest/proxylib/test_sai_proxy_dtel.cpp new file mode 100644 index 000000000..101d14762 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_dtel.cpp @@ -0,0 +1,43 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, dtel) +{ + sai_dtel_api_t *api = nullptr; + + sai_api_query(SAI_API_DTEL, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dtel(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dtel(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dtel_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dtel_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dtel_queue_report(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dtel_queue_report(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dtel_queue_report_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dtel_queue_report_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dtel_int_session(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dtel_int_session(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dtel_int_session_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dtel_int_session_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dtel_report_session(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dtel_report_session(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dtel_report_session_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dtel_report_session_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_dtel_event(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_dtel_event(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_dtel_event_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_dtel_event_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_fdb.cpp b/unittest/proxylib/test_sai_proxy_fdb.cpp new file mode 100644 index 000000000..c9f704581 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_fdb.cpp @@ -0,0 +1,30 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, fdb) +{ + sai_fdb_api_t *api = nullptr; + + sai_api_query(SAI_API_FDB, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_fdb_entry_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_fdb_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_fdb_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_fdb_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_fdb_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->flush_fdb_entries(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_fdb_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_fdb_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_fdb_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_fdb_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_generic_programmable.cpp b/unittest/proxylib/test_sai_proxy_generic_programmable.cpp new file mode 100644 index 000000000..57804b410 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_generic_programmable.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, generic_programmable) +{ + sai_generic_programmable_api_t *api = nullptr; + + sai_api_query(SAI_API_GENERIC_PROGRAMMABLE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t obj_id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_generic_programmable(&obj_id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_generic_programmable(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_generic_programmable_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_generic_programmable_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_hash.cpp b/unittest/proxylib/test_sai_proxy_hash.cpp new file mode 100644 index 000000000..516cfae26 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_hash.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, hash) +{ + sai_hash_api_t *api= nullptr; + + sai_api_query(SAI_API_HASH, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hash(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hash(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hash_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hash_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_fine_grained_hash_field(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_fine_grained_hash_field(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_fine_grained_hash_field_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_fine_grained_hash_field_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_hostif.cpp b/unittest/proxylib/test_sai_proxy_hostif.cpp new file mode 100644 index 000000000..e40f686d4 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_hostif.cpp @@ -0,0 +1,48 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, hostif) +{ + sai_hostif_api_t *api= nullptr; + + sai_api_query(SAI_API_HOSTIF, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hostif(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hostif(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hostif_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hostif_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hostif_table_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hostif_table_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hostif_table_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hostif_table_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hostif_trap_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hostif_trap_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hostif_trap_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hostif_trap_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hostif_trap(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hostif_trap(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hostif_trap_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hostif_trap_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_hostif_user_defined_trap(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_hostif_user_defined_trap(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_hostif_user_defined_trap_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_hostif_user_defined_trap_attribute(0,0,0)); + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->recv_hostif_packet(0,0,0,0,0)); + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->send_hostif_packet(0,0,0,0,0)); + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->allocate_hostif_packet(0,0,0,0,0)); + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->free_hostif_packet(0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_interfacequery.cpp b/unittest/proxylib/test_sai_proxy_interfacequery.cpp new file mode 100644 index 000000000..56dfff7b2 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_interfacequery.cpp @@ -0,0 +1,115 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, sai_log_set) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_log_set(SAI_API_VLAN, SAI_LOG_LEVEL_NOTICE)); +} + +TEST(libsaiproxy, sai_api_query) +{ + sai_vlan_api_t *api = nullptr; + + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_api_query(SAI_API_VLAN, nullptr)); + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_api_query(SAI_API_UNSPECIFIED, (void**)&api)); + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_api_query((sai_api_t)(1000), (void**)&api)); +#pragma GCC diagnostic pop + + EXPECT_EQ(SAI_STATUS_SUCCESS, sai_api_query(SAI_API_VLAN, (void**)&api)); +} + +TEST(libsaiproxy, sai_query_attribute_capability) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_query_attribute_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); +} + +TEST(libsaiproxy, sai_query_attribute_enum_values_capability) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_query_attribute_enum_values_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); +} + +TEST(libsaiproxy, sai_object_type_get_availability) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_object_type_get_availability(0,SAI_OBJECT_TYPE_NULL,0,0,0)); +} + +TEST(libsaiproxy, sai_dbg_generate_dump) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_dbg_generate_dump(nullptr)); +} + +TEST(libsaiproxy, sai_object_type_query) +{ + EXPECT_EQ(SAI_OBJECT_TYPE_NULL, sai_object_type_query(SAI_NULL_OBJECT_ID)); +} + +TEST(libsaiproxy, sai_switch_id_query) +{ + EXPECT_EQ(SAI_NULL_OBJECT_ID, sai_switch_id_query(SAI_NULL_OBJECT_ID)); +} + +TEST(libsaiproxy, sai_bulk_get_attribute) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_bulk_get_attribute(0,SAI_OBJECT_TYPE_NULL,0,0,0,0,0)); +} + +TEST(libsaiproxy, sai_get_maximum_attribute_count) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_maximum_attribute_count(0, SAI_OBJECT_TYPE_NULL,0)); +} + +TEST(libsaiproxy, sai_get_object_count) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_object_count(0,SAI_OBJECT_TYPE_NULL,0)); +} + +TEST(libsaiproxy, sai_get_object_key) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_object_key(0,SAI_OBJECT_TYPE_NULL,0,0)); +} + +TEST(libsaiproxy, sai_query_stats_capability) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_query_stats_capability(0,SAI_OBJECT_TYPE_NULL,0)); +} + +TEST(libsaiproxy, sai_bulk_object_get_stats) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_bulk_object_get_stats(SAI_NULL_OBJECT_ID, + SAI_OBJECT_TYPE_PORT, + 0, + nullptr, + 0, + nullptr, + SAI_STATS_MODE_BULK_READ, + nullptr, + nullptr)); +} + +TEST(libsaiproxy, sai_bulk_object_clear_stats) +{ + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_bulk_object_clear_stats(SAI_NULL_OBJECT_ID, + SAI_OBJECT_TYPE_PORT, + 0, + nullptr, + 0, + nullptr, + SAI_STATS_MODE_BULK_CLEAR, + nullptr)); +} + +TEST(libsaiproxy, sai_query_api_version) +{ + sai_api_version_t version; + + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_query_api_version(nullptr)); + EXPECT_EQ(SAI_STATUS_SUCCESS, sai_query_api_version(&version)); +} diff --git a/unittest/proxylib/test_sai_proxy_ipmc.cpp b/unittest/proxylib/test_sai_proxy_ipmc.cpp new file mode 100644 index 000000000..5aa5555d0 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_ipmc.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, ipmc) +{ + sai_ipmc_api_t *api = nullptr; + + sai_api_query(SAI_API_IPMC, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_ipmc_entry_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ipmc_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ipmc_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ipmc_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ipmc_entry_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_ipmc_group.cpp b/unittest/proxylib/test_sai_proxy_ipmc_group.cpp new file mode 100644 index 000000000..50a56ead6 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_ipmc_group.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, ipmc_group) +{ + sai_ipmc_group_api_t *api = nullptr; + + sai_api_query(SAI_API_IPMC_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ipmc_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ipmc_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ipmc_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ipmc_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_ipmc_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ipmc_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ipmc_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ipmc_group_member_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_isolation_group.cpp b/unittest/proxylib/test_sai_proxy_isolation_group.cpp new file mode 100644 index 000000000..23faaa490 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_isolation_group.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, isolation_group) +{ + sai_isolation_group_api_t *api = nullptr; + + sai_api_query(SAI_API_ISOLATION_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_isolation_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_isolation_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_isolation_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_isolation_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_isolation_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_isolation_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_isolation_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_isolation_group_member_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_l2mc.cpp b/unittest/proxylib/test_sai_proxy_l2mc.cpp new file mode 100644 index 000000000..1c646905a --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_l2mc.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, l2mc) +{ + sai_l2mc_api_t *api = nullptr; + + sai_api_query(SAI_API_L2MC, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_l2mc_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_l2mc_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_l2mc_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_l2mc_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_l2mc_entry_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_l2mcgroup.cpp b/unittest/proxylib/test_sai_proxy_l2mcgroup.cpp new file mode 100644 index 000000000..0c92d1bae --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_l2mcgroup.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, l2mc_group) +{ + sai_l2mc_group_api_t *api = nullptr; + + sai_api_query(SAI_API_L2MC_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_l2mc_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_l2mc_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_l2mc_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_l2mc_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_l2mc_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_l2mc_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_l2mc_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_l2mc_group_member_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_lag.cpp b/unittest/proxylib/test_sai_proxy_lag.cpp new file mode 100644 index 000000000..0cad93689 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_lag.cpp @@ -0,0 +1,31 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, lag) +{ + sai_lag_api_t *api = nullptr; + + sai_api_query(SAI_API_LAG, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_lag(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_lag(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_lag_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_lag_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_lag_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_lag_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_lag_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_lag_member_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_lag_members(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_lag_members(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_macsec.cpp b/unittest/proxylib/test_sai_proxy_macsec.cpp new file mode 100644 index 000000000..c05eed1f3 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_macsec.cpp @@ -0,0 +1,59 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, macsec) +{ + sai_macsec_api_t *api = nullptr; + + sai_api_query(SAI_API_MACSEC, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_macsec(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_macsec(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_macsec_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_macsec_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_macsec_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_macsec_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_port_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_port_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_port_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_macsec_port_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_macsec_flow(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_macsec_flow(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_macsec_flow_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_flow_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_flow_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_flow_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_macsec_flow_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_macsec_sc(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_macsec_sc(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_macsec_sc_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sc_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sc_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sc_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_macsec_sc_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_macsec_sa(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_macsec_sa(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_macsec_sa_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sa_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sa_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_macsec_sa_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_macsec_sa_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_mcastfdb.cpp b/unittest/proxylib/test_sai_proxy_mcastfdb.cpp new file mode 100644 index 000000000..0514918f8 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_mcastfdb.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, mcast_fdb) +{ + sai_mcast_fdb_api_t *api = nullptr; + + sai_api_query(SAI_API_MCAST_FDB, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_mcast_fdb_entry_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_mcast_fdb_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_mcast_fdb_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_mcast_fdb_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_mcast_fdb_entry_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_mirror.cpp b/unittest/proxylib/test_sai_proxy_mirror.cpp new file mode 100644 index 000000000..115e02ae3 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_mirror.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, mirror) +{ + sai_mirror_api_t *api = nullptr; + + sai_api_query(SAI_API_MIRROR, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_mirror_session(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_mirror_session(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_mirror_session_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_mirror_session_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_mpls.cpp b/unittest/proxylib/test_sai_proxy_mpls.cpp new file mode 100644 index 000000000..40339c97b --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_mpls.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, mpls) +{ + sai_mpls_api_t *api = nullptr; + + sai_api_query(SAI_API_MPLS, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_inseg_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_inseg_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_inseg_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_inseg_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_inseg_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_inseg_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_inseg_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_inseg_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_inseg_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_nat.cpp b/unittest/proxylib/test_sai_proxy_nat.cpp new file mode 100644 index 000000000..8c5e3d40c --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_nat.cpp @@ -0,0 +1,35 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, nat) +{ + sai_nat_api_t *api = nullptr; + + sai_api_query(SAI_API_NAT, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_nat_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + sai_object_id_t id1; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_nat_zone_counter(&id1,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_nat_zone_counter(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_nat_zone_counter_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_nat_zone_counter_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_neighbor.cpp b/unittest/proxylib/test_sai_proxy_neighbor.cpp new file mode 100644 index 000000000..2c44be0b0 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_neighbor.cpp @@ -0,0 +1,25 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, neighbor) +{ + sai_neighbor_api_t *api = nullptr; + + sai_api_query(SAI_API_NEIGHBOR, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_neighbor_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_neighbor_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_neighbor_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_neighbor_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_neighbor_entry_attribute(0,0,0)); + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->remove_all_neighbor_entries(0)); +} diff --git a/unittest/proxylib/test_sai_proxy_nexthop.cpp b/unittest/proxylib/test_sai_proxy_nexthop.cpp new file mode 100644 index 000000000..fd5b5399e --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_nexthop.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, next_hop) +{ + sai_next_hop_api_t *api = nullptr; + + sai_api_query(SAI_API_NEXT_HOP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_next_hop(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_next_hop(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_next_hop_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_next_hop_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_nexthopgroup.cpp b/unittest/proxylib/test_sai_proxy_nexthopgroup.cpp new file mode 100644 index 000000000..87c40847d --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_nexthopgroup.cpp @@ -0,0 +1,36 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, next_hop_group) +{ + sai_next_hop_group_api_t *api = nullptr; + + sai_api_query(SAI_API_NEXT_HOP_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_next_hop_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_next_hop_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_next_hop_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_next_hop_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_next_hop_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_next_hop_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_next_hop_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_next_hop_group_member_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_next_hop_group_members(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_next_hop_group_members(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_next_hop_group_map(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_next_hop_group_map(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_next_hop_group_map_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_next_hop_group_map_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_poe.cpp b/unittest/proxylib/test_sai_proxy_poe.cpp new file mode 100644 index 000000000..efa7ab2c5 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_poe.cpp @@ -0,0 +1,33 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, poe) +{ + sai_poe_api_t *api = nullptr; + + sai_api_query(SAI_API_POE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_device(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_device(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_device_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_device_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_pse(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_pse(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_pse_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_pse_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_poe_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_poe_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_poe_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_poe_port_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_policer.cpp b/unittest/proxylib/test_sai_proxy_policer.cpp new file mode 100644 index 000000000..da8ef45ae --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_policer.cpp @@ -0,0 +1,27 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, policer) +{ + sai_policer_api_t *api = nullptr; + + sai_api_query(SAI_API_POLICER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_policer(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_policer(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_policer_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_policer_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_policer_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_policer_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_policer_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_port.cpp b/unittest/proxylib/test_sai_proxy_port.cpp new file mode 100644 index 000000000..f24877bc3 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_port.cpp @@ -0,0 +1,48 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, port) +{ + sai_port_api_t *api = nullptr; + + sai_api_query(SAI_API_PORT, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_port_stats(0,0,0)); + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->clear_port_all_stats(0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_pool(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_pool(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_pool_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_pool_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_port_pool_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_connector(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_connector(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_connector_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_connector_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_port_serdes(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_port_serdes(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_port_serdes_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_port_serdes_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_qosmap.cpp b/unittest/proxylib/test_sai_proxy_qosmap.cpp new file mode 100644 index 000000000..3dd3811d0 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_qosmap.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, qos_map) +{ + sai_qos_map_api_t *api = nullptr; + + sai_api_query(SAI_API_QOS_MAP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_qos_map(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_qos_map(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_qos_map_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_qos_map_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_queue.cpp b/unittest/proxylib/test_sai_proxy_queue.cpp new file mode 100644 index 000000000..c230ca56a --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_queue.cpp @@ -0,0 +1,27 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, queue) +{ + sai_queue_api_t *api = nullptr; + + sai_api_query(SAI_API_QUEUE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_queue(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_queue(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_queue_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_queue_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_queue_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_queue_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_queue_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_route.cpp b/unittest/proxylib/test_sai_proxy_route.cpp new file mode 100644 index 000000000..f7369b159 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_route.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, route) +{ + sai_route_api_t *api = nullptr; + + sai_api_query(SAI_API_ROUTE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_route_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_route_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_route_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_route_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_route_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_route_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_route_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_route_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_route_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_router_interface.cpp b/unittest/proxylib/test_sai_proxy_router_interface.cpp new file mode 100644 index 000000000..0dbd98fac --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_router_interface.cpp @@ -0,0 +1,27 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, router_interface) +{ + sai_router_interface_api_t *api = nullptr; + + sai_api_query(SAI_API_ROUTER_INTERFACE, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_router_interface(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_router_interface(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_router_interface_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_router_interface_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_router_interface_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_router_interface_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_router_interface_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_router_rpfgroup.cpp b/unittest/proxylib/test_sai_proxy_router_rpfgroup.cpp new file mode 100644 index 000000000..362c20f35 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_router_rpfgroup.cpp @@ -0,0 +1,28 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, rpf_group) +{ + sai_rpf_group_api_t *api = nullptr; + + sai_api_query(SAI_API_RPF_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_rpf_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_rpf_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_rpf_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_rpf_group_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_rpf_group_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_rpf_group_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_rpf_group_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_rpf_group_member_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_router_samplepacket.cpp b/unittest/proxylib/test_sai_proxy_router_samplepacket.cpp new file mode 100644 index 000000000..1bec595d8 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_router_samplepacket.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, samplepacket) +{ + sai_samplepacket_api_t *api = nullptr; + + sai_api_query(SAI_API_SAMPLEPACKET, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_samplepacket(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_samplepacket(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_samplepacket_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_samplepacket_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_scheduler.cpp b/unittest/proxylib/test_sai_proxy_scheduler.cpp new file mode 100644 index 000000000..e1b2a77fe --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_scheduler.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, scheduler) +{ + sai_scheduler_api_t *api = nullptr; + + sai_api_query(SAI_API_SCHEDULER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_scheduler(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_scheduler(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_scheduler_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_scheduler_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_schedulergroup.cpp b/unittest/proxylib/test_sai_proxy_schedulergroup.cpp new file mode 100644 index 000000000..48e581220 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_schedulergroup.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, scheduler_group) +{ + sai_scheduler_group_api_t *api = nullptr; + + sai_api_query(SAI_API_SCHEDULER_GROUP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_scheduler_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_scheduler_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_scheduler_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_scheduler_group_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_srv6.cpp b/unittest/proxylib/test_sai_proxy_srv6.cpp new file mode 100644 index 000000000..d8ba0f748 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_srv6.cpp @@ -0,0 +1,36 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, srv6) +{ + sai_srv6_api_t *api = nullptr; + + sai_api_query(SAI_API_SRV6, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t obj_id; + sai_my_sid_entry_t id ; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_srv6_sidlist(&obj_id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_srv6_sidlist(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_srv6_sidlist_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_srv6_sidlist_attribute(0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_srv6_sidlists(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_srv6_sidlists(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_my_sid_entry(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_my_sid_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_my_sid_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_my_sid_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_my_sid_entries(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_my_sid_entries(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_my_sid_entries_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_my_sid_entries_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_stp.cpp b/unittest/proxylib/test_sai_proxy_stp.cpp new file mode 100644 index 000000000..4be8b2053 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_stp.cpp @@ -0,0 +1,31 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, stp) +{ + sai_stp_api_t *api = nullptr; + + sai_api_query(SAI_API_STP, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_stp(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_stp(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_stp_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_stp_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_stp_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_stp_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_stp_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_stp_port_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_stp_ports(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_stp_ports(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_switch.cpp b/unittest/proxylib/test_sai_proxy_switch.cpp new file mode 100644 index 000000000..b78ad7ac5 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_switch.cpp @@ -0,0 +1,35 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, switch) +{ + sai_switch_api_t *api = nullptr; + + sai_api_query(SAI_API_SWITCH, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_switch(&id,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_switch(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_switch_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_switch_stats(0,0,0)); + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->switch_mdio_read(0,0,0,0,0)); + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, api->switch_mdio_write(0,0,0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_switch_tunnel(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_switch_tunnel(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_switch_tunnel_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_switch_tunnel_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_system_port.cpp b/unittest/proxylib/test_sai_proxy_system_port.cpp new file mode 100644 index 000000000..ed4b3ac5a --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_system_port.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, system_port) +{ + sai_system_port_api_t *api = nullptr; + + sai_api_query(SAI_API_SYSTEM_PORT, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_system_port(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_system_port(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_system_port_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_system_port_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_tam.cpp b/unittest/proxylib/test_sai_proxy_tam.cpp new file mode 100644 index 000000000..7b5dfe048 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_tam.cpp @@ -0,0 +1,85 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, tam) +{ + sai_tam_api_t *api = nullptr; + + sai_api_query(SAI_API_TAM, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_math_func(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_math_func(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_math_func_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_math_func_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_report(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_report(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_report_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_report_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_event_threshold(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_event_threshold(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_event_threshold_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_event_threshold_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_int(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_int(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_int_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_int_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_tel_type(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_tel_type(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_tel_type_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_tel_type_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_transport(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_transport(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_transport_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_transport_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_telemetry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_telemetry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_telemetry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_telemetry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_collector(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_collector(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_collector_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_collector_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_event_action(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_event_action(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_event_action_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_event_action_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_event(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_event(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_event_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_event_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tam_counter_subscription(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tam_counter_subscription(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tam_counter_subscription_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_counter_subscription_attribute(0,0,0)); +} + +TEST(libsaiproxy, sai_tam_telemetry_get_data) +{ + sai_object_list_t list; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_tam_telemetry_get_data(0,list,0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_tunnel.cpp b/unittest/proxylib/test_sai_proxy_tunnel.cpp new file mode 100644 index 000000000..190cb63fa --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_tunnel.cpp @@ -0,0 +1,49 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, tunnel) +{ + sai_tunnel_api_t *api = nullptr; + + sai_api_query(SAI_API_TUNNEL, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tunnel_map(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tunnel_map(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tunnel_map_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_map_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tunnel(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tunnel(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tunnel_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_tunnel_stats(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tunnel_term_table_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tunnel_term_table_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tunnel_term_table_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_term_table_entry_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_tunnel_map_entry(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_tunnel_map_entry(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tunnel_map_entry_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnel_map_entry_attribute(0,0,0)); + + uint32_t attr_count = 0; + sai_status_t status = 0; + sai_attribute_t *p_attr = nullptr; + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tunnels_attribute(0,&id,&attr_count,&p_attr,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,&status)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_tunnels_attribute(0,&id,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,&status)); +} + diff --git a/unittest/proxylib/test_sai_proxy_udf.cpp b/unittest/proxylib/test_sai_proxy_udf.cpp new file mode 100644 index 000000000..1549a56f8 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_udf.cpp @@ -0,0 +1,33 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, udf) +{ + sai_udf_api_t *api = nullptr; + + sai_api_query(SAI_API_UDF, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_udf(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_udf(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_udf_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_udf_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_udf_match(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_udf_match(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_udf_match_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_udf_match_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_udf_group(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_udf_group(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_udf_group_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_udf_group_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_virtual_router.cpp b/unittest/proxylib/test_sai_proxy_virtual_router.cpp new file mode 100644 index 000000000..0e7b213a9 --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_virtual_router.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, virtual_router) +{ + sai_virtual_router_api_t *api = nullptr; + + sai_api_query(SAI_API_VIRTUAL_ROUTER, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_virtual_router(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_virtual_router(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_virtual_router_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_virtual_router_attribute(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_vlan.cpp b/unittest/proxylib/test_sai_proxy_vlan.cpp new file mode 100644 index 000000000..fddf914bf --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_vlan.cpp @@ -0,0 +1,35 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, vlan) +{ + sai_vlan_api_t *api = nullptr; + + sai_api_query(SAI_API_VLAN, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vlan(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vlan(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_vlan_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vlan_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vlan_member(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vlan_member(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_vlan_member_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vlan_member_attribute(0,0,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_vlan_members(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_vlan_members(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); + + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vlan_stats(0,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_vlan_stats_ext(0,0,0,SAI_STATS_MODE_READ,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->clear_vlan_stats(0,0,0)); +} diff --git a/unittest/proxylib/test_sai_proxy_wred.cpp b/unittest/proxylib/test_sai_proxy_wred.cpp new file mode 100644 index 000000000..de00c4a9c --- /dev/null +++ b/unittest/proxylib/test_sai_proxy_wred.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { +#include "sai.h" +} + +#include "swss/logger.h" + +TEST(libsaiproxy, wred) +{ + sai_wred_api_t *api = nullptr; + + sai_api_query(SAI_API_WRED, (void**)&api); + + EXPECT_NE(api, nullptr); + + sai_object_id_t id; + + EXPECT_NE(SAI_STATUS_SUCCESS, api->create_wred(&id,0,0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_wred(0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->set_wred_attribute(0,0)); + EXPECT_NE(SAI_STATUS_SUCCESS, api->get_wred_attribute(0,0,0)); +} diff --git a/unittest/vslib/test_sai_vs_poe.cpp b/unittest/vslib/test_sai_vs_poe.cpp index a79deaa27..03ec57601 100644 --- a/unittest/vslib/test_sai_vs_poe.cpp +++ b/unittest/vslib/test_sai_vs_poe.cpp @@ -6,7 +6,7 @@ extern "C" { #include "swss/logger.h" -TEST(libsairedis, poe) +TEST(libsaivs, poe) { sai_poe_api_t *api = nullptr; diff --git a/unittest/vslib/test_sai_vs_tam.cpp b/unittest/vslib/test_sai_vs_tam.cpp index f879977f7..c77ccd35f 100644 --- a/unittest/vslib/test_sai_vs_tam.cpp +++ b/unittest/vslib/test_sai_vs_tam.cpp @@ -77,7 +77,7 @@ TEST(libsaivs, tam) EXPECT_NE(SAI_STATUS_SUCCESS, api->get_tam_counter_subscription_attribute(0,0,0)); } -TEST(libsairedis, sai_tam_telemetry_get_data) +TEST(libsaivs, sai_tam_telemetry_get_data) { sai_object_list_t list;