diff --git a/.azure-pipelines/build-swss-template.yml b/.azure-pipelines/build-swss-template.yml index 59d46ce99..54cd78e2c 100644 --- a/.azure-pipelines/build-swss-template.yml +++ b/.azure-pipelines/build-swss-template.yml @@ -137,8 +137,7 @@ jobs: path: $(Build.ArtifactStagingDirectory)/download patterns: | libdashapi*.deb - displayName: "Download dash api" - + displayName: "Download dash api test" - script: | set -ex # install libyang before install libswsscommon diff --git a/.azure-pipelines/build-template.yml b/.azure-pipelines/build-template.yml index 3e5a1417a..9ba2d9531 100644 --- a/.azure-pipelines/build-template.yml +++ b/.azure-pipelines/build-template.yml @@ -98,7 +98,7 @@ jobs: sudo mkdir -m 755 /var/run/sswsyncd sudo apt-get install -y rsyslog - sudo service rsyslog start + sudo rsyslogd cat /etc/apt/sources.list dpkg --list | grep libnl @@ -167,7 +167,8 @@ jobs: displayName: "Compile sonic sairedis with coverage enabled" - script: | sudo cp azsyslog.conf /etc/rsyslog.conf - sudo service rsyslog restart + sudo killall rsyslogd + sudo rsyslogd displayName: "Update rsyslog.conf" - ${{ if eq(parameters.run_unit_test, true) }}: - script: | diff --git a/.azure-pipelines/test-docker-sonic-vs-template.yml b/.azure-pipelines/test-docker-sonic-vs-template.yml index e4939d3db..8b2292962 100644 --- a/.azure-pipelines/test-docker-sonic-vs-template.yml +++ b/.azure-pipelines/test-docker-sonic-vs-template.yml @@ -81,7 +81,7 @@ jobs: # install packages for vs test sudo apt-get install -y net-tools bridge-utils vlan sudo apt-get install -y python3-pip - sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker>=4.4.1 redis==3.3.4 flaky==3.7.0 + sudo pip3 install pytest==4.6.2 attrs==19.1.0 exabgp==4.0.10 distro==1.5.0 docker>=4.4.1 redis==3.3.4 flaky==3.7.0 requests==2.31.0 displayName: "Install dependencies" - script: | diff --git a/.gitignore b/.gitignore index f2dceea04..8c96ced02 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.so *.pyc *_wrap.cpp +*.bak # Packaging Files # ################### @@ -58,6 +59,10 @@ stamp-h1 python/build/ python/setup.py +lib/sai_redis.cpp +vslib/sai_vs.cpp +proxylib/sai_proxy.cpp + # Test Files # ############## meta/test-suite.log @@ -111,7 +116,11 @@ unittest/meta/tests unittest/syncd/tests unittest/vslib/tests unittest/vslib/testslibsaivs +unittest/proxylib/tests +unittest/proxylib/testslibsaiproxy vslib/tests +stub/tests +unittest/stub/stub/testslibsaistub # Temporary files # ################### diff --git a/Makefile.am b/Makefile.am index efea0003d..6661ff163 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = meta lib vslib pyext +SUBDIRS = meta lib vslib proxylib pyext if SYNCD SUBDIRS += syncd saiplayer saidump saidiscovery saisdkdump saiasiccmp tests unittest diff --git a/SAI b/SAI index 96143eef4..0788e82e8 160000 --- a/SAI +++ b/SAI @@ -1 +1 @@ -Subproject commit 96143eef4a662b720038a10e68d7d702370dc20a +Subproject commit 0788e82e8ca56b82eb8f8c0a3dee40edbc2ba9ba diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0a7bf62d5..79f3989ae 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,6 +101,42 @@ stages: syslog_artifact_name: sonic-sairedis.syslog.arm64 debian_version: ${{ parameters.debian_version }} +- stage: BuildBookworm + dependsOn: BuildArm + condition: succeeded('BuildArm') + jobs: + - template: .azure-pipelines/build-template.yml + parameters: + arch: amd64 + sonic_slave: sonic-slave-bookworm + swss_common_artifact_name: sonic-swss-common-bookworm + artifact_name: sonic-sairedis-bookworm + syslog_artifact_name: sonic-sairedis-bookworm.syslog + run_unit_test: true + debian_version: ${{ parameters.debian_version }} + + - template: .azure-pipelines/build-template.yml + parameters: + arch: armhf + timeout: 180 + pool: sonicbld-armhf + sonic_slave: sonic-slave-bookworm-armhf + swss_common_artifact_name: sonic-swss-common-bookworm.armhf + artifact_name: sonic-sairedis-bookworm.armhf + syslog_artifact_name: sonic-sairedis-bookworm.syslog.armhf + debian_version: ${{ parameters.debian_version }} + + - template: .azure-pipelines/build-template.yml + parameters: + arch: arm64 + timeout: 180 + pool: sonicbld-arm64 + sonic_slave: sonic-slave-bookworm-arm64 + swss_common_artifact_name: sonic-swss-common-bookworm.arm64 + artifact_name: sonic-sairedis-bookworm.arm64 + syslog_artifact_name: sonic-sairedis-bookworm.syslog.arm64 + debian_version: ${{ parameters.debian_version }} + - stage: BuildSwss dependsOn: Build condition: succeeded('Build') diff --git a/configure.ac b/configure.ac index 6f5854b93..43fe79fab 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,11 @@ AC_ARG_WITH(sai, esac]) AM_CONDITIONAL(SAIVS, test x$sai = xvs) +AC_ARG_WITH(dashsai, + [ --with-dashsai compiling against DASH SAI], + [AM_CONDITIONAL(DASHSAI, true)], + [AM_CONDITIONAL(DASHSAI, false)]) + AC_ARG_WITH(swss-common-inc, [ --with-swss-common-inc=DIR prefix where swss-common includes are installed], @@ -113,6 +118,7 @@ if test "x$asan_enabled" = "xtrue"; then CFLAGS_ASAN+=" -fsanitize=address" CFLAGS_ASAN+=" -DASAN_ENABLED" CFLAGS_ASAN+=" -ggdb -fno-omit-frame-pointer -U_FORTIFY_SOURCE" + CFLAGS_ASAN+=" -Wno-maybe-uninitialized" AC_SUBST(CFLAGS_ASAN) LDFLAGS_ASAN+=" -lasan" @@ -284,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/debian/rules b/debian/rules index b872e8062..f8df60575 100755 --- a/debian/rules +++ b/debian/rules @@ -37,6 +37,9 @@ endif ifneq ($(filter syncd,$(DEB_BUILD_PROFILES)),) ifneq ($(filter vs,$(DEB_BUILD_PROFILES)),) configure_opts += --with-sai=vs +ifneq ($(filter dashsai,$(DEB_BUILD_PROFILES)),) +configure_opts += --with-dashsai +endif endif else configure_opts += --disable-syncd @@ -52,7 +55,7 @@ endif # -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) override_dh_auto_configure: - dh_auto_configure -- ${SWSS_COMMON_CONFIG} $(configure_opts) + dh_auto_configure -- ${SWSS_COMMON_CONFIG} $(configure_opts) $(DEB_CONFIGURE_EXTRA_FLAGS) override_dh_install: ifneq ($(filter rpc,$(DEB_BUILD_PROFILES)),) diff --git a/lib/ClientSai.cpp b/lib/ClientSai.cpp index 809f50e73..74e09a3a8 100644 --- a/lib/ClientSai.cpp +++ b/lib/ClientSai.cpp @@ -46,11 +46,11 @@ ClientSai::~ClientSai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } -sai_status_t ClientSai::initialize( +sai_status_t ClientSai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -91,7 +91,7 @@ sai_status_t ClientSai::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t ClientSai::uninitialize(void) +sai_status_t ClientSai::apiUninitialize(void) { SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); @@ -433,6 +433,26 @@ sai_status_t ClientSai::bulkSet( SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY) +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t ClientSai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + REDIS_CHECK_API_INITIALIZED(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY) + // QUAD API HELPERS sai_status_t ClientSai::create( @@ -814,7 +834,7 @@ sai_status_t ClientSai::waitForQueryAttributeCapabilityResponse( // QUERY ATTRIBUTE ENUM CAPABILITY -sai_status_t ClientSai::queryAattributeEnumValuesCapability( +sai_status_t ClientSai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -1337,6 +1357,26 @@ sai_status_t ClientSai::bulkSet( return waitForBulkResponse(SAI_COMMON_API_BULK_SET, (uint32_t)serialized_object_ids.size(), object_statuses); } +// BULK GET + +sai_status_t ClientSai::bulkGet( + _In_ sai_object_type_t object_type, + _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) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + // BULK RESPONSE HELPERS sai_status_t ClientSai::waitForBulkResponse( @@ -1497,3 +1537,15 @@ sai_status_t ClientSai::logSet( return SAI_STATUS_SUCCESS; } + +sai_status_t ClientSai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("queryApiVersion not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} diff --git a/lib/ClientSai.h b/lib/ClientSai.h index 05d0f5888..cbe6a3204 100644 --- a/lib/ClientSai.h +++ b/lib/ClientSai.h @@ -26,11 +26,11 @@ namespace sairedis public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -88,6 +88,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -159,7 +168,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -175,6 +184,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: // QUAD API helpers sai_status_t create( diff --git a/lib/ClientServerSai.cpp b/lib/ClientServerSai.cpp index 60366aaef..e3a9f808e 100644 --- a/lib/ClientServerSai.cpp +++ b/lib/ClientServerSai.cpp @@ -29,13 +29,13 @@ ClientServerSai::~ClientServerSai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } // INITIALIZE UNINITIALIZE -sai_status_t ClientServerSai::initialize( +sai_status_t ClientServerSai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -82,7 +82,7 @@ sai_status_t ClientServerSai::initialize( m_sai = std::make_shared(); } - auto status = m_sai->initialize(flags, service_method_table); + auto status = m_sai->apiInitialize(flags, service_method_table); SWSS_LOG_NOTICE("init client/server sai: %s", sai_serialize_status(status).c_str()); @@ -94,7 +94,7 @@ sai_status_t ClientServerSai::initialize( return status; } -sai_status_t ClientServerSai::uninitialize(void) +sai_status_t ClientServerSai::apiUninitialize(void) { SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); @@ -414,6 +414,22 @@ sai_status_t ClientServerSai::bulkSet( object_statuses); } +sai_status_t ClientServerSai::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + // BULK QUAD ENTRY #define DECLARE_BULK_CREATE_ENTRY(OT,ot) \ @@ -483,6 +499,26 @@ sai_status_t ClientServerSai::bulkSet( \ SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t ClientServerSai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + REDIS_CHECK_API_INITIALIZED(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + // NON QUAD API sai_status_t ClientServerSai::flushFdbEntries( @@ -535,7 +571,7 @@ sai_status_t ClientServerSai::queryAttributeCapability( capability); } -sai_status_t ClientServerSai::queryAattributeEnumValuesCapability( +sai_status_t ClientServerSai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -545,7 +581,7 @@ sai_status_t ClientServerSai::queryAattributeEnumValuesCapability( SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); - return m_sai->queryAattributeEnumValuesCapability( + return m_sai->queryAttributeEnumValuesCapability( switch_id, object_type, attr_id, @@ -592,3 +628,13 @@ sai_status_t ClientServerSai::logSet( return m_sai->logSet(api, log_level); } + +sai_status_t ClientServerSai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + return m_sai->queryApiVersion(version); +} diff --git a/lib/ClientServerSai.h b/lib/ClientServerSai.h index db6c2460c..a9163252d 100644 --- a/lib/ClientServerSai.h +++ b/lib/ClientServerSai.h @@ -18,11 +18,11 @@ namespace sairedis public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -80,6 +80,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -151,7 +160,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -167,6 +176,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: bool m_apiInitialized; diff --git a/lib/Context.cpp b/lib/Context.cpp index a5cecf528..a03b3bed7 100644 --- a/lib/Context.cpp +++ b/lib/Context.cpp @@ -32,7 +32,7 @@ Context::~Context() { SWSS_LOG_ENTER(); - m_redisSai->uninitialize(); // will stop threads + m_redisSai->apiUninitialize(); // will stop threads m_redisSai = nullptr; diff --git a/lib/Makefile.am b/lib/Makefile.am index 46471b89b..7b9e44a92 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -28,69 +28,15 @@ libSaiRedis_a_SOURCES = \ VirtualObjectIdManager.cpp \ ZeroMQChannel.cpp -libsairedis_la_SOURCES = \ - sai_redis_acl.cpp \ - sai_redis_bfd.cpp \ - sai_redis_bmtor.cpp \ - sai_redis_bridge.cpp \ - sai_redis_buffer.cpp \ - sai_redis_counter.cpp \ - sai_redis_dash_vip.cpp \ - sai_redis_dash_pa_validation.cpp \ - sai_redis_dash_vnet.cpp \ - sai_redis_dash_outbound_routing.cpp \ - sai_redis_dash_outbound_ca_to_pa.cpp \ - sai_redis_dash_inbound_routing.cpp \ - sai_redis_dash_eni.cpp \ - sai_redis_dash_direction_lookup.cpp \ - sai_redis_dash_acl.cpp \ - sai_redis_debug_counter.cpp \ - sai_redis_dtel.cpp \ - sai_redis_fdb.cpp \ - sai_redis_genericprogrammable.cpp \ - sai_redis_hash.cpp \ - sai_redis_hostif.cpp \ - sai_redis_interfacequery.cpp \ - sai_redis_ipmc.cpp \ - sai_redis_ipmc_group.cpp \ - sai_redis_isolation_group.cpp \ - sai_redis_l2mc.cpp \ - sai_redis_l2mcgroup.cpp \ - sai_redis_lag.cpp \ - sai_redis_macsec.cpp \ - sai_redis_mcastfdb.cpp \ - sai_redis_mirror.cpp \ - sai_redis_mpls.cpp \ - sai_redis_nat.cpp \ - sai_redis_neighbor.cpp \ - sai_redis_nexthop.cpp \ - sai_redis_nexthopgroup.cpp \ - sai_redis_policer.cpp \ - sai_redis_port.cpp \ - sai_redis_qosmap.cpp \ - sai_redis_queue.cpp \ - sai_redis_route.cpp \ - sai_redis_router_interface.cpp \ - sai_redis_rpfgroup.cpp \ - sai_redis_samplepacket.cpp \ - sai_redis_scheduler.cpp \ - sai_redis_schedulergroup.cpp \ - sai_redis_srv6.cpp \ - sai_redis_stp.cpp \ - sai_redis_switch.cpp \ - sai_redis_system_port.cpp \ - sai_redis_tam.cpp \ - sai_redis_tunnel.cpp \ - sai_redis_udf.cpp \ - sai_redis_virtual_router.cpp \ - sai_redis_vlan.cpp \ - sai_redis_wred.cpp \ - sai_redis_ipsec.cpp \ - sai_redis_my_mac.cpp \ - sai_redis_ars.cpp \ - sai_redis_ars_profile.cpp \ - sai_redis_twamp.cpp \ - sai_redis_dash_meter.cpp +BUILT_SOURCES = sai_redis.cpp + +sai_redis.cpp: ../stub.pl $(top_srcdir)/SAI/meta/saimetadata.c + ../stub.pl -d ../SAI/ -c ClientServerSai -n sairedis -f sai_redis.cpp -s stub + +clean-local: + rm -f sai_redis.cpp + +libsairedis_la_SOURCES = sai_redis.cpp libSaiRedis_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) libSaiRedis_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) diff --git a/lib/Recorder.cpp b/lib/Recorder.cpp index 32bc2d0d8..6c9ebd721 100644 --- a/lib/Recorder.cpp +++ b/lib/Recorder.cpp @@ -1016,7 +1016,7 @@ void Recorder::recordQueryAttributeCapabilityResponse( recordQueryAttributeCapabilityResponse(status, values); } -void Recorder::recordQueryAattributeEnumValuesCapability( +void Recorder::recordQueryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -1053,7 +1053,7 @@ void Recorder::recordQueryAattributeEnumValuesCapability( recordQueryAttributeEnumValuesCapability(key, values); } -void Recorder::recordQueryAattributeEnumValuesCapabilityResponse( +void Recorder::recordQueryAttributeEnumValuesCapabilityResponse( _In_ sai_status_t status, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, diff --git a/lib/Recorder.h b/lib/Recorder.h index ccda2bacb..920ee0c7f 100644 --- a/lib/Recorder.h +++ b/lib/Recorder.h @@ -341,13 +341,13 @@ namespace sairedis _In_ sai_attr_id_t attrId, _In_ const sai_attr_capability_t* capability); - void recordQueryAattributeEnumValuesCapability( + void recordQueryAttributeEnumValuesCapability( _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); - void recordQueryAattributeEnumValuesCapabilityResponse( + void recordQueryAttributeEnumValuesCapabilityResponse( _In_ sai_status_t status, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, diff --git a/lib/RedisRemoteSaiInterface.cpp b/lib/RedisRemoteSaiInterface.cpp index a789235e4..1c846fe5a 100644 --- a/lib/RedisRemoteSaiInterface.cpp +++ b/lib/RedisRemoteSaiInterface.cpp @@ -43,7 +43,7 @@ RedisRemoteSaiInterface::RedisRemoteSaiInterface( m_initialized = false; - initialize(0, nullptr); + apiInitialize(0, nullptr); } RedisRemoteSaiInterface::~RedisRemoteSaiInterface() @@ -52,11 +52,11 @@ RedisRemoteSaiInterface::~RedisRemoteSaiInterface() if (m_initialized) { - uninitialize(); + apiUninitialize(); } } -sai_status_t RedisRemoteSaiInterface::initialize( +sai_status_t RedisRemoteSaiInterface::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -109,7 +109,7 @@ sai_status_t RedisRemoteSaiInterface::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t RedisRemoteSaiInterface::uninitialize(void) +sai_status_t RedisRemoteSaiInterface::apiUninitialize(void) { SWSS_LOG_ENTER(); @@ -476,6 +476,14 @@ sai_status_t RedisRemoteSaiInterface::setRedisExtensionAttribute( return SAI_STATUS_SUCCESS; + case SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP: + return notifyCounterGroupOperations(objectId, + reinterpret_cast(attr->value.ptr)); + + case SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER: + return notifyCounterOperations(objectId, + reinterpret_cast(attr->value.ptr)); + default: break; } @@ -485,6 +493,126 @@ sai_status_t RedisRemoteSaiInterface::setRedisExtensionAttribute( return SAI_STATUS_FAILURE; } +bool RedisRemoteSaiInterface::isSaiS8ListValidString( + _In_ const sai_s8_list_t &s8list) +{ + SWSS_LOG_ENTER(); + + if (s8list.list != nullptr && s8list.count > 0) + { + size_t len = strnlen((const char *)s8list.list, s8list.count); + + if (len == (size_t)s8list.count) + { + return true; + } + else + { + SWSS_LOG_ERROR("Count (%u) is different than strnlen (%zu)", s8list.count, len); + } + } + + return false; +} + +bool RedisRemoteSaiInterface::emplaceStrings( + _In_ const sai_s8_list_t &field, + _In_ const sai_s8_list_t &value, + _Out_ std::vector &entries) +{ + SWSS_LOG_ENTER(); + + bool result = false; + + if (isSaiS8ListValidString(field) && isSaiS8ListValidString(value)) + { + entries.emplace_back(std::string((const char*)field.list, field.count), std::string((const char*)value.list, value.count)); + result = true; + } + + return result; +} + +bool RedisRemoteSaiInterface::emplaceStrings( + _In_ const char *field, + _In_ const sai_s8_list_t &value, + _Out_ std::vector &entries) +{ + SWSS_LOG_ENTER(); + + bool result = false; + + if (isSaiS8ListValidString(value)) + { + entries.emplace_back(field, std::string((const char*)value.list, value.count)); + result = true; + } + + return result; +} + +sai_status_t RedisRemoteSaiInterface::notifyCounterGroupOperations( + _In_ sai_object_id_t objectId, + _In_ const sai_redis_flex_counter_group_parameter_t *flexCounterGroupParam) +{ + SWSS_LOG_ENTER(); + + std::vector entries; + + if (flexCounterGroupParam == nullptr || !isSaiS8ListValidString(flexCounterGroupParam->counter_group_name)) + { + SWSS_LOG_ERROR("Invalid parameters when handling counter group operation"); + return SAI_STATUS_FAILURE; + } + + std::string key((const char*)flexCounterGroupParam->counter_group_name.list, flexCounterGroupParam->counter_group_name.count); + + emplaceStrings(POLL_INTERVAL_FIELD, flexCounterGroupParam->poll_interval, entries); + emplaceStrings(STATS_MODE_FIELD, flexCounterGroupParam->stats_mode, entries); + emplaceStrings(flexCounterGroupParam->plugin_name, flexCounterGroupParam->plugins, entries); + emplaceStrings(FLEX_COUNTER_STATUS_FIELD, flexCounterGroupParam->operation, entries); + + m_recorder->recordGenericSet(key, entries); + + m_communicationChannel->set(key, + entries, + (entries.size() != 0) ? REDIS_FLEX_COUNTER_COMMAND_SET_GROUP : REDIS_FLEX_COUNTER_COMMAND_DEL_GROUP); + + return waitForResponse(SAI_COMMON_API_SET); +} + +sai_status_t RedisRemoteSaiInterface::notifyCounterOperations( + _In_ sai_object_id_t objectId, + _In_ const sai_redis_flex_counter_parameter_t *flexCounterParam) +{ + SWSS_LOG_ENTER(); + + if (flexCounterParam == nullptr || !isSaiS8ListValidString(flexCounterParam->counter_key)) + { + SWSS_LOG_ERROR("Invalid parameters when handling counter operation"); + return SAI_STATUS_FAILURE; + } + + std::vector entries; + std::string key((const char*)flexCounterParam->counter_key.list, flexCounterParam->counter_key.count); + std::string command; + + if (emplaceStrings(flexCounterParam->counter_field_name, flexCounterParam->counter_ids, entries)) + { + command = REDIS_FLEX_COUNTER_COMMAND_START_POLL; + emplaceStrings(STATS_MODE_FIELD, flexCounterParam->stats_mode, entries); + } + else + { + command = REDIS_FLEX_COUNTER_COMMAND_STOP_POLL; + } + + m_recorder->recordGenericSet(key, entries); + m_communicationChannel->set(key, entries, command); + + return waitForResponse(SAI_COMMON_API_SET); +} + sai_status_t RedisRemoteSaiInterface::set( _In_ sai_object_type_t objectType, _In_ sai_object_id_t objectId, @@ -650,6 +778,25 @@ sai_status_t RedisRemoteSaiInterface::bulkSet( SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t RedisRemoteSaiInterface::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + + sai_status_t RedisRemoteSaiInterface::create( _In_ sai_object_type_t object_type, _In_ const std::string& serializedObjectId, @@ -1054,7 +1201,7 @@ sai_status_t RedisRemoteSaiInterface::waitForQueryAttributeCapabilityResponse( return status; } -sai_status_t RedisRemoteSaiInterface::queryAattributeEnumValuesCapability( +sai_status_t RedisRemoteSaiInterface::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -1101,18 +1248,18 @@ sai_status_t RedisRemoteSaiInterface::queryAattributeEnumValuesCapability( // This query will not put any data into the ASIC view, just into the // message queue - m_recorder->recordQueryAattributeEnumValuesCapability(switchId, objectType, attrId, enumValuesCapability); + m_recorder->recordQueryAttributeEnumValuesCapability(switchId, objectType, attrId, enumValuesCapability); m_communicationChannel->set(switch_id_str, entry, REDIS_ASIC_STATE_COMMAND_ATTR_ENUM_VALUES_CAPABILITY_QUERY); - auto status = waitForQueryAattributeEnumValuesCapabilityResponse(enumValuesCapability); + auto status = waitForQueryAttributeEnumValuesCapabilityResponse(enumValuesCapability); - m_recorder->recordQueryAattributeEnumValuesCapabilityResponse(status, objectType, attrId, enumValuesCapability); + m_recorder->recordQueryAttributeEnumValuesCapabilityResponse(status, objectType, attrId, enumValuesCapability); return status; } -sai_status_t RedisRemoteSaiInterface::waitForQueryAattributeEnumValuesCapabilityResponse( +sai_status_t RedisRemoteSaiInterface::waitForQueryAttributeEnumValuesCapabilityResponse( _Inout_ sai_s32_list_t* enumValuesCapability) { SWSS_LOG_ENTER(); @@ -1507,6 +1654,22 @@ sai_status_t RedisRemoteSaiInterface::bulkSet( return waitForBulkResponse(SAI_COMMON_API_BULK_SET, (uint32_t)serialized_object_ids.size(), object_statuses); } +sai_status_t RedisRemoteSaiInterface::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t RedisRemoteSaiInterface::bulkCreate( _In_ sai_object_type_t object_type, _In_ sai_object_id_t switch_id, @@ -1726,6 +1889,27 @@ sai_status_t RedisRemoteSaiInterface::logSet( return SAI_STATUS_SUCCESS; } +sai_status_t RedisRemoteSaiInterface::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + 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 sairedis 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 RedisRemoteSaiInterface::sai_redis_notify_syncd( _In_ sai_object_id_t switchId, _In_ const sai_attribute_t *attr) diff --git a/lib/RedisRemoteSaiInterface.h b/lib/RedisRemoteSaiInterface.h index 8d5b01c1f..aa8c136cd 100644 --- a/lib/RedisRemoteSaiInterface.h +++ b/lib/RedisRemoteSaiInterface.h @@ -37,11 +37,11 @@ namespace sairedis public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - virtual sai_status_t uninitialize(void) override; + virtual sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -99,6 +99,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -170,7 +179,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -186,6 +195,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + public: // notify syncd virtual sai_status_t notifySyncd( @@ -319,7 +331,7 @@ namespace sairedis sai_status_t waitForQueryAttributeCapabilityResponse( _Out_ sai_attr_capability_t* capability); - sai_status_t waitForQueryAattributeEnumValuesCapabilityResponse( + sai_status_t waitForQueryAttributeEnumValuesCapabilityResponse( _Inout_ sai_s32_list_t* enumValuesCapability); sai_status_t waitForObjectTypeGetAvailabilityResponse( @@ -343,6 +355,27 @@ namespace sairedis _In_ sai_object_id_t objectId, _In_ const sai_attribute_t *attr); + bool isSaiS8ListValidString( + _In_ const sai_s8_list_t &s8list); + + bool emplaceStrings( + _In_ const sai_s8_list_t &field, + _In_ const sai_s8_list_t &value, + _Out_ std::vector &entries); + + bool emplaceStrings( + _In_ const char *field, + _In_ const sai_s8_list_t &value, + _Out_ std::vector &entries); + + sai_status_t notifyCounterGroupOperations( + _In_ sai_object_id_t objectId, + _In_ const sai_redis_flex_counter_group_parameter_t *flexCounterGroupParam); + + sai_status_t notifyCounterOperations( + _In_ sai_object_id_t objectId, + _In_ const sai_redis_flex_counter_parameter_t *flexCounterParam); + private: sai_status_t sai_redis_notify_syncd( diff --git a/lib/Sai.cpp b/lib/Sai.cpp index 15725dc24..6e45c2bf6 100644 --- a/lib/Sai.cpp +++ b/lib/Sai.cpp @@ -43,13 +43,13 @@ Sai::~Sai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } // INITIALIZE UNINITIALIZE -sai_status_t Sai::initialize( +sai_status_t Sai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -99,7 +99,7 @@ sai_status_t Sai::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t Sai::uninitialize(void) +sai_status_t Sai::apiUninitialize(void) { SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); @@ -503,6 +503,22 @@ sai_status_t Sai::bulkSet( object_statuses); } +sai_status_t Sai::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + // BULK QUAD ENTRY #define DECLARE_BULK_CREATE_ENTRY(OT,ot) \ @@ -578,6 +594,30 @@ sai_status_t Sai::bulkSet( \ SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t Sai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + REDIS_CHECK_API_INITIALIZED(); \ + REDIS_CHECK_POINTER(ot); \ + REDIS_CHECK_POINTER(attr_count); \ + REDIS_CHECK_POINTER(attr_list); \ + REDIS_CHECK_POINTER(object_statuses); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + // NON QUAD API sai_status_t Sai::flushFdbEntries( @@ -636,7 +676,7 @@ sai_status_t Sai::queryAttributeCapability( capability); } -sai_status_t Sai::queryAattributeEnumValuesCapability( +sai_status_t Sai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -647,7 +687,7 @@ sai_status_t Sai::queryAattributeEnumValuesCapability( REDIS_CHECK_API_INITIALIZED(); REDIS_CHECK_CONTEXT(switch_id); - return context->m_meta->queryAattributeEnumValuesCapability( + return context->m_meta->queryAttributeEnumValuesCapability( switch_id, object_type, attr_id, @@ -700,6 +740,31 @@ sai_status_t Sai::logSet( return SAI_STATUS_SUCCESS; } +sai_status_t Sai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + // TODO we should use specific context, but we don't know which one since + // there is no object ID parameter, we can use default context or cast + // version as context id same as passed in SAI_REDIS_SWITCH_ATTR_CONTEXT + // currently we will return just first context on context map, since + // user maybe not aware of trick with casting context + + for (auto&kvp: m_contextMap) + { + SWSS_LOG_WARN("using first context"); + + return kvp.second->m_meta->queryApiVersion(version); + } + + SWSS_LOG_ERROR("context map is empty"); + + return SAI_STATUS_FAILURE; +} + /* * NOTE: Notifications during switch create and switch remove. * diff --git a/lib/Sai.h b/lib/Sai.h index d92c43919..1b45c11e0 100644 --- a/lib/Sai.h +++ b/lib/Sai.h @@ -27,11 +27,11 @@ namespace sairedis public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -89,6 +89,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -160,7 +169,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -176,6 +185,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: sai_switch_notifications_t handle_notification( diff --git a/lib/ServerSai.cpp b/lib/ServerSai.cpp index 24bd4043a..6a8f5ad92 100644 --- a/lib/ServerSai.cpp +++ b/lib/ServerSai.cpp @@ -39,13 +39,13 @@ ServerSai::~ServerSai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } // INITIALIZE UNINITIALIZE -sai_status_t ServerSai::initialize( +sai_status_t ServerSai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -79,7 +79,7 @@ sai_status_t ServerSai::initialize( m_sai = std::make_shared(); // actual SAI to talk to syncd - auto status = m_sai->initialize(flags, service_method_table); + auto status = m_sai->apiInitialize(flags, service_method_table); SWSS_LOG_NOTICE("init client/server sai: %s", sai_serialize_status(status).c_str()); @@ -103,7 +103,7 @@ sai_status_t ServerSai::initialize( return status; } -sai_status_t ServerSai::uninitialize(void) +sai_status_t ServerSai::apiUninitialize(void) { SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); @@ -434,6 +434,24 @@ sai_status_t ServerSai::bulkSet( object_statuses); } +sai_status_t ServerSai::bulkGet( + _In_ sai_object_type_t object_type, + _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) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + // BULK QUAD ENTRY #define DECLARE_BULK_CREATE_ENTRY(OT,ot) \ @@ -503,6 +521,26 @@ sai_status_t ServerSai::bulkSet( \ SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t ServerSai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + REDIS_CHECK_API_INITIALIZED(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + // NON QUAD API sai_status_t ServerSai::flushFdbEntries( @@ -555,7 +593,7 @@ sai_status_t ServerSai::queryAttributeCapability( capability); } -sai_status_t ServerSai::queryAattributeEnumValuesCapability( +sai_status_t ServerSai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -565,7 +603,7 @@ sai_status_t ServerSai::queryAattributeEnumValuesCapability( SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); - return m_sai->queryAattributeEnumValuesCapability( + return m_sai->queryAttributeEnumValuesCapability( switch_id, object_type, attr_id, @@ -613,6 +651,16 @@ sai_status_t ServerSai::logSet( return m_sai->logSet(api, log_level); } +sai_status_t ServerSai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + REDIS_CHECK_API_INITIALIZED(); + + return m_sai->queryApiVersion(version); +} + void ServerSai::serverThreadFunction() { SWSS_LOG_ENTER(); @@ -1949,7 +1997,7 @@ sai_status_t ServerSai::processAttrEnumValuesCapabilityQuery( enumCapList.count = list_size; enumCapList.list = enum_capabilities_list.data(); - sai_status_t status = m_sai->queryAattributeEnumValuesCapability(switchOid, objectType, attrId, &enumCapList); + sai_status_t status = m_sai->queryAttributeEnumValuesCapability(switchOid, objectType, attrId, &enumCapList); std::vector entry; diff --git a/lib/ServerSai.h b/lib/ServerSai.h index b67c4ed1c..e0a17eab3 100644 --- a/lib/ServerSai.h +++ b/lib/ServerSai.h @@ -23,11 +23,11 @@ namespace sairedis public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -85,6 +85,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -156,7 +165,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -172,6 +181,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: void serverThreadFunction(); diff --git a/lib/SkipRecordAttrContainer.cpp b/lib/SkipRecordAttrContainer.cpp index 3f04dc40b..cdda07ba1 100644 --- a/lib/SkipRecordAttrContainer.cpp +++ b/lib/SkipRecordAttrContainer.cpp @@ -30,9 +30,16 @@ SkipRecordAttrContainer::SkipRecordAttrContainer() add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVAILABLE_DOUBLE_NAT_ENTRY); add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE); add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVAILABLE_ACL_TABLE_GROUP); + add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_TEMP_LIST); + add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_MAX_TEMP); + add(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_AVERAGE_TEMP); add(SAI_OBJECT_TYPE_ACL_TABLE, SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_ENTRY); add(SAI_OBJECT_TYPE_ACL_TABLE, SAI_ACL_TABLE_ATTR_AVAILABLE_ACL_COUNTER); + + add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_FABRIC_ATTACHED); + add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_FABRIC_ATTACHED_SWITCH_ID); + add(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_FABRIC_ATTACHED_PORT_INDEX); } bool SkipRecordAttrContainer::add( diff --git a/lib/Switch.cpp b/lib/Switch.cpp index 8c198e2f0..6777e747c 100644 --- a/lib/Switch.cpp +++ b/lib/Switch.cpp @@ -83,6 +83,11 @@ void Switch::updateNotifications( (sai_switch_state_change_notification_fn)attr.value.ptr; break; + case SAI_SWITCH_ATTR_SWITCH_ASIC_SDK_HEALTH_EVENT_NOTIFY: + m_switchNotifications.on_switch_asic_sdk_health_event = + (sai_switch_asic_sdk_health_event_notification_fn)attr.value.ptr; + break; + case SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY: m_switchNotifications.on_switch_shutdown_request = (sai_switch_shutdown_request_notification_fn)attr.value.ptr; diff --git a/lib/sai_redis.h b/lib/sai_redis.h deleted file mode 100644 index 061ef280b..000000000 --- a/lib/sai_redis.h +++ /dev/null @@ -1,449 +0,0 @@ -#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 redis_acl_api; -PRIVATE extern const sai_ars_api_t redis_ars_api; -PRIVATE extern const sai_ars_profile_api_t redis_ars_profile_api; -PRIVATE extern const sai_bfd_api_t redis_bfd_api; -PRIVATE extern const sai_bmtor_api_t redis_bmtor_api; -PRIVATE extern const sai_generic_programmable_api_t redis_generic_programmable_api; -PRIVATE extern const sai_bridge_api_t redis_bridge_api; -PRIVATE extern const sai_buffer_api_t redis_buffer_api; -PRIVATE extern const sai_counter_api_t redis_counter_api; -PRIVATE extern const sai_dash_vip_api_t redis_dash_vip_api; -PRIVATE extern const sai_dash_pa_validation_api_t redis_dash_pa_validation_api; -PRIVATE extern const sai_dash_vnet_api_t redis_dash_vnet_api; -PRIVATE extern const sai_dash_outbound_routing_api_t redis_dash_outbound_routing_api; -PRIVATE extern const sai_dash_outbound_ca_to_pa_api_t redis_dash_outbound_ca_to_pa_api; -PRIVATE extern const sai_dash_inbound_routing_api_t redis_dash_inbound_routing_api; -PRIVATE extern const sai_dash_eni_api_t redis_dash_eni_api; -PRIVATE extern const sai_dash_direction_lookup_api_t redis_dash_direction_lookup_api; -PRIVATE extern const sai_dash_acl_api_t redis_dash_acl_api; -PRIVATE extern const sai_debug_counter_api_t redis_debug_counter_api; -PRIVATE extern const sai_dtel_api_t redis_dtel_api; -PRIVATE extern const sai_fdb_api_t redis_fdb_api; -PRIVATE extern const sai_hash_api_t redis_hash_api; -PRIVATE extern const sai_hostif_api_t redis_hostif_api; -PRIVATE extern const sai_ipmc_api_t redis_ipmc_api; -PRIVATE extern const sai_ipmc_group_api_t redis_ipmc_group_api; -PRIVATE extern const sai_isolation_group_api_t redis_isolation_group_api; -PRIVATE extern const sai_l2mc_api_t redis_l2mc_api; -PRIVATE extern const sai_l2mc_group_api_t redis_l2mc_group_api; -PRIVATE extern const sai_lag_api_t redis_lag_api; -PRIVATE extern const sai_macsec_api_t redis_macsec_api; -PRIVATE extern const sai_mcast_fdb_api_t redis_mcast_fdb_api; -PRIVATE extern const sai_mirror_api_t redis_mirror_api; -PRIVATE extern const sai_mpls_api_t redis_mpls_api; -PRIVATE extern const sai_nat_api_t redis_nat_api; -PRIVATE extern const sai_neighbor_api_t redis_neighbor_api; -PRIVATE extern const sai_next_hop_api_t redis_next_hop_api; -PRIVATE extern const sai_next_hop_group_api_t redis_next_hop_group_api; -PRIVATE extern const sai_policer_api_t redis_policer_api; -PRIVATE extern const sai_port_api_t redis_port_api; -PRIVATE extern const sai_qos_map_api_t redis_qos_map_api; -PRIVATE extern const sai_queue_api_t redis_queue_api; -PRIVATE extern const sai_route_api_t redis_route_api; -PRIVATE extern const sai_router_interface_api_t redis_router_interface_api; -PRIVATE extern const sai_rpf_group_api_t redis_rpf_group_api; -PRIVATE extern const sai_samplepacket_api_t redis_samplepacket_api; -PRIVATE extern const sai_scheduler_api_t redis_scheduler_api; -PRIVATE extern const sai_scheduler_group_api_t redis_scheduler_group_api; -PRIVATE extern const sai_srv6_api_t redis_srv6_api; -PRIVATE extern const sai_stp_api_t redis_stp_api; -PRIVATE extern const sai_switch_api_t redis_switch_api; -PRIVATE extern const sai_system_port_api_t redis_system_port_api; -PRIVATE extern const sai_tam_api_t redis_tam_api; -PRIVATE extern const sai_tunnel_api_t redis_tunnel_api; -PRIVATE extern const sai_udf_api_t redis_udf_api; -PRIVATE extern const sai_virtual_router_api_t redis_virtual_router_api; -PRIVATE extern const sai_vlan_api_t redis_vlan_api; -PRIVATE extern const sai_wred_api_t redis_wred_api; -PRIVATE extern const sai_my_mac_api_t redis_my_mac_api; -PRIVATE extern const sai_ipsec_api_t redis_ipsec_api; -PRIVATE extern const sai_twamp_api_t redis_twamp_api; -PRIVATE extern const sai_dash_meter_api_t redis_dash_meter_api; - -PRIVATE extern std::shared_ptr redis_sai; - -// QUAD OID - -#define REDIS_CREATE(OT,ot) \ - static sai_status_t redis_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 redis_sai->create( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - switch_id, \ - attr_count, \ - attr_list); \ -} - -#define REDIS_REMOVE(OT,ot) \ - static sai_status_t redis_remove_ ## ot( \ - _In_ sai_object_id_t object_id) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->remove( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id); \ -} - -#define REDIS_SET(OT,ot) \ - static sai_status_t redis_set_ ## ot ## _attribute( \ - _In_ sai_object_id_t object_id, \ - _In_ const sai_attribute_t *attr) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->set( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - attr); \ -} - -#define REDIS_GET(OT,ot) \ - static sai_status_t redis_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 redis_sai->get( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - attr_count, \ - attr_list); \ -} - -// QUAD DECLARE - -#define REDIS_GENERIC_QUAD(OT,ot) \ - REDIS_CREATE(OT,ot); \ - REDIS_REMOVE(OT,ot); \ - REDIS_SET(OT,ot); \ - REDIS_GET(OT,ot); - -// QUAD ENTRY - -#define REDIS_CREATE_ENTRY(OT,ot) \ - static sai_status_t redis_create_ ## ot( \ - _In_ const sai_ ## ot ##_t *entry, \ - _In_ uint32_t attr_count, \ - _In_ const sai_attribute_t *attr_list) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->create( \ - entry, \ - attr_count, \ - attr_list); \ -} - -#define REDIS_REMOVE_ENTRY(OT,ot) \ - static sai_status_t redis_remove_ ## ot( \ - _In_ const sai_ ## ot ## _t *entry) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->remove( \ - entry); \ -} - -#define REDIS_SET_ENTRY(OT,ot) \ - static sai_status_t redis_set_ ## ot ## _attribute( \ - _In_ const sai_ ## ot ## _t *entry, \ - _In_ const sai_attribute_t *attr) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->set( \ - entry, \ - attr); \ -} - -#define REDIS_GET_ENTRY(OT,ot) \ - static sai_status_t redis_get_ ## ot ## _attribute( \ - _In_ const sai_ ## ot ## _t *entry, \ - _In_ uint32_t attr_count, \ - _Inout_ sai_attribute_t *attr_list) \ -{ \ - SWSS_LOG_ENTER(); \ - return redis_sai->get( \ - entry, \ - attr_count, \ - attr_list); \ -} - -// QUAD ENTRY DECLARE - -#define REDIS_GENERIC_QUAD_ENTRY(OT,ot) \ - REDIS_CREATE_ENTRY(OT,ot); \ - REDIS_REMOVE_ENTRY(OT,ot); \ - REDIS_SET_ENTRY(OT,ot); \ - REDIS_GET_ENTRY(OT,ot); - -// QUAD API - -#define REDIS_GENERIC_QUAD_API(ot) \ - redis_create_ ## ot, \ - redis_remove_ ## ot, \ - redis_set_ ## ot ##_attribute, \ - redis_get_ ## ot ##_attribute, - -// STATS - -#define REDIS_GET_STATS(OT,ot) \ - static sai_status_t redis_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 redis_sai->getStats( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids, \ - counters); \ -} - -#define REDIS_GET_STATS_EXT(OT,ot) \ - static sai_status_t redis_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 redis_sai->getStatsExt( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids, \ - mode, \ - counters); \ -} - -#define REDIS_CLEAR_STATS(OT,ot) \ - static sai_status_t redis_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 redis_sai->clearStats( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids); \ -} - -// STATS DECLARE - -#define REDIS_GENERIC_STATS(OT, ot) \ - REDIS_GET_STATS(OT,ot); \ - REDIS_GET_STATS_EXT(OT,ot); \ - REDIS_CLEAR_STATS(OT,ot); - -// STATS API - -#define REDIS_GENERIC_STATS_API(ot) \ - redis_get_ ## ot ## _stats, \ - redis_get_ ## ot ## _stats_ext, \ - redis_clear_ ## ot ## _stats, - -// BULK QUAD - -#define REDIS_BULK_CREATE(OT,fname) \ - static sai_status_t redis_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 redis_sai->bulkCreate( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - switch_id, \ - object_count, \ - attr_count, \ - attr_list, \ - mode, \ - object_id, \ - object_statuses); \ -} - -#define REDIS_BULK_REMOVE(OT,fname) \ - static sai_status_t redis_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 redis_sai->bulkRemove( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_count, \ - object_id, \ - mode, \ - object_statuses); \ -} - -#define REDIS_BULK_SET(OT,fname) \ - static sai_status_t redis_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 redis_sai->bulkSet( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_count, \ - object_id, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define REDIS_BULK_GET(OT,fname) \ - static sai_status_t redis_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 REDIS_BULK_QUAD(OT,ot) \ - REDIS_BULK_CREATE(OT,ot); \ - REDIS_BULK_REMOVE(OT,ot); \ - REDIS_BULK_SET(OT,ot); \ - REDIS_BULK_GET(OT,ot); - -// BULK QUAD ENTRY - -#define REDIS_BULK_CREATE_ENTRY(OT,ot) \ - REDIS_BULK_CREATE_ENTRY_EX(OT, ot, ot) - -#define REDIS_BULK_CREATE_ENTRY_EX(OT,ot,fname) \ - static sai_status_t redis_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 redis_sai->bulkCreate( \ - object_count, \ - entry, \ - attr_count, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define REDIS_BULK_REMOVE_ENTRY(OT,ot) \ - REDIS_BULK_REMOVE_ENTRY_EX(OT, ot, ot) - -#define REDIS_BULK_REMOVE_ENTRY_EX(OT,ot,fname) \ - static sai_status_t redis_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 redis_sai->bulkRemove( \ - object_count, \ - entry, \ - mode, \ - object_statuses); \ -} - -#define REDIS_BULK_SET_ENTRY(OT,ot) \ - static sai_status_t redis_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 redis_sai->bulkSet( \ - object_count, \ - entry, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define REDIS_BULK_GET_ENTRY(OT,ot) \ - static sai_status_t redis_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 REDIS_BULK_QUAD_ENTRY(OT,ot) \ - REDIS_BULK_CREATE_ENTRY(OT,ot); \ - REDIS_BULK_REMOVE_ENTRY(OT,ot); \ - REDIS_BULK_SET_ENTRY(OT,ot); \ - REDIS_BULK_GET_ENTRY(OT,ot); - -// BULK QUAD API - -#define REDIS_BULK_QUAD_API(ot) \ - redis_bulk_create_ ## ot, \ - redis_bulk_remove_ ## ot, \ - redis_bulk_set_ ## ot, \ - redis_bulk_get_ ## ot, - -// BULK get/set DECLARE - -#define REDIS_BULK_GET_SET(OT,ot) \ - REDIS_BULK_GET(OT,ot); \ - REDIS_BULK_SET(OT,ot); - -// BULK get/set API - -#define REDIS_BULK_GET_SET_API(ot) \ - redis_bulk_get_ ## ot, \ - redis_bulk_set_ ## ot, diff --git a/lib/sai_redis_acl.cpp b/lib/sai_redis_acl.cpp deleted file mode 100644 index 9c1ebf7d8..000000000 --- a/lib/sai_redis_acl.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(ACL_TABLE,acl_table); -REDIS_GENERIC_QUAD(ACL_ENTRY,acl_entry); -REDIS_GENERIC_QUAD(ACL_COUNTER,acl_counter); -REDIS_GENERIC_QUAD(ACL_RANGE,acl_range); -REDIS_GENERIC_QUAD(ACL_TABLE_GROUP,acl_table_group); -REDIS_GENERIC_QUAD(ACL_TABLE_GROUP_MEMBER,acl_table_group_member); -REDIS_GENERIC_QUAD(ACL_TABLE_CHAIN_GROUP,acl_table_chain_group) - -const sai_acl_api_t redis_acl_api = { - - REDIS_GENERIC_QUAD_API(acl_table) - REDIS_GENERIC_QUAD_API(acl_entry) - REDIS_GENERIC_QUAD_API(acl_counter) - REDIS_GENERIC_QUAD_API(acl_range) - REDIS_GENERIC_QUAD_API(acl_table_group) - REDIS_GENERIC_QUAD_API(acl_table_group_member) - REDIS_GENERIC_QUAD_API(acl_table_chain_group) -}; diff --git a/lib/sai_redis_ars.cpp b/lib/sai_redis_ars.cpp deleted file mode 100644 index 5fd6f812a..000000000 --- a/lib/sai_redis_ars.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(ARS, ars); - -const sai_ars_api_t redis_ars_api = { - REDIS_GENERIC_QUAD_API(ars) -}; diff --git a/lib/sai_redis_ars_profile.cpp b/lib/sai_redis_ars_profile.cpp deleted file mode 100644 index ffef33354..000000000 --- a/lib/sai_redis_ars_profile.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - - -REDIS_GENERIC_QUAD(ARS_PROFILE, ars_profile); - -const sai_ars_profile_api_t redis_ars_profile_api = { - REDIS_GENERIC_QUAD_API(ars_profile) -}; diff --git a/lib/sai_redis_bfd.cpp b/lib/sai_redis_bfd.cpp deleted file mode 100644 index 92a778584..000000000 --- a/lib/sai_redis_bfd.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(BFD_SESSION,bfd_session); -REDIS_GENERIC_STATS(BFD_SESSION,bfd_session); - -const sai_bfd_api_t redis_bfd_api = { - - REDIS_GENERIC_QUAD_API(bfd_session) - REDIS_GENERIC_STATS_API(bfd_session) -}; diff --git a/lib/sai_redis_bmtor.cpp b/lib/sai_redis_bmtor.cpp deleted file mode 100644 index 9784ef6c7..000000000 --- a/lib/sai_redis_bmtor.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); -REDIS_GENERIC_STATS(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); -REDIS_GENERIC_QUAD(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); -REDIS_GENERIC_STATS(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); -REDIS_GENERIC_QUAD(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); -REDIS_GENERIC_STATS(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); - -const sai_bmtor_api_t redis_bmtor_api = { - - REDIS_GENERIC_QUAD_API(table_bitmap_classification_entry) - REDIS_GENERIC_STATS_API(table_bitmap_classification_entry) - REDIS_GENERIC_QUAD_API(table_bitmap_router_entry) - REDIS_GENERIC_STATS_API(table_bitmap_router_entry) - REDIS_GENERIC_QUAD_API(table_meta_tunnel_entry) - REDIS_GENERIC_STATS_API(table_meta_tunnel_entry) -}; diff --git a/lib/sai_redis_bridge.cpp b/lib/sai_redis_bridge.cpp deleted file mode 100644 index c3491830e..000000000 --- a/lib/sai_redis_bridge.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(BRIDGE,bridge); -REDIS_GENERIC_QUAD(BRIDGE_PORT,bridge_port); -REDIS_GENERIC_STATS(BRIDGE,bridge); -REDIS_GENERIC_STATS(BRIDGE_PORT,bridge_port); - -const sai_bridge_api_t redis_bridge_api = { - - REDIS_GENERIC_QUAD_API(bridge) - REDIS_GENERIC_STATS_API(bridge) - REDIS_GENERIC_QUAD_API(bridge_port) - REDIS_GENERIC_STATS_API(bridge_port) -}; diff --git a/lib/sai_redis_buffer.cpp b/lib/sai_redis_buffer.cpp deleted file mode 100644 index 833ef3e13..000000000 --- a/lib/sai_redis_buffer.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(BUFFER_POOL,buffer_pool); -REDIS_GENERIC_QUAD(INGRESS_PRIORITY_GROUP,ingress_priority_group); -REDIS_GENERIC_QUAD(BUFFER_PROFILE,buffer_profile); -REDIS_GENERIC_STATS(BUFFER_POOL,buffer_pool); -REDIS_GENERIC_STATS(INGRESS_PRIORITY_GROUP,ingress_priority_group); - -const sai_buffer_api_t redis_buffer_api = { - - REDIS_GENERIC_QUAD_API(buffer_pool) - REDIS_GENERIC_STATS_API(buffer_pool) - REDIS_GENERIC_QUAD_API(ingress_priority_group) - REDIS_GENERIC_STATS_API(ingress_priority_group) - REDIS_GENERIC_QUAD_API(buffer_profile) -}; diff --git a/lib/sai_redis_counter.cpp b/lib/sai_redis_counter.cpp deleted file mode 100644 index 5ec1ac48f..000000000 --- a/lib/sai_redis_counter.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(COUNTER,counter); -REDIS_GENERIC_STATS(COUNTER,counter); - -const sai_counter_api_t redis_counter_api = { - - REDIS_GENERIC_QUAD_API(counter) - REDIS_GENERIC_STATS_API(counter) -}; diff --git a/lib/sai_redis_dash_acl.cpp b/lib/sai_redis_dash_acl.cpp deleted file mode 100644 index 69440cb3e..000000000 --- a/lib/sai_redis_dash_acl.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(DASH_ACL_GROUP, dash_acl_group); -REDIS_BULK_CREATE(DASH_ACL_GROUP, dash_acl_groups); -REDIS_BULK_REMOVE(DASH_ACL_GROUP, dash_acl_groups); - -REDIS_GENERIC_QUAD(DASH_ACL_RULE, dash_acl_rule); -REDIS_BULK_CREATE(DASH_ACL_RULE, dash_acl_rules); -REDIS_BULK_REMOVE(DASH_ACL_RULE, dash_acl_rules); - -const sai_dash_acl_api_t redis_dash_acl_api = { - REDIS_GENERIC_QUAD_API(dash_acl_group) - redis_bulk_create_dash_acl_groups, - redis_bulk_remove_dash_acl_groups, - - REDIS_GENERIC_QUAD_API(dash_acl_rule) - redis_bulk_create_dash_acl_rules, - redis_bulk_remove_dash_acl_rules, -}; diff --git a/lib/sai_redis_dash_direction_lookup.cpp b/lib/sai_redis_dash_direction_lookup.cpp deleted file mode 100644 index 4d691dffc..000000000 --- a/lib/sai_redis_dash_direction_lookup.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry); -REDIS_BULK_CREATE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); -REDIS_BULK_REMOVE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); - -const sai_dash_direction_lookup_api_t redis_dash_direction_lookup_api = { - REDIS_GENERIC_QUAD_API(direction_lookup_entry) - redis_bulk_create_direction_lookup_entries, - redis_bulk_remove_direction_lookup_entries, -}; diff --git a/lib/sai_redis_dash_eni.cpp b/lib/sai_redis_dash_eni.cpp deleted file mode 100644 index 9f21bda71..000000000 --- a/lib/sai_redis_dash_eni.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry); -REDIS_BULK_CREATE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); -REDIS_BULK_REMOVE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); - -REDIS_GENERIC_QUAD(ENI, eni); -REDIS_BULK_CREATE(ENI, enis); -REDIS_BULK_REMOVE(ENI, enis); - -const sai_dash_eni_api_t redis_dash_eni_api = { - REDIS_GENERIC_QUAD_API(eni_ether_address_map_entry) - redis_bulk_create_eni_ether_address_map_entries, - redis_bulk_remove_eni_ether_address_map_entries, - - REDIS_GENERIC_QUAD_API(eni) - redis_bulk_create_enis, - redis_bulk_remove_enis, -}; diff --git a/lib/sai_redis_dash_inbound_routing.cpp b/lib/sai_redis_dash_inbound_routing.cpp deleted file mode 100644 index 30d4e7644..000000000 --- a/lib/sai_redis_dash_inbound_routing.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(INBOUND_ROUTING_ENTRY, inbound_routing_entry); -REDIS_BULK_CREATE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); -REDIS_BULK_REMOVE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); - -const sai_dash_inbound_routing_api_t redis_dash_inbound_routing_api = { - REDIS_GENERIC_QUAD_API(inbound_routing_entry) - redis_bulk_create_inbound_routing_entries, - redis_bulk_remove_inbound_routing_entries, -}; diff --git a/lib/sai_redis_dash_meter.cpp b/lib/sai_redis_dash_meter.cpp deleted file mode 100644 index 5b22e7f27..000000000 --- a/lib/sai_redis_dash_meter.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(METER_BUCKET, meter_bucket); -REDIS_BULK_CREATE(METER_BUCKET, meter_buckets); -REDIS_BULK_REMOVE(METER_BUCKET, meter_buckets); - -REDIS_GENERIC_QUAD(METER_BUCKET, meter_policy); -REDIS_BULK_CREATE(METER_BUCKET, meter_policys); -REDIS_BULK_REMOVE(METER_BUCKET, meter_policys); - -REDIS_GENERIC_QUAD(METER_BUCKET, meter_rule); -REDIS_BULK_CREATE(METER_BUCKET, meter_rules); -REDIS_BULK_REMOVE(METER_BUCKET, meter_rules); - -const sai_dash_meter_api_t redis_dash_meter_api = { - - REDIS_GENERIC_QUAD_API(meter_bucket) - redis_bulk_create_meter_buckets, - redis_bulk_remove_meter_buckets, - - REDIS_GENERIC_QUAD_API(meter_policy) - redis_bulk_create_meter_policys, - redis_bulk_remove_meter_policys, - - REDIS_GENERIC_QUAD_API(meter_rule) - redis_bulk_create_meter_rules, - redis_bulk_remove_meter_rules, -}; diff --git a/lib/sai_redis_dash_outbound_ca_to_pa.cpp b/lib/sai_redis_dash_outbound_ca_to_pa.cpp deleted file mode 100644 index 6f3bd9267..000000000 --- a/lib/sai_redis_dash_outbound_ca_to_pa.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry); -REDIS_BULK_CREATE_ENTRY_EX(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry, outbound_ca_to_pa_entries); -REDIS_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 redis_dash_outbound_ca_to_pa_api = { - REDIS_GENERIC_QUAD_API(outbound_ca_to_pa_entry) - redis_bulk_create_outbound_ca_to_pa_entries, - redis_bulk_remove_outbound_ca_to_pa_entries, -}; diff --git a/lib/sai_redis_dash_outbound_routing.cpp b/lib/sai_redis_dash_outbound_routing.cpp deleted file mode 100644 index 4fe8b9aa9..000000000 --- a/lib/sai_redis_dash_outbound_routing.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry); -REDIS_BULK_CREATE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); -REDIS_BULK_REMOVE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); - -const sai_dash_outbound_routing_api_t redis_dash_outbound_routing_api = { - REDIS_GENERIC_QUAD_API(outbound_routing_entry) - redis_bulk_create_outbound_routing_entries, - redis_bulk_remove_outbound_routing_entries, -}; diff --git a/lib/sai_redis_dash_pa_validation.cpp b/lib/sai_redis_dash_pa_validation.cpp deleted file mode 100644 index 24ca4373e..000000000 --- a/lib/sai_redis_dash_pa_validation.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(PA_VALIDATION_ENTRY, pa_validation_entry); -REDIS_BULK_CREATE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); -REDIS_BULK_REMOVE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); - -const sai_dash_pa_validation_api_t redis_dash_pa_validation_api = { - REDIS_GENERIC_QUAD_API(pa_validation_entry) - redis_bulk_create_pa_validation_entries, - redis_bulk_remove_pa_validation_entries, -}; diff --git a/lib/sai_redis_dash_vip.cpp b/lib/sai_redis_dash_vip.cpp deleted file mode 100644 index 5992a83f7..000000000 --- a/lib/sai_redis_dash_vip.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(VIP_ENTRY, vip_entry); -REDIS_BULK_CREATE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); -REDIS_BULK_REMOVE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); - -const sai_dash_vip_api_t redis_dash_vip_api = { - REDIS_GENERIC_QUAD_API(vip_entry) - redis_bulk_create_vip_entries, - redis_bulk_remove_vip_entries, -}; diff --git a/lib/sai_redis_dash_vnet.cpp b/lib/sai_redis_dash_vnet.cpp deleted file mode 100644 index 536785bcc..000000000 --- a/lib/sai_redis_dash_vnet.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(VNET, vnet); -REDIS_BULK_CREATE(VNET, vnets); -REDIS_BULK_REMOVE(VNET, vnets); - -const sai_dash_vnet_api_t redis_dash_vnet_api = { - REDIS_GENERIC_QUAD_API(vnet) - redis_bulk_create_vnets, - redis_bulk_remove_vnets, -}; diff --git a/lib/sai_redis_debug_counter.cpp b/lib/sai_redis_debug_counter.cpp deleted file mode 100644 index 6d22002b5..000000000 --- a/lib/sai_redis_debug_counter.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(DEBUG_COUNTER,debug_counter); - -const sai_debug_counter_api_t redis_debug_counter_api = { - - REDIS_GENERIC_QUAD_API(debug_counter) -}; diff --git a/lib/sai_redis_dtel.cpp b/lib/sai_redis_dtel.cpp deleted file mode 100644 index c429cf3dd..000000000 --- a/lib/sai_redis_dtel.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(DTEL,dtel); -REDIS_GENERIC_QUAD(DTEL_QUEUE_REPORT,dtel_queue_report); -REDIS_GENERIC_QUAD(DTEL_INT_SESSION,dtel_int_session); -REDIS_GENERIC_QUAD(DTEL_REPORT_SESSION,dtel_report_session); -REDIS_GENERIC_QUAD(DTEL_EVENT,dtel_event); - -const sai_dtel_api_t redis_dtel_api = { - - REDIS_GENERIC_QUAD_API(dtel) - REDIS_GENERIC_QUAD_API(dtel_queue_report) - REDIS_GENERIC_QUAD_API(dtel_int_session) - REDIS_GENERIC_QUAD_API(dtel_report_session) - REDIS_GENERIC_QUAD_API(dtel_event) -}; diff --git a/lib/sai_redis_fdb.cpp b/lib/sai_redis_fdb.cpp deleted file mode 100644 index 0c2fc3209..000000000 --- a/lib/sai_redis_fdb.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "sai_redis.h" - -static sai_status_t redis_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 redis_sai->flushFdbEntries( - switch_id, - attr_count, - attr_list); -} - -REDIS_GENERIC_QUAD_ENTRY(FDB_ENTRY,fdb_entry); -REDIS_BULK_QUAD_ENTRY(FDB_ENTRY,fdb_entry); - -const sai_fdb_api_t redis_fdb_api = { - - REDIS_GENERIC_QUAD_API(fdb_entry) - - redis_flush_fdb_entries, - - REDIS_BULK_QUAD_API(fdb_entry) -}; diff --git a/lib/sai_redis_genericprogrammable.cpp b/lib/sai_redis_genericprogrammable.cpp deleted file mode 100644 index 587917638..000000000 --- a/lib/sai_redis_genericprogrammable.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(GENERIC_PROGRAMMABLE,generic_programmable); - -const sai_generic_programmable_api_t redis_generic_programmable_api = { - REDIS_GENERIC_QUAD_API(generic_programmable) -}; diff --git a/lib/sai_redis_hash.cpp b/lib/sai_redis_hash.cpp deleted file mode 100644 index 0dec9b313..000000000 --- a/lib/sai_redis_hash.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(HASH,hash); -REDIS_GENERIC_QUAD(FINE_GRAINED_HASH_FIELD,fine_grained_hash_field); - -const sai_hash_api_t redis_hash_api = { - REDIS_GENERIC_QUAD_API(hash) - REDIS_GENERIC_QUAD_API(fine_grained_hash_field) -}; diff --git a/lib/sai_redis_hostif.cpp b/lib/sai_redis_hostif.cpp deleted file mode 100644 index fab7a9cfa..000000000 --- a/lib/sai_redis_hostif.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "sai_redis.h" - -static sai_status_t redis_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 redis_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 redis_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 redis_free_hostif_packet( - _In_ sai_object_id_t hostif_id, - _Inout_ void *buffer) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -REDIS_GENERIC_QUAD(HOSTIF,hostif); -REDIS_GENERIC_QUAD(HOSTIF_TABLE_ENTRY,hostif_table_entry); -REDIS_GENERIC_QUAD(HOSTIF_TRAP_GROUP,hostif_trap_group); -REDIS_GENERIC_QUAD(HOSTIF_TRAP,hostif_trap); -REDIS_GENERIC_QUAD(HOSTIF_USER_DEFINED_TRAP,hostif_user_defined_trap); - -const sai_hostif_api_t redis_hostif_api = { - - REDIS_GENERIC_QUAD_API(hostif) - REDIS_GENERIC_QUAD_API(hostif_table_entry) - REDIS_GENERIC_QUAD_API(hostif_trap_group) - REDIS_GENERIC_QUAD_API(hostif_trap) - REDIS_GENERIC_QUAD_API(hostif_user_defined_trap) - - redis_recv_hostif_packet, - redis_send_hostif_packet, - redis_allocate_hostif_packet, - redis_free_hostif_packet, -}; diff --git a/lib/sai_redis_interfacequery.cpp b/lib/sai_redis_interfacequery.cpp deleted file mode 100644 index e18c084e0..000000000 --- a/lib/sai_redis_interfacequery.cpp +++ /dev/null @@ -1,308 +0,0 @@ -#include "sai_redis.h" -#include "ClientServerSai.h" - -using namespace sairedis; - -std::shared_ptr redis_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 redis_sai->initialize(flags, service_method_table); -} - -sai_status_t sai_api_uninitialize(void) -{ - SWSS_LOG_ENTER(); - - return redis_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(&redis_ ## api ## _api) - -static sai_apis_t redis_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(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**)&redis_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 redis_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 redis_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 redis_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 redis_sai->objectTypeQuery(objectId); -} - -sai_object_id_t sai_switch_id_query( - _In_ sai_object_id_t objectId) -{ - SWSS_LOG_ENTER(); - - return redis_sai->switchIdQuery(objectId); -} - -sai_status_t sai_dbg_generate_dump( - _In_ const char *dump_file_name) -{ - SWSS_LOG_ENTER(); - - 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(); - - 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(); - - 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(); - - 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(); - - 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(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_status_t sai_query_api_version( - _Out_ sai_api_version_t *version) -{ - SWSS_LOG_ENTER(); - - 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 sairedis 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(); - - 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(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} diff --git a/lib/sai_redis_ipmc.cpp b/lib/sai_redis_ipmc.cpp deleted file mode 100644 index a27086f42..000000000 --- a/lib/sai_redis_ipmc.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(IPMC_ENTRY,ipmc_entry); - -const sai_ipmc_api_t redis_ipmc_api = { - - REDIS_GENERIC_QUAD_API(ipmc_entry) -}; diff --git a/lib/sai_redis_ipmc_group.cpp b/lib/sai_redis_ipmc_group.cpp deleted file mode 100644 index 6b41a6e44..000000000 --- a/lib/sai_redis_ipmc_group.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(IPMC_GROUP,ipmc_group); -REDIS_GENERIC_QUAD(IPMC_GROUP_MEMBER,ipmc_group_member); - -const sai_ipmc_group_api_t redis_ipmc_group_api = { - - REDIS_GENERIC_QUAD_API(ipmc_group) - REDIS_GENERIC_QUAD_API(ipmc_group_member) -}; diff --git a/lib/sai_redis_ipsec.cpp b/lib/sai_redis_ipsec.cpp deleted file mode 100644 index 3cde2eeff..000000000 --- a/lib/sai_redis_ipsec.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(IPSEC,ipsec); -REDIS_GENERIC_QUAD(IPSEC_PORT,ipsec_port); -REDIS_GENERIC_QUAD(IPSEC_SA,ipsec_sa); -REDIS_GENERIC_STATS(IPSEC_PORT,ipsec_port); -REDIS_GENERIC_STATS(IPSEC_SA,ipsec_sa); - -const sai_ipsec_api_t redis_ipsec_api = { - - REDIS_GENERIC_QUAD_API(ipsec) - REDIS_GENERIC_QUAD_API(ipsec_port) - REDIS_GENERIC_STATS_API(ipsec_port) - REDIS_GENERIC_QUAD_API(ipsec_sa) - REDIS_GENERIC_STATS_API(ipsec_sa) -}; diff --git a/lib/sai_redis_isolation_group.cpp b/lib/sai_redis_isolation_group.cpp deleted file mode 100644 index f685c73f5..000000000 --- a/lib/sai_redis_isolation_group.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(ISOLATION_GROUP,isolation_group); -REDIS_GENERIC_QUAD(ISOLATION_GROUP_MEMBER,isolation_group_member); - -const sai_isolation_group_api_t redis_isolation_group_api = { - - REDIS_GENERIC_QUAD_API(isolation_group) - REDIS_GENERIC_QUAD_API(isolation_group_member) -}; diff --git a/lib/sai_redis_l2mc.cpp b/lib/sai_redis_l2mc.cpp deleted file mode 100644 index 898ce9d4a..000000000 --- a/lib/sai_redis_l2mc.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(L2MC_ENTRY,l2mc_entry); - -const sai_l2mc_api_t redis_l2mc_api = { - - REDIS_GENERIC_QUAD_API(l2mc_entry) -}; diff --git a/lib/sai_redis_l2mcgroup.cpp b/lib/sai_redis_l2mcgroup.cpp deleted file mode 100644 index 8892cf4c8..000000000 --- a/lib/sai_redis_l2mcgroup.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(L2MC_GROUP,l2mc_group); -REDIS_GENERIC_QUAD(L2MC_GROUP_MEMBER,l2mc_group_member); - -const sai_l2mc_group_api_t redis_l2mc_group_api = { - - REDIS_GENERIC_QUAD_API(l2mc_group) - REDIS_GENERIC_QUAD_API(l2mc_group_member) -}; diff --git a/lib/sai_redis_lag.cpp b/lib/sai_redis_lag.cpp deleted file mode 100644 index 89c6b5e0c..000000000 --- a/lib/sai_redis_lag.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_CREATE(LAG_MEMBER,lag_members); -REDIS_BULK_REMOVE(LAG_MEMBER,lag_members); - -REDIS_GENERIC_QUAD(LAG,lag); -REDIS_GENERIC_QUAD(LAG_MEMBER,lag_member); - -const sai_lag_api_t redis_lag_api = { - - REDIS_GENERIC_QUAD_API(lag) - REDIS_GENERIC_QUAD_API(lag_member) - - redis_bulk_create_lag_members, - redis_bulk_remove_lag_members, -}; diff --git a/lib/sai_redis_macsec.cpp b/lib/sai_redis_macsec.cpp deleted file mode 100644 index 0367919e8..000000000 --- a/lib/sai_redis_macsec.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(MACSEC,macsec); -REDIS_GENERIC_QUAD(MACSEC_PORT,macsec_port); -REDIS_GENERIC_STATS(MACSEC_PORT,macsec_port); -REDIS_GENERIC_QUAD(MACSEC_FLOW,macsec_flow); -REDIS_GENERIC_STATS(MACSEC_FLOW,macsec_flow); -REDIS_GENERIC_QUAD(MACSEC_SC,macsec_sc); -REDIS_GENERIC_STATS(MACSEC_SC,macsec_sc); -REDIS_GENERIC_QUAD(MACSEC_SA,macsec_sa); -REDIS_GENERIC_STATS(MACSEC_SA,macsec_sa); - -const sai_macsec_api_t redis_macsec_api = { - - REDIS_GENERIC_QUAD_API(macsec) - REDIS_GENERIC_QUAD_API(macsec_port) - REDIS_GENERIC_STATS_API(macsec_port) - REDIS_GENERIC_QUAD_API(macsec_flow) - REDIS_GENERIC_STATS_API(macsec_flow) - REDIS_GENERIC_QUAD_API(macsec_sc) - REDIS_GENERIC_STATS_API(macsec_sc) - REDIS_GENERIC_QUAD_API(macsec_sa) - REDIS_GENERIC_STATS_API(macsec_sa) -}; diff --git a/lib/sai_redis_mcastfdb.cpp b/lib/sai_redis_mcastfdb.cpp deleted file mode 100644 index e05ada2ce..000000000 --- a/lib/sai_redis_mcastfdb.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(MCAST_FDB_ENTRY,mcast_fdb_entry); - -const sai_mcast_fdb_api_t redis_mcast_fdb_api = { - - REDIS_GENERIC_QUAD_API(mcast_fdb_entry) -}; diff --git a/lib/sai_redis_mirror.cpp b/lib/sai_redis_mirror.cpp deleted file mode 100644 index 9394d225a..000000000 --- a/lib/sai_redis_mirror.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(MIRROR_SESSION,mirror_session); - -const sai_mirror_api_t redis_mirror_api = { - - REDIS_GENERIC_QUAD_API(mirror_session) -}; diff --git a/lib/sai_redis_mpls.cpp b/lib/sai_redis_mpls.cpp deleted file mode 100644 index 70eef8ae8..000000000 --- a/lib/sai_redis_mpls.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); -REDIS_BULK_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); - -const sai_mpls_api_t redis_mpls_api = { - - REDIS_GENERIC_QUAD_API(inseg_entry) - REDIS_BULK_QUAD_API(inseg_entry) -}; diff --git a/lib/sai_redis_my_mac.cpp b/lib/sai_redis_my_mac.cpp deleted file mode 100644 index 586644148..000000000 --- a/lib/sai_redis_my_mac.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(MY_MAC,my_mac); - -const sai_my_mac_api_t redis_my_mac_api = { - - REDIS_GENERIC_QUAD_API(my_mac) -}; diff --git a/lib/sai_redis_nat.cpp b/lib/sai_redis_nat.cpp deleted file mode 100644 index caf0b0038..000000000 --- a/lib/sai_redis_nat.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_QUAD_ENTRY(NAT_ENTRY,nat_entry); -REDIS_GENERIC_QUAD_ENTRY(NAT_ENTRY,nat_entry); -REDIS_GENERIC_QUAD(NAT_ZONE_COUNTER,nat_zone_counter); - -const sai_nat_api_t redis_nat_api = { - - REDIS_GENERIC_QUAD_API(nat_entry) - REDIS_BULK_QUAD_API(nat_entry) - REDIS_GENERIC_QUAD_API(nat_zone_counter) -}; diff --git a/lib/sai_redis_neighbor.cpp b/lib/sai_redis_neighbor.cpp deleted file mode 100644 index e189a775c..000000000 --- a/lib/sai_redis_neighbor.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "sai_redis.h" - -static sai_status_t redis_remove_all_neighbor_entries( - _In_ sai_object_id_t switch_id) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -REDIS_BULK_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); -REDIS_GENERIC_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); - -const sai_neighbor_api_t redis_neighbor_api = { - - REDIS_GENERIC_QUAD_API(neighbor_entry) - redis_remove_all_neighbor_entries, - - REDIS_BULK_QUAD_API(neighbor_entry) -}; diff --git a/lib/sai_redis_nexthop.cpp b/lib/sai_redis_nexthop.cpp deleted file mode 100644 index 4d7a91399..000000000 --- a/lib/sai_redis_nexthop.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(NEXT_HOP,next_hop); -REDIS_BULK_QUAD(NEXT_HOP,next_hop); - -const sai_next_hop_api_t redis_next_hop_api = { - - REDIS_GENERIC_QUAD_API(next_hop) - REDIS_BULK_QUAD_API(next_hop) -}; diff --git a/lib/sai_redis_nexthopgroup.cpp b/lib/sai_redis_nexthopgroup.cpp deleted file mode 100644 index 98ac1662b..000000000 --- a/lib/sai_redis_nexthopgroup.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_CREATE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -REDIS_BULK_REMOVE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -REDIS_BULK_GET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -REDIS_BULK_SET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -REDIS_GENERIC_QUAD(NEXT_HOP_GROUP,next_hop_group); -REDIS_GENERIC_QUAD(NEXT_HOP_GROUP_MEMBER,next_hop_group_member); -REDIS_GENERIC_QUAD(NEXT_HOP_GROUP_MAP,next_hop_group_map); - -const sai_next_hop_group_api_t redis_next_hop_group_api = { - - REDIS_GENERIC_QUAD_API(next_hop_group) - REDIS_GENERIC_QUAD_API(next_hop_group_member) - - redis_bulk_create_next_hop_group_members, - redis_bulk_remove_next_hop_group_members, - REDIS_GENERIC_QUAD_API(next_hop_group_map) - redis_bulk_set_next_hop_group_members, - redis_bulk_get_next_hop_group_members -}; diff --git a/lib/sai_redis_policer.cpp b/lib/sai_redis_policer.cpp deleted file mode 100644 index 4129c9cd4..000000000 --- a/lib/sai_redis_policer.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(POLICER,policer); -REDIS_GENERIC_STATS(POLICER,policer); - -const sai_policer_api_t redis_policer_api = { - - REDIS_GENERIC_QUAD_API(policer) - REDIS_GENERIC_STATS_API(policer) -}; diff --git a/lib/sai_redis_port.cpp b/lib/sai_redis_port.cpp deleted file mode 100644 index f6c28f35b..000000000 --- a/lib/sai_redis_port.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "sai_redis.h" - -static sai_status_t redis_clear_port_all_stats( - _In_ sai_object_id_t port_id) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -REDIS_GENERIC_QUAD(PORT,port); -REDIS_GENERIC_QUAD(PORT_POOL,port_pool); -REDIS_GENERIC_QUAD(PORT_SERDES,port_serdes); -REDIS_GENERIC_QUAD(PORT_CONNECTOR,port_connector); -REDIS_GENERIC_STATS(PORT,port); -REDIS_GENERIC_STATS(PORT_POOL,port_pool); -REDIS_BULK_QUAD(PORT, ports); -REDIS_BULK_QUAD(PORT_SERDES, port_serdeses); - -const sai_port_api_t redis_port_api = { - - REDIS_GENERIC_QUAD_API(port) - REDIS_GENERIC_STATS_API(port) - - redis_clear_port_all_stats, - - REDIS_GENERIC_QUAD_API(port_pool) - REDIS_GENERIC_STATS_API(port_pool) - REDIS_GENERIC_QUAD_API(port_connector) - REDIS_GENERIC_QUAD_API(port_serdes) - REDIS_BULK_QUAD_API(ports) - REDIS_BULK_QUAD_API(port_serdeses) -}; diff --git a/lib/sai_redis_qosmap.cpp b/lib/sai_redis_qosmap.cpp deleted file mode 100644 index 40000eb98..000000000 --- a/lib/sai_redis_qosmap.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(QOS_MAP,qos_map); - -const sai_qos_map_api_t redis_qos_map_api = { - - REDIS_GENERIC_QUAD_API(qos_map) -}; diff --git a/lib/sai_redis_queue.cpp b/lib/sai_redis_queue.cpp deleted file mode 100644 index f05eb120a..000000000 --- a/lib/sai_redis_queue.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(QUEUE,queue); -REDIS_GENERIC_STATS(QUEUE,queue); - -const sai_queue_api_t redis_queue_api = { - - REDIS_GENERIC_QUAD_API(queue) - REDIS_GENERIC_STATS_API(queue) -}; diff --git a/lib/sai_redis_route.cpp b/lib/sai_redis_route.cpp deleted file mode 100644 index 64ab44d51..000000000 --- a/lib/sai_redis_route.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD_ENTRY(ROUTE_ENTRY,route_entry); -REDIS_BULK_QUAD_ENTRY(ROUTE_ENTRY,route_entry); - -const sai_route_api_t redis_route_api = { - - REDIS_GENERIC_QUAD_API(route_entry) - REDIS_BULK_QUAD_API(route_entry) -}; diff --git a/lib/sai_redis_router_interface.cpp b/lib/sai_redis_router_interface.cpp deleted file mode 100644 index 1e77427e7..000000000 --- a/lib/sai_redis_router_interface.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(ROUTER_INTERFACE,router_interface); -REDIS_GENERIC_STATS(ROUTER_INTERFACE,router_interface); -REDIS_BULK_QUAD(ROUTER_INTERFACE,router_interfaces); - -const sai_router_interface_api_t redis_router_interface_api = { - - REDIS_GENERIC_QUAD_API(router_interface) - REDIS_GENERIC_STATS_API(router_interface) - REDIS_BULK_QUAD_API(router_interfaces) -}; diff --git a/lib/sai_redis_rpfgroup.cpp b/lib/sai_redis_rpfgroup.cpp deleted file mode 100644 index 32b66c80d..000000000 --- a/lib/sai_redis_rpfgroup.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(RPF_GROUP,rpf_group); -REDIS_GENERIC_QUAD(RPF_GROUP_MEMBER,rpf_group_member); - -const sai_rpf_group_api_t redis_rpf_group_api = { - - REDIS_GENERIC_QUAD_API(rpf_group) - REDIS_GENERIC_QUAD_API(rpf_group_member) -}; diff --git a/lib/sai_redis_samplepacket.cpp b/lib/sai_redis_samplepacket.cpp deleted file mode 100644 index 283c72e94..000000000 --- a/lib/sai_redis_samplepacket.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(SAMPLEPACKET,samplepacket); - -const sai_samplepacket_api_t redis_samplepacket_api = { - - REDIS_GENERIC_QUAD_API(samplepacket) -}; diff --git a/lib/sai_redis_scheduler.cpp b/lib/sai_redis_scheduler.cpp deleted file mode 100644 index 854a6b831..000000000 --- a/lib/sai_redis_scheduler.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(SCHEDULER,scheduler); - -const sai_scheduler_api_t redis_scheduler_api = { - - REDIS_GENERIC_QUAD_API(scheduler) -}; diff --git a/lib/sai_redis_schedulergroup.cpp b/lib/sai_redis_schedulergroup.cpp deleted file mode 100644 index 9941d87a7..000000000 --- a/lib/sai_redis_schedulergroup.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(SCHEDULER_GROUP,scheduler_group); - -const sai_scheduler_group_api_t redis_scheduler_group_api = { - - REDIS_GENERIC_QUAD_API(scheduler_group) -}; diff --git a/lib/sai_redis_srv6.cpp b/lib/sai_redis_srv6.cpp deleted file mode 100644 index 293a35ac8..000000000 --- a/lib/sai_redis_srv6.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_CREATE(SRV6_SIDLIST, srv6_sidlist); -REDIS_BULK_REMOVE(SRV6_SIDLIST, srv6_sidlist); -REDIS_GENERIC_QUAD(SRV6_SIDLIST,srv6_sidlist); -REDIS_BULK_QUAD_ENTRY(MY_SID_ENTRY,my_sid_entry); -REDIS_GENERIC_QUAD_ENTRY(MY_SID_ENTRY,my_sid_entry); - -const sai_srv6_api_t redis_srv6_api = { - - REDIS_GENERIC_QUAD_API(srv6_sidlist) - - redis_bulk_create_srv6_sidlist, - redis_bulk_remove_srv6_sidlist, - - NULL, - NULL, - NULL, - - REDIS_GENERIC_QUAD_API(my_sid_entry) - REDIS_BULK_QUAD_API(my_sid_entry) -}; diff --git a/lib/sai_redis_stp.cpp b/lib/sai_redis_stp.cpp deleted file mode 100644 index 98dd9d60b..000000000 --- a/lib/sai_redis_stp.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_CREATE(STP_PORT,stp_ports); -REDIS_BULK_REMOVE(STP_PORT,stp_ports); -REDIS_GENERIC_QUAD(STP,stp); -REDIS_GENERIC_QUAD(STP_PORT,stp_port); - -const sai_stp_api_t redis_stp_api = { - - REDIS_GENERIC_QUAD_API(stp) - REDIS_GENERIC_QUAD_API(stp_port) - - redis_bulk_create_stp_ports, - redis_bulk_remove_stp_ports, -}; diff --git a/lib/sai_redis_switch.cpp b/lib/sai_redis_switch.cpp deleted file mode 100644 index 32d227c7e..000000000 --- a/lib/sai_redis_switch.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "sai_redis.h" - -static sai_status_t redis_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 redis_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 redis_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 redis_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; -} - -REDIS_GENERIC_QUAD(SWITCH,switch); -REDIS_GENERIC_STATS(SWITCH,switch); -REDIS_GENERIC_QUAD(SWITCH_TUNNEL,switch_tunnel); - -static sai_status_t redis_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 redis_create_switch( - switch_id, - SAI_NULL_OBJECT_ID, // no switch id since we create switch - attr_count, - attr_list); -} - -const sai_switch_api_t redis_switch_api = { - - redis_create_switch_uniq, - redis_remove_switch, - redis_set_switch_attribute, - redis_get_switch_attribute, - - REDIS_GENERIC_STATS_API(switch) - - redis_switch_mdio_read, - redis_switch_mdio_write, - - REDIS_GENERIC_QUAD_API(switch_tunnel) - redis_switch_mdio_cl22_read, - redis_switch_mdio_cl22_write -}; diff --git a/lib/sai_redis_system_port.cpp b/lib/sai_redis_system_port.cpp deleted file mode 100644 index 0514fd723..000000000 --- a/lib/sai_redis_system_port.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(SYSTEM_PORT,system_port); - -const sai_system_port_api_t redis_system_port_api = { - - REDIS_GENERIC_QUAD_API(system_port) -}; diff --git a/lib/sai_redis_tam.cpp b/lib/sai_redis_tam.cpp deleted file mode 100644 index aa21ced94..000000000 --- a/lib/sai_redis_tam.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "sai_redis.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; -} - -REDIS_GENERIC_QUAD(TAM,tam); -REDIS_GENERIC_QUAD(TAM_MATH_FUNC,tam_math_func); -REDIS_GENERIC_QUAD(TAM_REPORT,tam_report); -REDIS_GENERIC_QUAD(TAM_EVENT_THRESHOLD,tam_event_threshold); -REDIS_GENERIC_QUAD(TAM_INT,tam_int); -REDIS_GENERIC_QUAD(TAM_TEL_TYPE,tam_tel_type); -REDIS_GENERIC_QUAD(TAM_TRANSPORT,tam_transport); -REDIS_GENERIC_QUAD(TAM_TELEMETRY,tam_telemetry); -REDIS_GENERIC_QUAD(TAM_COLLECTOR,tam_collector); -REDIS_GENERIC_QUAD(TAM_EVENT_ACTION,tam_event_action); -REDIS_GENERIC_QUAD(TAM_EVENT,tam_event); - -const sai_tam_api_t redis_tam_api = { - - REDIS_GENERIC_QUAD_API(tam) - REDIS_GENERIC_QUAD_API(tam_math_func) - REDIS_GENERIC_QUAD_API(tam_report) - REDIS_GENERIC_QUAD_API(tam_event_threshold) - REDIS_GENERIC_QUAD_API(tam_int) - REDIS_GENERIC_QUAD_API(tam_tel_type) - REDIS_GENERIC_QUAD_API(tam_transport) - REDIS_GENERIC_QUAD_API(tam_telemetry) - REDIS_GENERIC_QUAD_API(tam_collector) - REDIS_GENERIC_QUAD_API(tam_event_action) - REDIS_GENERIC_QUAD_API(tam_event) -}; diff --git a/lib/sai_redis_tunnel.cpp b/lib/sai_redis_tunnel.cpp deleted file mode 100644 index 2807a6b84..000000000 --- a/lib/sai_redis_tunnel.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(TUNNEL_MAP,tunnel_map); -REDIS_GENERIC_QUAD(TUNNEL,tunnel); -REDIS_GENERIC_QUAD(TUNNEL_TERM_TABLE_ENTRY,tunnel_term_table_entry); -REDIS_GENERIC_QUAD(TUNNEL_MAP_ENTRY,tunnel_map_entry); -REDIS_GENERIC_STATS(TUNNEL,tunnel); -REDIS_BULK_QUAD(TUNNEL,tunnels); - -const sai_tunnel_api_t redis_tunnel_api = { - - REDIS_GENERIC_QUAD_API(tunnel_map) - REDIS_GENERIC_QUAD_API(tunnel) - REDIS_GENERIC_STATS_API(tunnel) - REDIS_GENERIC_QUAD_API(tunnel_term_table_entry) - REDIS_GENERIC_QUAD_API(tunnel_map_entry) - REDIS_BULK_QUAD_API(tunnels) -}; diff --git a/lib/sai_redis_twamp.cpp b/lib/sai_redis_twamp.cpp deleted file mode 100644 index 83e1c4cf4..000000000 --- a/lib/sai_redis_twamp.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(TWAMP_SESSION,twamp_session); -REDIS_GENERIC_STATS(TWAMP_SESSION,twamp_session); - -const sai_twamp_api_t redis_twamp_api = { - REDIS_GENERIC_QUAD_API(twamp_session) - REDIS_GENERIC_STATS_API(twamp_session) -}; diff --git a/lib/sai_redis_udf.cpp b/lib/sai_redis_udf.cpp deleted file mode 100644 index fdfaf8979..000000000 --- a/lib/sai_redis_udf.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(UDF,udf) -REDIS_GENERIC_QUAD(UDF_MATCH,udf_match) -REDIS_GENERIC_QUAD(UDF_GROUP,udf_group) - -const sai_udf_api_t redis_udf_api = { - - REDIS_GENERIC_QUAD_API(udf) - REDIS_GENERIC_QUAD_API(udf_match) - REDIS_GENERIC_QUAD_API(udf_group) -}; diff --git a/lib/sai_redis_virtual_router.cpp b/lib/sai_redis_virtual_router.cpp deleted file mode 100644 index 814c0461f..000000000 --- a/lib/sai_redis_virtual_router.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(VIRTUAL_ROUTER,virtual_router); - -const sai_virtual_router_api_t redis_virtual_router_api = { - - REDIS_GENERIC_QUAD_API(virtual_router) -}; diff --git a/lib/sai_redis_vlan.cpp b/lib/sai_redis_vlan.cpp deleted file mode 100644 index cc34a44db..000000000 --- a/lib/sai_redis_vlan.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "sai_redis.h" - -REDIS_BULK_CREATE(VLAN_MEMBER,vlan_members); -REDIS_BULK_REMOVE(VLAN_MEMBER,vlan_members); -REDIS_GENERIC_QUAD(VLAN,vlan); -REDIS_GENERIC_QUAD(VLAN_MEMBER,vlan_member); -REDIS_GENERIC_STATS(VLAN,vlan); - -const sai_vlan_api_t redis_vlan_api = { - - REDIS_GENERIC_QUAD_API(vlan) - REDIS_GENERIC_QUAD_API(vlan_member) - - redis_bulk_create_vlan_members, - redis_bulk_remove_vlan_members, - - REDIS_GENERIC_STATS_API(vlan) -}; diff --git a/lib/sai_redis_wred.cpp b/lib/sai_redis_wred.cpp deleted file mode 100644 index 70c300b50..000000000 --- a/lib/sai_redis_wred.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_redis.h" - -REDIS_GENERIC_QUAD(WRED,wred); - -const sai_wred_api_t redis_wred_api = { - - REDIS_GENERIC_QUAD_API(wred) -}; diff --git a/lib/sairedis.h b/lib/sairedis.h index 68e9436d5..56a21bd4d 100644 --- a/lib/sairedis.h +++ b/lib/sairedis.h @@ -86,6 +86,88 @@ typedef enum _sai_redis_communication_mode_t } sai_redis_communication_mode_t; +/** + * @brief Use Redis communication channel to handle counters. + * + * Originally, there are out-of-order issue between the objects and their counters. + * This is because the counters are handled on receiving flex counter database update. + * However, the objects are handled on receiving update from the redis communication channel. + * + * To resolve the issue, we use the redis communication channel to handle the counter updates. + * + * The struct sai_redis_flex_counter_group_parameter_t represents the counter group operations. + * The caller (usually orchagent) can change some or all the options of a counter group. + * The counter_group_name represents the counter group name which must be a valid list. + * For the rest fields, it means not changing it to pass an empty list. + */ +typedef struct _sai_redis_flex_counter_group_parameter_t +{ + /** + * @brief The flex counter group name. + * + * It is the key of FLEX_COUNTER_TABLE and FLEX_COUNTER_GROUP_TABLE table. + */ + sai_s8_list_t counter_group_name; + + /** + * @brief The polling interval of the counter group + * + * It should be a number representing the polling interval in seconds. + */ + sai_s8_list_t poll_interval; + + /** + * @brief The operation of the counter group + * + * It should be either "enable" or "disable" + */ + sai_s8_list_t operation; + + /** + * @brief The counter fetching mode. + * + * It should be either "STATS_MODE_READ" or "STATS_MODE_READ_AND_CLEAR" + */ + sai_s8_list_t stats_mode; + + /** + * @brief The name of the filed that represents the Lua plugin + */ + sai_s8_list_t plugin_name; + + /** + * @brief The SHA code of the Lua plugin + */ + sai_s8_list_t plugins; + +} sai_redis_flex_counter_group_parameter_t; + +typedef struct _sai_redis_flex_counter_parameter_t +{ + /** + * @brief The key in the flex counter table + * + * It should be the serialized OID eg. "oid:0x15000000000001" + */ + sai_s8_list_t counter_key; + + /** + * @brief The list of counters' IDs that should be fetched. + */ + sai_s8_list_t counter_ids; + + /** + * @brief The name of the filed that represents the counters' IDs. + */ + sai_s8_list_t counter_field_name; + + /** + * @brief The counter fetch mode of the object. + */ + sai_s8_list_t stats_mode; + +} sai_redis_flex_counter_parameter_t; + typedef enum _sai_redis_switch_attr_t { /** @@ -249,6 +331,25 @@ typedef enum _sai_redis_switch_attr_t * @default 60000 */ SAI_REDIS_SWITCH_ATTR_SYNC_OPERATION_RESPONSE_TIMEOUT, + + /** + * @brief Flex counter group operations + * + * @type sai_redis_flex_counter_group_parameter_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP, + + /** + * @brief Flex counter operations + * + * @type sai_redis_counter_parameter_t + * @flags CREATE_AND_SET + * @default 0 + */ + SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER, + } sai_redis_switch_attr_t; /** diff --git a/lib/sairediscommon.h b/lib/sairediscommon.h index 7a6a997d9..d09ddc0ab 100644 --- a/lib/sairediscommon.h +++ b/lib/sairediscommon.h @@ -52,6 +52,11 @@ #define REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_QUERY "object_type_get_availability_query" #define REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_RESPONSE "object_type_get_availability_response" +#define REDIS_FLEX_COUNTER_COMMAND_START_POLL "start_poll" +#define REDIS_FLEX_COUNTER_COMMAND_STOP_POLL "stop_poll" +#define REDIS_FLEX_COUNTER_COMMAND_SET_GROUP "set_counter_group" +#define REDIS_FLEX_COUNTER_COMMAND_DEL_GROUP "del_counter_group" +#define REDIS_FLEX_COUNTER_COMMAND_RESPONSE "counter_response" /** * @brief Redis virtual object id counter key name. * diff --git a/lib/tests.cpp b/lib/tests.cpp index 355f3e1de..eb3d9ad70 100644 --- a/lib/tests.cpp +++ b/lib/tests.cpp @@ -789,7 +789,7 @@ static void test_recorder_enum_value_capability_query_request( sai_s32_list_t enum_values_capability { .count = 0, .list = nullptr }; - recorder.recordQueryAattributeEnumValuesCapability( + recorder.recordQueryAttributeEnumValuesCapability( switch_id, object_type, attr_id, @@ -821,7 +821,7 @@ static void test_recorder_enum_value_capability_query_response( enum_values_capability.count = static_cast(enumList.size()); enum_values_capability.list = enumList.data(); - recorder.recordQueryAattributeEnumValuesCapabilityResponse( + recorder.recordQueryAttributeEnumValuesCapabilityResponse( status, object_type, attr_id, diff --git a/meta/DummySaiInterface.cpp b/meta/DummySaiInterface.cpp index fa3ede4fe..51e9e7d51 100644 --- a/meta/DummySaiInterface.cpp +++ b/meta/DummySaiInterface.cpp @@ -21,16 +21,39 @@ void DummySaiInterface::setStatus( m_status = status; } -sai_status_t DummySaiInterface::initialize( +sai_status_t DummySaiInterface::apiInitialize( _In_ uint64_t flags, - _In_ const sai_service_method_table_t *service_method_table) + _In_ const sai_service_method_table_t *smt) { SWSS_LOG_ENTER(); + if (smt) + { + if (smt->profile_get_value) + { + SWSS_LOG_NOTICE("Dummy: profile_get_value(NULL): %s", smt->profile_get_value(0, NULL)); + SWSS_LOG_NOTICE("Dummy: profile_get_value(FOO): %s", smt->profile_get_value(0, "FOO")); + SWSS_LOG_NOTICE("Dummy: profile_get_value(FOO): %s", smt->profile_get_value(0, "CAR")); + } + + if (smt->profile_get_next_value) + { + + const char *var = NULL; + const char *val = NULL; + + SWSS_LOG_NOTICE("Dummy: profile_get_next_value: %d", smt->profile_get_next_value(0, NULL, NULL)); + SWSS_LOG_NOTICE("Dummy: profile_get_next_value: %d", smt->profile_get_next_value(0, NULL, &val)); + SWSS_LOG_NOTICE("Dummy: profile_get_next_value: %d", smt->profile_get_next_value(0, &var, NULL)); + SWSS_LOG_NOTICE("Dummy: profile_get_next_value: %d", smt->profile_get_next_value(0, &var, &val)); + SWSS_LOG_NOTICE("Dummy: profile_get_next_value: %d", smt->profile_get_next_value(0, &var, &val)); + } + } + return SAI_STATUS_SUCCESS; } -sai_status_t DummySaiInterface::uninitialize(void) +sai_status_t DummySaiInterface::apiUninitialize(void) { SWSS_LOG_ENTER(); @@ -46,6 +69,11 @@ sai_status_t DummySaiInterface::create( { SWSS_LOG_ENTER(); + if (objectId && m_status == SAI_STATUS_SUCCESS) + { + *objectId = (sai_object_id_t)1; + } + return m_status; } @@ -158,6 +186,22 @@ sai_status_t DummySaiInterface::bulkSet( \ return m_status; \ } +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t DummySaiInterface::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +// NON QUAD API + SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_REMOVE_ENTRY); SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_CREATE_ENTRY); SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_SET_ENTRY); @@ -165,6 +209,7 @@ SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_GET_ENTRY); SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_CREATE_ENTRY); SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_REMOVE_ENTRY); SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); sai_status_t DummySaiInterface::flushFdbEntries( _In_ sai_object_id_t switchId, @@ -247,7 +292,7 @@ sai_status_t DummySaiInterface::queryAttributeCapability( return m_status; } -sai_status_t DummySaiInterface::queryAattributeEnumValuesCapability( +sai_status_t DummySaiInterface::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -279,7 +324,7 @@ sai_status_t DummySaiInterface::queryStatsCapability( { SWSS_LOG_ENTER(); - return SAI_STATUS_NOT_IMPLEMENTED; + return m_status; } sai_status_t DummySaiInterface::getStatsExt( @@ -370,6 +415,22 @@ sai_status_t DummySaiInterface::bulkSet( return m_status; } +sai_status_t DummySaiInterface::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t DummySaiInterface::bulkCreate( _In_ sai_object_type_t object_type, _In_ sai_object_id_t switch_id, @@ -418,3 +479,20 @@ sai_status_t DummySaiInterface::logSet( return m_status; } + +sai_status_t DummySaiInterface::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + if (version) + { + *version = SAI_API_VERSION; + + return m_status; + } + + SWSS_LOG_ERROR("version parameter is NULL"); + + return m_status; +} diff --git a/meta/DummySaiInterface.h b/meta/DummySaiInterface.h index 8cef2ecff..d6e8d748d 100644 --- a/meta/DummySaiInterface.h +++ b/meta/DummySaiInterface.h @@ -27,11 +27,11 @@ namespace saimeta public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - virtual sai_status_t uninitialize(void) override; + virtual sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -89,6 +89,15 @@ namespace saimeta _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -188,7 +197,7 @@ namespace saimeta _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -204,6 +213,9 @@ namespace saimeta _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + protected: sai_status_t m_status; diff --git a/meta/Makefile.am b/meta/Makefile.am index 8947603ca..0a6ac1887 100644 --- a/meta/Makefile.am +++ b/meta/Makefile.am @@ -32,6 +32,7 @@ libsaimeta_la_SOURCES = \ NotificationNatEvent.cpp \ NotificationPortStateChange.cpp \ NotificationQueuePfcDeadlock.cpp \ + NotificationSwitchAsicSdkHealthEvent.cpp \ NotificationSwitchShutdownRequest.cpp \ NotificationSwitchStateChange.cpp \ NotificationBfdSessionStateChange.cpp \ diff --git a/meta/Meta.cpp b/meta/Meta.cpp index db9e6854e..d6a9f4526 100644 --- a/meta/Meta.cpp +++ b/meta/Meta.cpp @@ -146,20 +146,20 @@ Meta::Meta( m_warmBoot = false; } -sai_status_t Meta::initialize( +sai_status_t Meta::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { SWSS_LOG_ENTER(); - return m_implementation->initialize(flags, service_method_table); + return m_implementation->apiInitialize(flags, service_method_table); } -sai_status_t Meta::uninitialize(void) +sai_status_t Meta::apiUninitialize(void) { SWSS_LOG_ENTER(); - return m_implementation->uninitialize(); + return m_implementation->apiUninitialize(); } void Meta::meta_warm_boot_notify() @@ -723,9 +723,26 @@ sai_status_t Meta::bulkSet( return status; \ } +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t Meta::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_CREATE_ENTRY); SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_REMOVE_ENTRY); SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); sai_status_t Meta::objectTypeGetAvailability( _In_ sai_object_id_t switchId, @@ -854,7 +871,7 @@ sai_status_t Meta::queryAttributeCapability( return status; } -sai_status_t Meta::queryAattributeEnumValuesCapability( +sai_status_t Meta::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -892,7 +909,7 @@ sai_status_t Meta::queryAattributeEnumValuesCapability( return SAI_STATUS_INVALID_PARAMETER; } - auto status = m_implementation->queryAattributeEnumValuesCapability(switchId, objectType, attrId, enumValuesCapability); + auto status = m_implementation->queryAttributeEnumValuesCapability(switchId, objectType, attrId, enumValuesCapability); if (status == SAI_STATUS_SUCCESS) { @@ -1252,6 +1269,22 @@ sai_status_t Meta::bulkSet( return status; } +sai_status_t Meta::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t Meta::bulkCreate( _In_ sai_object_type_t object_type, _In_ sai_object_id_t switchId, @@ -1377,6 +1410,16 @@ sai_status_t Meta::logSet( return m_implementation->logSet(api, log_level); } +sai_status_t Meta::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + PARAMETER_CHECK_IF_NOT_NULL(version); + + return m_implementation->queryApiVersion(version); +} + void Meta::clean_after_switch_remove( _In_ sai_object_id_t switchId) { @@ -6513,6 +6556,54 @@ void Meta::meta_sai_on_switch_state_change( // we should not snoop switch_id, since switch id should be created directly by user } +void Meta::meta_sai_on_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); + + if (!sai_metadata_get_enum_value_name( + &sai_metadata_enum_sai_switch_asic_sdk_health_severity_t, + severity)) + { + SWSS_LOG_WARN("Switch ASIC/SDK health event severity value (%d) not found in sai_switch_asic_sdk_health_severity_t", + severity); + } + + if (!sai_metadata_get_enum_value_name( + &sai_metadata_enum_sai_switch_asic_sdk_health_category_t, + category)) + { + SWSS_LOG_WARN("Switch ASIC/SDK health event category value (%d) not found in sai_switch_asic_sdk_health_severity_t", + category); + } + + auto ot = objectTypeQuery(switch_id); + + if (ot != SAI_OBJECT_TYPE_SWITCH) + { + SWSS_LOG_WARN("switch_id %s is of type %s, but expected SAI_OBJECT_TYPE_SWITCH", + sai_serialize_object_id(switch_id).c_str(), + sai_serialize_object_type(ot).c_str()); + + return; + } + + sai_object_meta_key_t switch_meta_key = { .objecttype = ot , .objectkey = { .key = { .object_id = switch_id } } }; + + if (!m_saiObjectCollection.objectExists(switch_meta_key)) + { + SWSS_LOG_ERROR("switch_id %s don't exists in local database", + sai_serialize_object_id(switch_id).c_str()); + } + + // we should not snoop switch_id, since switch id should be created directly by user +} + void Meta::meta_sai_on_switch_shutdown_request( _In_ sai_object_id_t switch_id) { diff --git a/meta/Meta.h b/meta/Meta.h index a30fc53ff..12dbf3aa7 100644 --- a/meta/Meta.h +++ b/meta/Meta.h @@ -34,11 +34,11 @@ namespace saimeta public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - virtual sai_status_t uninitialize(void) override; + virtual sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -96,6 +96,15 @@ namespace saimeta _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -167,7 +176,7 @@ namespace saimeta _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -183,6 +192,9 @@ namespace saimeta _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + public: void meta_init_db(); @@ -205,6 +217,14 @@ namespace saimeta _In_ sai_object_id_t switch_id, _In_ sai_switch_oper_status_t switch_oper_status); + void meta_sai_on_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description); + void meta_sai_on_switch_shutdown_request( _In_ sai_object_id_t switch_id); diff --git a/meta/NotificationFactory.cpp b/meta/NotificationFactory.cpp index 6381bd16b..0c9f95721 100644 --- a/meta/NotificationFactory.cpp +++ b/meta/NotificationFactory.cpp @@ -5,6 +5,7 @@ #include "NotificationQueuePfcDeadlock.h" #include "NotificationSwitchShutdownRequest.h" #include "NotificationSwitchStateChange.h" +#include "NotificationSwitchAsicSdkHealthEvent.h" #include "NotificationBfdSessionStateChange.h" #include "NotificationTwampSessionEvent.h" #include "NotificationPortHostTxReadyEvent.h" @@ -38,6 +39,9 @@ std::shared_ptr NotificationFactory::deserialize( if (name == SAI_SWITCH_NOTIFICATION_NAME_SWITCH_SHUTDOWN_REQUEST) return std::make_shared(serializedNotification); + if (name == SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT) + return std::make_shared(serializedNotification); + if (name == SAI_SWITCH_NOTIFICATION_NAME_SWITCH_STATE_CHANGE) return std::make_shared(serializedNotification); diff --git a/meta/NotificationSwitchAsicSdkHealthEvent.cpp b/meta/NotificationSwitchAsicSdkHealthEvent.cpp new file mode 100644 index 000000000..ed6129052 --- /dev/null +++ b/meta/NotificationSwitchAsicSdkHealthEvent.cpp @@ -0,0 +1,74 @@ +#include "NotificationSwitchAsicSdkHealthEvent.h" + +#include "swss/logger.h" + +#include "sai_serialize.h" + +using namespace sairedis; + +NotificationSwitchAsicSdkHealthEvent::NotificationSwitchAsicSdkHealthEvent( + _In_ const std::string& serializedNotification): + Notification( + SAI_SWITCH_NOTIFICATION_TYPE_SWITCH_ASIC_SDK_HEALTH_EVENT, + serializedNotification) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_switch_asic_sdk_health_event(serializedNotification, + m_switchId, + m_severity, + m_timestamp, + m_category, + m_healthData, + m_description); +} + +NotificationSwitchAsicSdkHealthEvent::~NotificationSwitchAsicSdkHealthEvent() +{ + SWSS_LOG_ENTER(); + + sai_deserialize_free_switch_asic_sdk_health_event(m_description); +} + +sai_object_id_t NotificationSwitchAsicSdkHealthEvent::getSwitchId() const +{ + SWSS_LOG_ENTER(); + + return m_switchId; +} + +sai_object_id_t NotificationSwitchAsicSdkHealthEvent::getAnyObjectId() const +{ + SWSS_LOG_ENTER(); + + return m_switchId; +} + +void NotificationSwitchAsicSdkHealthEvent::processMetadata( + _In_ std::shared_ptr meta) const +{ + SWSS_LOG_ENTER(); + + meta->meta_sai_on_switch_asic_sdk_health_event(m_switchId, + m_severity, + m_timestamp, + m_category, + m_healthData, + m_description); +} + +void NotificationSwitchAsicSdkHealthEvent::executeCallback( + _In_ const sai_switch_notifications_t& switchNotifications) const +{ + SWSS_LOG_ENTER(); + + if (switchNotifications.on_switch_asic_sdk_health_event) + { + switchNotifications.on_switch_asic_sdk_health_event(m_switchId, + m_severity, + m_timestamp, + m_category, + m_healthData, + m_description); + } +} diff --git a/meta/NotificationSwitchAsicSdkHealthEvent.h b/meta/NotificationSwitchAsicSdkHealthEvent.h new file mode 100644 index 000000000..c1330f7fc --- /dev/null +++ b/meta/NotificationSwitchAsicSdkHealthEvent.h @@ -0,0 +1,38 @@ +#pragma once + +#include "Notification.h" + +namespace sairedis +{ + class NotificationSwitchAsicSdkHealthEvent: + public Notification + { + public: + + NotificationSwitchAsicSdkHealthEvent( + _In_ const std::string& serializedNotification); + + virtual ~NotificationSwitchAsicSdkHealthEvent(); + + public: + + virtual sai_object_id_t getSwitchId() const override; + + virtual sai_object_id_t getAnyObjectId() const override; + + virtual void processMetadata( + _In_ std::shared_ptr meta) const override; + + virtual void executeCallback( + _In_ const sai_switch_notifications_t& switchNotifications) const override; + + private: + + sai_object_id_t m_switchId; + sai_switch_asic_sdk_health_severity_t m_severity; + sai_switch_asic_sdk_health_category_t m_category; + sai_timespec_t m_timestamp; + sai_switch_health_data_t m_healthData; + sai_u8_list_t m_description; + }; +} diff --git a/meta/SaiInterface.h b/meta/SaiInterface.h index fdd55ac00..d45e0b974 100644 --- a/meta/SaiInterface.h +++ b/meta/SaiInterface.h @@ -87,6 +87,13 @@ extern "C" { _In_ const sai_attribute_t *attr_list, \ _In_ sai_bulk_op_error_mode_t mode, \ _Out_ sai_status_t *object_statuses) = 0; \ + virtual sai_status_t bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) = 0; \ #define SAIREDIS_SAIINTERFACE_DECLARE_BULK_ENTRY_OVERRIDE(OT,ot) \ virtual sai_status_t bulkCreate( \ @@ -107,6 +114,13 @@ extern "C" { _In_ const sai_attribute_t *attr_list, \ _In_ sai_bulk_op_error_mode_t mode, \ _Out_ sai_status_t *object_statuses) override; \ + virtual sai_status_t bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) override; \ namespace sairedis { @@ -120,11 +134,11 @@ namespace sairedis public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) = 0; - virtual sai_status_t uninitialize(void) = 0; + virtual sai_status_t apiUninitialize(void) = 0; public: // QUAD oid @@ -182,6 +196,15 @@ namespace sairedis _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) = 0; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) = 0; + public: // QUAD meta key virtual sai_status_t create( @@ -301,7 +324,7 @@ namespace sairedis _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) = 0; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -317,6 +340,9 @@ namespace sairedis _In_ sai_api_t api, _In_ sai_log_level_t log_level) = 0; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) = 0; + public: // non SAI API virtual sai_log_level_t logGet( diff --git a/meta/SaiSerialize.cpp b/meta/SaiSerialize.cpp index a35c21fc7..3d9605ad5 100644 --- a/meta/SaiSerialize.cpp +++ b/meta/SaiSerialize.cpp @@ -163,9 +163,9 @@ sai_status_t transfer_attribute( transfer_primitive(src_attr.value.u16, dst_attr.value.u16); break; -// case SAI_ATTR_VALUE_TYPE_INT16: -// transfer_primitive(src_attr.value.s16, dst_attr.value.s16); -// break; + case SAI_ATTR_VALUE_TYPE_INT16: + transfer_primitive(src_attr.value.s16, dst_attr.value.s16); + break; case SAI_ATTR_VALUE_TYPE_UINT32: transfer_primitive(src_attr.value.u32, dst_attr.value.u32); @@ -510,6 +510,10 @@ sai_status_t transfer_attribute( RETURN_ON_ERROR(transfer_list(src_attr.value.aclchainlist, dst_attr.value.aclchainlist, countOnly)); break; + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: + transfer_primitive(src_attr.value.portpowerconsumption, dst_attr.value.portpowerconsumption); + break; + default: SWSS_LOG_THROW("sai attr value %s is not implemented, FIXME", sai_serialize_attr_value_type(serialization_type).c_str()); } @@ -1131,6 +1135,41 @@ std::string sai_serialize_egress_drop_reason( return sai_serialize_enum(reason, &sai_metadata_enum_sai_out_drop_reason_t); } +std::string sai_serialize_timespec( + _In_ const sai_timespec_t ×pec) +{ + SWSS_LOG_ENTER(); + + json j; + + j["tv_sec"] = sai_serialize_number(timespec.tv_sec); + j["tv_nsec"] = sai_serialize_number(timespec.tv_nsec); + + return j.dump(); +} + +std::string sai_serialize_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ const sai_timespec_t ×tamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ const sai_switch_health_data_t &data, + _In_ const sai_u8_list_t &description) +{ + SWSS_LOG_ENTER(); + + json j; + + j["switch_id"] = sai_serialize_object_id(switch_id); + j["severity"] = sai_serialize_enum(severity, &sai_metadata_enum_sai_switch_asic_sdk_health_severity_t); + j["timestamp"] = sai_serialize_timespec(timestamp); + j["category"] = sai_serialize_enum(category, &sai_metadata_enum_sai_switch_asic_sdk_health_category_t); + j["data.data_type"] = sai_serialize_enum(data.data_type, &sai_metadata_enum_sai_health_data_type_t); + j["description"] = sai_serialize_number_list(description, false); + + return j.dump(); +} + std::string sai_serialize_switch_shutdown_request( _In_ sai_object_id_t switch_id) { @@ -1299,7 +1338,7 @@ template std::string sai_serialize_number_list( _In_ const T& list, _In_ bool countOnly, - _In_ bool hex = false) + _In_ bool hex) { SWSS_LOG_ENTER(); @@ -1942,8 +1981,8 @@ std::string sai_serialize_attr_value( case SAI_ATTR_VALUE_TYPE_JSON: return sai_serialize_json(attr.value.json); -// case SAI_ATTR_VALUE_TYPE_INT16: -// return sai_serialize_number(attr.value.s16); + case SAI_ATTR_VALUE_TYPE_INT16: + return sai_serialize_number(attr.value.s16); case SAI_ATTR_VALUE_TYPE_UINT32: return sai_serialize_number(attr.value.u32); @@ -2096,6 +2135,9 @@ std::string sai_serialize_attr_value( case SAI_ATTR_VALUE_TYPE_IP_PREFIX_LIST: return sai_serialize_ip_prefix_list(attr.value.ipprefixlist, countOnly); + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: + return sai_serialize_poe_port_power_consumption(attr.value.portpowerconsumption); + default: SWSS_LOG_THROW("sai attr value type %s is not implemented, FIXME", sai_serialize_attr_value_type(meta.attrvaluetype).c_str()); } @@ -2744,6 +2786,51 @@ std::string sai_serialize_redis_link_event_damping_aied_config( return j.dump(); } +std::string sai_serialize_poe_port_active_channel_type( + _In_ const sai_poe_port_active_channel_type_t value) +{ + SWSS_LOG_ENTER(); + + return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_active_channel_type_t); +} + +std::string sai_serialize_poe_port_class_method_type( + _In_ const sai_poe_port_class_method_type_t value) +{ + SWSS_LOG_ENTER(); + + return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_class_method_type_t); +} + +std::string sai_serialzie_poe_port_signature_type( + _In_ const sai_poe_port_signature_type_t value) +{ + SWSS_LOG_ENTER(); + + return sai_serialize_enum(value, &sai_metadata_enum_sai_poe_port_signature_type_t); +} + +std::string sai_serialize_poe_port_power_consumption( + _In_ const sai_poe_port_power_consumption_t& value) +{ + SWSS_LOG_ENTER(); + + json j; + + j["active_channel"] = sai_serialize_poe_port_active_channel_type(value.active_channel); + j["voltage"] = sai_serialize_number(value.voltage, false); + j["current"] = sai_serialize_number(value.current, false); + j["consumption"] = sai_serialize_number(value.consumption, false); + j["signature_type"] = sai_serialzie_poe_port_signature_type(value.signature_type); + j["class_method"] = sai_serialize_poe_port_class_method_type(value.class_method); + j["measured_class_a"] = sai_serialize_number(value.measured_class_a, false); + j["assigned_class_a"] = sai_serialize_number(value.assigned_class_a, false); + j["measured_class_b"] = sai_serialize_number(value.measured_class_b, false); + j["assigned_class_b"] = sai_serialize_number(value.assigned_class_b, false); + + return j.dump(); +} + // deserialize void sai_deserialize_bool( @@ -3878,8 +3965,8 @@ void sai_deserialize_attr_value( case SAI_ATTR_VALUE_TYPE_JSON: return sai_deserialize_json(s, attr.value.json); -// case SAI_ATTR_VALUE_TYPE_INT16: -// return sai_deserialize_number(s, attr.value.s16); + case SAI_ATTR_VALUE_TYPE_INT16: + return sai_deserialize_number(s, attr.value.s16); case SAI_ATTR_VALUE_TYPE_UINT32: return sai_deserialize_number(s, attr.value.u32); @@ -4030,8 +4117,12 @@ void sai_deserialize_attr_value( case SAI_ATTR_VALUE_TYPE_IP_PREFIX_LIST: return sai_deserialize_ip_prefix_list(s, attr.value.ipprefixlist, countOnly); + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: + return sai_deserialize_poe_port_power_consumption(s, attr.value.portpowerconsumption); + default: - SWSS_LOG_THROW("deserialize type %d is not supported yet FIXME", meta.attrvaluetype); + SWSS_LOG_THROW("deserialize type %s is not supported yet FIXME", + sai_serialize_attr_value_type(meta.attrvaluetype).c_str()); } } @@ -4147,6 +4238,66 @@ void sai_deserialize_switch_oper_status( sai_deserialize_enum(j["status"], &sai_metadata_enum_sai_switch_oper_status_t, (int32_t&)status); } +void sai_deserialize_timespec( + _In_ const std::string& s, + _Out_ sai_timespec_t ×tamp) +{ + SWSS_LOG_ENTER(); + + json j; + try + { + j = json::parse(s); + } + catch (const std::exception&) + { + SWSS_LOG_THROW("Received an exception after trying to parse timespec_t from %s", s.c_str()); + } + + sai_deserialize_number(j["tv_sec"], timestamp.tv_sec); + sai_deserialize_number(j["tv_nsec"], timestamp.tv_nsec); +} + +void sai_deserialize_switch_asic_sdk_health_event( + _In_ const std::string& s, + _Out_ sai_object_id_t &switch_id, + _Out_ sai_switch_asic_sdk_health_severity_t &severity, + _Out_ sai_timespec_t ×tamp, + _Out_ sai_switch_asic_sdk_health_category_t &category, + _Out_ sai_switch_health_data_t &data, + _Out_ sai_u8_list_t &description) +{ + SWSS_LOG_ENTER(); + + json j; + try + { + j = json::parse(s); + } + catch (const std::exception&) + { + SWSS_LOG_THROW("Received an exception after trying to parse switch_asic_sdk_health_event from %s", s.c_str()); + } + + sai_deserialize_object_id(j["switch_id"], switch_id); + sai_deserialize_enum(j["severity"], &sai_metadata_enum_sai_switch_asic_sdk_health_severity_t, (int32_t&)severity); + sai_deserialize_timespec(j["timestamp"], timestamp); + sai_deserialize_enum(j["category"], &sai_metadata_enum_sai_switch_asic_sdk_health_category_t, (int32_t&)category); + int32_t data_type; + sai_deserialize_enum(j["data.data_type"], &sai_metadata_enum_sai_health_data_type_t, data_type); + data.data_type = (sai_health_data_type_t)data_type; + data.data_type = SAI_HEALTH_DATA_TYPE_GENERAL; + sai_deserialize_number_list(j["description"], description, false, false); +} + +void sai_deserialize_free_switch_asic_sdk_health_event( + _In_ sai_u8_list_t &description) +{ + SWSS_LOG_ENTER(); + + sai_free_list(description); +} + void sai_deserialize_switch_shutdown_request( _In_ const std::string& s, _Out_ sai_object_id_t &switch_id) @@ -5088,11 +5239,61 @@ void sai_deserialize_free_attribute_value( sai_free_list(attr.value.ipprefixlist); break; + case SAI_ATTR_VALUE_TYPE_POE_PORT_POWER_CONSUMPTION: + break; + default: SWSS_LOG_THROW("sai attr value %s is not implemented, FIXME", sai_serialize_attr_value_type(type).c_str()); } } +void sai_deserialize_poe_port_active_channel_type( + _In_ const std::string& s, + _Out_ sai_poe_port_active_channel_type_t& value) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_active_channel_type_t, (int32_t&)value); +} + +void sai_deserialize_poe_port_class_method_type( + _In_ const std::string& s, + _Out_ sai_poe_port_class_method_type_t& value) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_class_method_type_t, (int32_t&)value); +} + +void sai_deserialzie_poe_port_signature_type( + _In_ const std::string& s, + _Out_ sai_poe_port_signature_type_t& value) +{ + SWSS_LOG_ENTER(); + + sai_deserialize_enum(s, &sai_metadata_enum_sai_poe_port_signature_type_t, (int32_t&)value); +} + +void sai_deserialize_poe_port_power_consumption( + _In_ const std::string& s, + _Out_ sai_poe_port_power_consumption_t& value) +{ + SWSS_LOG_ENTER(); + + json j = json::parse(s); + + sai_deserialize_poe_port_active_channel_type(j["active_channel"], value.active_channel); + sai_deserialize_number(j["voltage"], value.voltage); + sai_deserialize_number(j["current"], value.current); + sai_deserialize_number(j["consumption"], value.consumption); + sai_deserialize_poe_port_class_method_type(j["class_method"], value.class_method); + sai_deserialzie_poe_port_signature_type(j["signature_type"],value.signature_type); + sai_deserialize_number(j["measured_class_a"], value.measured_class_a); + sai_deserialize_number(j["assigned_class_a"], value.assigned_class_a); + sai_deserialize_number(j["measured_class_b"], value.measured_class_b); + sai_deserialize_number(j["assigned_class_b"], value.assigned_class_b); +} + // deserialize free notifications void sai_deserialize_free_fdb_event( diff --git a/meta/sai_serialize.h b/meta/sai_serialize.h index f0ebc0960..5e149c409 100644 --- a/meta/sai_serialize.h +++ b/meta/sai_serialize.h @@ -204,6 +204,17 @@ std::string sai_serialize_switch_oper_status( _In_ sai_object_id_t switch_id, _In_ sai_switch_oper_status_t status); +std::string sai_serialize_timespec( + _In_ const sai_timespec_t ×pec); + +std::string sai_serialize_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ const sai_timespec_t ×tamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ const sai_switch_health_data_t &data, + _In_ const sai_u8_list_t &description); + std::string sai_serialize_switch_shutdown_request( _In_ sai_object_id_t switch_id); @@ -220,6 +231,12 @@ std::string sai_serialize_number( _In_ uint32_t number, _In_ bool hex = false); +template +std::string sai_serialize_number_list( + _In_ const T& list, + _In_ bool countOnly, + _In_ bool hex = false); + std::string sai_serialize_attr_id( _In_ const sai_attr_metadata_t& meta); @@ -256,6 +273,9 @@ std::string sai_serialize_qos_map_item( std::string sai_serialize_twamp_session_stat( _In_ const sai_twamp_session_stat_t counter); +std::string sai_serialize_poe_port_power_consumption( + _In_ const sai_poe_port_power_consumption_t& pppc); + // serialize notifications std::string sai_serialize_fdb_event_ntf( @@ -327,6 +347,19 @@ void sai_deserialize_switch_oper_status( _Out_ sai_object_id_t &switch_id, _Out_ sai_switch_oper_status_t& status); +void sai_deserialize_timespec( + _In_ const std::string& s, + _Out_ sai_timespec_t ×tamp); + +void sai_deserialize_switch_asic_sdk_health_event( + _In_ const std::string& s, + _Out_ sai_object_id_t &switch_id, + _Out_ sai_switch_asic_sdk_health_severity_t &severity, + _Out_ sai_timespec_t ×tamp, + _Out_ sai_switch_asic_sdk_health_category_t &category, + _Out_ sai_switch_health_data_t &data, + _Out_ sai_u8_list_t &description); + void sai_deserialize_switch_shutdown_request( _In_ const std::string& s, _Out_ sai_object_id_t &switch_id); @@ -469,6 +502,10 @@ void sai_deserialize_chardata( _In_ const std::string& s, _Out_ char chardata[32]); +void sai_deserialize_poe_port_power_consumption( + _In_ const std::string& s, + _Out_ sai_poe_port_power_consumption_t& pppc); + // deserialize notifications void sai_deserialize_fdb_event_ntf( @@ -536,6 +573,9 @@ void sai_deserialize_free_bfd_session_state_ntf( _In_ uint32_t count, _In_ sai_bfd_session_state_notification_t* bfdsessionstate); +void sai_deserialize_free_switch_asic_sdk_health_event( + _In_ sai_u8_list_t &description); + void sai_deserialize_ingress_priority_group_attr( _In_ const std::string& s, _Out_ sai_ingress_priority_group_attr_t& attr); diff --git a/proxylib/Makefile.am b/proxylib/Makefile.am new file mode 100644 index 000000000..5797451eb --- /dev/null +++ b/proxylib/Makefile.am @@ -0,0 +1,29 @@ +AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/lib -I$(top_srcdir)/meta + +lib_LTLIBRARIES = libsaiproxy.la + +noinst_LIBRARIES = libSaiProxy.a + +libSaiProxy_a_SOURCES = \ + Proxy.cpp \ + Sai.cpp + +BUILT_SOURCES = sai_proxy.cpp + +sai_proxy.cpp: $(top_srcdir)/SAI/meta/saimetadata.c ../stub.pl + ../stub.pl -d ../SAI/ -c Sai -n saiproxy -f sai_proxy.cpp -s stub + +clean-local: + rm -f sai_proxy.cpp + +libsaiproxy_la_SOURCES = sai_proxy.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/Proxy.cpp b/proxylib/Proxy.cpp new file mode 100644 index 000000000..ff789c5fd --- /dev/null +++ b/proxylib/Proxy.cpp @@ -0,0 +1,1053 @@ +#include "Proxy.h" + +#include "swss/logger.h" +#include "swss/select.h" +#include "swss/table.h" + +#include "meta/SaiAttributeList.h" +#include "meta/sai_serialize.h" +#include "meta/ZeroMQSelectableChannel.h" + +#include "syncd/ZeroMQNotificationProducer.h" + +#include +#include + +using namespace saiproxy; +using namespace std::placeholders; + +// TODO we need pointers translation for receiving notifications +// TODO handle diagnostic shell + +Proxy::Proxy( + _In_ std::shared_ptr vendorSai): + m_vendorSai(vendorSai), + m_apiInitialized(false) +{ + SWSS_LOG_ENTER(); + + m_configFile = "config.ini"; // TODO to command line + + // TODO to move hard coded addresses to config + + m_selectableChannel = std::make_shared("tcp://127.0.0.1:5555"); + m_notifications = std::make_shared("tcp://127.0.0.1:5556"); + + loadProfileMap(); + + m_smt.profileGetValue = std::bind(&Proxy::profileGetValue, this, _1, _2); + m_smt.profileGetNextValue = std::bind(&Proxy::profileGetNextValue, this, _1, _2, _3); + + m_test_services = m_smt.getServiceMethodTable(); + + sai_status_t status = m_vendorSai->apiInitialize(0, &m_test_services); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("FATAL: failed to sai_api_initialize: %s", + sai_serialize_status(status).c_str()); + } + else + { + m_apiInitialized = true; + + SWSS_LOG_NOTICE("api initialized success"); + } +} + +Proxy::~Proxy() +{ + SWSS_LOG_ENTER(); + + // TODO call stop() + + if (m_apiInitialized) + { + SWSS_LOG_NOTICE("calling api uninitialize"); + + auto status = m_vendorSai->apiUninitialize(); + + if (status != SAI_STATUS_SUCCESS) + { + SWSS_LOG_ERROR("api uninitialize failed: %s", sai_serialize_status(status).c_str()); + } + } + + // TODO lock guard could be needed to wait for notifications destruction + // until all possible notification thread will be sent + + m_notifications = nullptr; +} + +void Proxy::loadProfileMap() +{ + SWSS_LOG_ENTER(); + + std::ifstream profile(m_configFile.c_str()); + + if (!profile.is_open()) + { + SWSS_LOG_WARN("failed to open profile map file: %s: %s", + m_configFile.c_str(), + strerror(errno)); + + return; + } + + std::string line; + + while (getline(profile, line)) + { + if (line.size() > 0 && (line[0] == '#' || line[0] == ';')) + { + continue; + } + + size_t pos = line.find("="); + + if (pos == std::string::npos) + { + SWSS_LOG_WARN("not found '=' in line %s", line.c_str()); + continue; + } + + std::string key = line.substr(0, pos); + std::string value = line.substr(pos + 1); + + m_profileMap[key] = value; + + SWSS_LOG_NOTICE("insert: %s:%s", key.c_str(), value.c_str()); + } +} + +const char* Proxy::profileGetValue( + _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 = m_profileMap.find(variable); + + if (it == m_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(); +} + +int Proxy::profileGetNextValue( + _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"); + + m_profileIter = m_profileMap.begin(); + return 0; + } + + if (variable == NULL) + { + SWSS_LOG_WARN("variable is null"); + return -1; + } + + if (m_profileIter == m_profileMap.end()) + { + SWSS_LOG_INFO("iterator reached end"); + return -1; + } + + *variable = m_profileIter->first.c_str(); + *value = m_profileIter->second.c_str(); + + SWSS_LOG_INFO("key: %s:%s", *variable, *value); + + m_profileIter++; + + return 0; +} + +void Proxy::run() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_NOTICE("thread start"); + + std::shared_ptr s = std::make_shared(); + + // TODO will we need this thread at all?, maybe just resend notification as they + // arrive ? could this potentially cause deadlock ? if we will be invoking + // some api under mutex and then that ntf would be called from same thread + // as api invoked that's why we have processing queue on syncd here we would + // need only protect ntf sender- notification channel + + // m_processor->startNotificationsProcessingThread(); + + s->addSelectable(m_selectableChannel.get()); + s->addSelectable(&m_stopEvent); + + SWSS_LOG_NOTICE("entering main thread loop"); + + while (true) + { + swss::Selectable *sel = NULL; + + int result = s->select(&sel); + + if (sel == &m_stopEvent) + { + break; + } + else if (sel == m_selectableChannel.get()) + { + processEvent(*m_selectableChannel.get()); + } + else + { + SWSS_LOG_ERROR("select failed: %d", result); + } + } + + SWSS_LOG_NOTICE("thread end"); +} + +void Proxy::stop() +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_NOTICE("stop thread requested"); + + // TODO maybe not needed + std::lock_guard lock(m_mutex); + + m_stopEvent.notify(); +} + +void Proxy::processEvent( + _In_ sairedis::SelectableChannel& consumer) +{ + SWSS_LOG_ENTER(); + + std::lock_guard lock(m_mutex); + + do + { + swss::KeyOpFieldsValuesTuple kco; + + consumer.pop(kco, false); + + processSingleEvent(kco); + } + while (!consumer.empty()); +} + +void Proxy::processSingleEvent( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& key = kfvKey(kco); + auto& op = kfvOp(kco); + + SWSS_LOG_INFO("key: %s op: %s", key.c_str(), op.c_str()); + + if (key.length() == 0) + { + SWSS_LOG_DEBUG("no elements in m_buffer"); + + return; + } + + // TODO implement bulk create/remove/set/get + + if (op == "create") + return processCreate(kco); + + if (op == "remove") + return processRemove(kco); + + if (op == "set") + return processSet(kco); + + if (op == "get") + return processGet(kco); + + if (op == "create_entry") + return processCreateEntry(kco); + + if (op == "flush_fdb_entries") + return processFlushFdbEntries(kco); + + if (op == "object_type_get_availability") + return processObjectTypeGetAvailability(kco); + + if (op == "query_attribute_capability") + return processQueryAttributeCapability(kco); + + if (op == "query_attribute_enum_values_capability") + return processQueryAttributeEnumValuesCapability(kco); + + if (op == "object_type_query") + return processObjectTypeQuery(kco); + + if (op == "switch_id_query") + return processSwitchIdQuery(kco); + + if (op == "query_api_version") + return processQueryApiVersion(kco); + + if (op == "log_set") + return processLogSet(kco); + + if (op == "get_stats") + return processGetStats(kco); + + if (op == "get_stats_ext") + return processGetStatsExt(kco); + + if (op == "clear_stats") + return processClearStats(kco); + + SWSS_LOG_THROW("event op '%s' is not implemented, FIXME", op.c_str()); +} + +void Proxy::processCreate( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + const std::string& strObjectId = key.substr(key.find(":") + 1); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto values = kfvFieldsValues(kco); + + sai_object_id_t switchId = SAI_NULL_OBJECT_ID; + + auto vv = values.back(); + + values.pop_back(); + + SWSS_LOG_NOTICE("removed last field: %s: %s", fvField(vv).c_str(), fvValue(vv).c_str()); + + sai_deserialize_object_id(fvValue(vv), switchId); + + for (auto& v: values) + { + SWSS_LOG_DEBUG("attr: %s: %s", fvField(v).c_str(), fvValue(v).c_str()); + } + + saimeta::SaiAttributeList list(metaKey.objecttype, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + uint32_t attr_count = list.get_attr_count(); + + if (metaKey.objecttype == SAI_OBJECT_TYPE_SWITCH) + { + /* + * TODO: translate notification pointers + * TODO: must be done per switch, and switch may not exists yet + */ + + // TODO + // m_handler->updateNotificationsPointers(attr_count, attr_list); + } + + sai_object_id_t newObjectId = SAI_NULL_OBJECT_ID;; + + sai_status_t status = m_vendorSai->create(metaKey.objecttype, &newObjectId, switchId, attr_count, attr_list); + + std::vector entry; + + std::string strStatus = sai_serialize_status(status); + + swss::FieldValueTuple fvt("OBJECT_ID", sai_serialize_object_id(newObjectId)); + + entry.push_back(fvt); + + m_selectableChannel->set(strStatus, entry, "create_response"); +} + +void Proxy::processRemove( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + const std::string& strObjectId = key.substr(key.find(":") + 1); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + sai_status_t status = m_vendorSai->remove(metaKey); + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, {}, "remove_response"); +} + +void Proxy::processSet( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + const std::string& strObjectId = key.substr(key.find(":") + 1); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto values = kfvFieldsValues(kco); + + for (auto& v: values) + { + SWSS_LOG_DEBUG("attr: %s: %s", fvField(v).c_str(), fvValue(v).c_str()); + } + + saimeta::SaiAttributeList list(metaKey.objecttype, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + + if (metaKey.objecttype == SAI_OBJECT_TYPE_SWITCH) + { + /* + * TODO: translate notification pointers + * TODO: must be done per switch, and switch may not exists yet + */ + + // TODO + // m_handler->updateNotificationsPointers(attr_count, attr_list); + } + + sai_status_t status = m_vendorSai->set(metaKey, attr_list); + + std::vector entry; + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, {}, "set_response"); +} + +void Proxy::processGet( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + const std::string& strObjectId = key.substr(key.find(":") + 1); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto& values = kfvFieldsValues(kco); + + for (auto& v: values) + { + SWSS_LOG_DEBUG("attr: %s: %s", fvField(v).c_str(), fvValue(v).c_str()); + } + + saimeta::SaiAttributeList list(metaKey.objecttype, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + uint32_t attr_count = list.get_attr_count(); + + auto status = m_vendorSai->get(metaKey, attr_count, attr_list); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + entry = saimeta::SaiAttributeList::serialize_attr_list( + metaKey.objecttype, + attr_count, + attr_list, + false); + } + else if (status == SAI_STATUS_BUFFER_OVERFLOW) + { + /* + * In this case we got correct values for list, but list was too small + * so serialize only count without list itself, sairedis will need to + * take this into account when deserialize. + * + * If there was a list somewhere, count will be changed to actual value + * different attributes can have different lists, many of them may + * serialize only count, and will need to support that on the receiver. + */ + + entry = saimeta::SaiAttributeList::serialize_attr_list( + metaKey.objecttype, + attr_count, + attr_list, + true); + } + else + { + /* + * Some other error, don't send attributes at all. + */ + + SWSS_LOG_WARN("api failed: %s", sai_serialize_status(status).c_str()); + } + + std::string strStatus = sai_serialize_status(status); + + SWSS_LOG_INFO("sending response for GET api with status: %s", strStatus.c_str()); + + /* + * Since we have only one get at a time, we don't have to serialize object + * type and object id, only get status is required to be returned. Get + * response will not put any data to table, only queue is used. + */ + + m_selectableChannel->set(strStatus, entry, "get_response"); +} + +void Proxy::processCreateEntry( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + // const std::string& op = kfvOp(kco); + + const std::string& strObjectId = key.substr(key.find(":") + 1); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto values = kfvFieldsValues(kco); + + saimeta::SaiAttributeList list(metaKey.objecttype, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + uint32_t attr_count = list.get_attr_count(); + + // since this is only used for create entries, there is no need for notification + // pointers translation, since object entries don't contain pointers + + sai_status_t status = m_vendorSai->create(metaKey, SAI_NULL_OBJECT_ID, attr_count, attr_list); + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, {}, "create_entry_response"); +} + +void Proxy::processFlushFdbEntries( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& key = kfvKey(kco); + auto strSwitchId = key.substr(key.find(":") + 1); + + sai_object_id_t switchId; + sai_deserialize_object_id(strSwitchId, switchId); + + auto& values = kfvFieldsValues(kco); + + for (const auto &v: values) + { + SWSS_LOG_NOTICE("attr: %s: %s", fvField(v).c_str(), fvValue(v).c_str()); + } + + saimeta::SaiAttributeList list(SAI_OBJECT_TYPE_FDB_FLUSH, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + uint32_t attr_count = list.get_attr_count(); + + sai_status_t status = m_vendorSai->flushFdbEntries(switchId, attr_count, attr_list); + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, {}, "flush_fdb_entries_response"); +} + +void Proxy::processObjectTypeGetAvailability( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& strSwitchId = kfvKey(kco); + + sai_object_id_t switchId; + sai_deserialize_object_id(strSwitchId, switchId); + + std::vector values = kfvFieldsValues(kco); + + sai_object_type_t objectType; + sai_deserialize_object_type(fvValue(values.back()), objectType); + + values.pop_back(); + + saimeta::SaiAttributeList list(objectType, values, false); + + sai_attribute_t *attr_list = list.get_attr_list(); + uint32_t attr_count = list.get_attr_count(); + + uint64_t count; + + sai_status_t status = m_vendorSai->objectTypeGetAvailability( + switchId, + objectType, + attr_count, + attr_list, + &count); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + entry.emplace_back("COUNT", std::to_string(count)); + } + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "object_type_get_availability_response"); +} + +void Proxy::processQueryAttributeCapability( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& strSwitchId = kfvKey(kco); + + sai_object_id_t switchId; + sai_deserialize_object_id(strSwitchId, switchId); + + auto& values = kfvFieldsValues(kco); + + if (values.size() != 2) + { + SWSS_LOG_ERROR("logic error, expected 2 arguments, received %zu", values.size()); + + auto strStatus = sai_serialize_status(SAI_STATUS_INVALID_PARAMETER); + + m_selectableChannel->set(strStatus, {}, "query_attribute_capability_response"); + + return; + } + + sai_object_type_t objectType; + sai_deserialize_object_type(fvValue(values[0]), objectType); + + sai_attr_id_t attrId; + sai_deserialize_attr_id(fvValue(values[1]), attrId); + + sai_attr_capability_t capability; + + sai_status_t status = m_vendorSai->queryAttributeCapability(switchId, objectType, attrId, &capability); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + entry = + { + swss::FieldValueTuple("CREATE_IMPLEMENTED", (capability.create_implemented ? "true" : "false")), + swss::FieldValueTuple("SET_IMPLEMENTED", (capability.set_implemented ? "true" : "false")), + swss::FieldValueTuple("GET_IMPLEMENTED", (capability.get_implemented ? "true" : "false")) + }; + } + + auto strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "query_attribute_capability_response"); +} + +void Proxy::processQueryAttributeEnumValuesCapability( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& strSwitchId = kfvKey(kco); + + sai_object_id_t switchId; + sai_deserialize_object_id(strSwitchId, switchId); + + auto& values = kfvFieldsValues(kco); + + if (values.size() != 3) + { + SWSS_LOG_ERROR("logic error, expected 3 arguments, received %zu", values.size()); + + auto strStatus = sai_serialize_status(SAI_STATUS_INVALID_PARAMETER); + + m_selectableChannel->set(strStatus, {}, "query_attribute_enum_values_capability_response"); + + return; + } + + sai_object_type_t objectType; + sai_deserialize_object_type(fvValue(values[0]), objectType); + + sai_attr_id_t attrId; + sai_deserialize_attr_id(fvValue(values[1]), attrId); + + uint32_t list_size = std::stoi(fvValue(values[2])); + + std::vector enum_capabilities_list(list_size); + + sai_s32_list_t enumCapList; + + enumCapList.count = list_size; + enumCapList.list = enum_capabilities_list.data(); + + sai_status_t status = m_vendorSai->queryAttributeEnumValuesCapability(switchId, objectType, attrId, &enumCapList); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + std::vector vec; + std::transform(enumCapList.list, enumCapList.list + enumCapList.count, + std::back_inserter(vec), [](auto&e) { return std::to_string(e); }); + + std::ostringstream join; + std::copy(vec.begin(), vec.end(), std::ostream_iterator(join, ",")); + + auto strCap = join.str(); + + entry = + { + swss::FieldValueTuple("ENUM_CAPABILITIES", strCap), + swss::FieldValueTuple("ENUM_COUNT", std::to_string(enumCapList.count)) + }; + } + else if (status == SAI_STATUS_BUFFER_OVERFLOW) + { + entry = + { + swss::FieldValueTuple("ENUM_COUNT", std::to_string(enumCapList.count)) + }; + } + + auto strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "query_attribute_enum_values_capability_response"); +} + +void Proxy::processObjectTypeQuery( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + sai_object_id_t objectId; + sai_deserialize_object_id(key, objectId); + + sai_object_type_t objectType = m_vendorSai->objectTypeQuery(objectId); + + std::vector entry; + + std::string strStatus = sai_serialize_status(SAI_STATUS_SUCCESS); // we assume success + + entry.emplace_back("OBJECT_TYPE", sai_serialize_object_type(objectType)); + + m_selectableChannel->set(strStatus, entry, "object_type_query_response"); +} + +void Proxy::processSwitchIdQuery( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + sai_object_id_t objectId; + sai_deserialize_object_id(key, objectId); + + sai_object_id_t switchId = m_vendorSai->switchIdQuery(objectId); + + std::vector entry; + + std::string strStatus = sai_serialize_status(SAI_STATUS_SUCCESS); // we assume success + + entry.emplace_back("OBJECT_ID", sai_serialize_object_id(switchId)); + + m_selectableChannel->set(strStatus, entry, "switch_id_query_response"); +} + +void Proxy::processQueryApiVersion( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + sai_api_version_t version; + + sai_status_t status = m_vendorSai->queryApiVersion(&version); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + entry.emplace_back("VERSION", std::to_string(version)); + + SWSS_LOG_NOTICE("query api version returned: %ld", version); + } + + auto strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "query_api_version_response"); +} + +void Proxy::processLogSet( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + auto& key = kfvKey(kco); + + auto strApi = key.substr(0, key.find(":")); + auto strLogLevel = key.substr(key.find(":") + 1); + + sai_api_t api; + sai_deserialize_api(strApi, api); + + sai_log_level_t level; + sai_deserialize_log_level(strLogLevel, level); + + sai_status_t status = m_vendorSai->logSet(api, level); + + auto strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, {}, "log_set_response"); +} + +void Proxy::processGetStats( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto oi = sai_metadata_get_object_type_info(metaKey.objecttype); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(metaKey.objecttype).c_str()); + + std::string strStatus = sai_serialize_status(SAI_STATUS_FAILURE); + + m_selectableChannel->set(strStatus, {}, "get_stats_response"); + + return; + } + + auto &values = kfvFieldsValues(kco); + + uint32_t numberOfCounters = (uint32_t)values.size(); + + std::vector counterIds; + std::vector counters; + + for (const auto&fv: values) + { + sai_stat_id_t stat; + sai_deserialize_enum(fvField(fv), oi->statenum, (int32_t&)stat); + + counters.push_back(stat); + } + + auto status = m_vendorSai->getStats( + metaKey.objecttype, + metaKey.objectkey.key.object_id, + numberOfCounters, + counterIds.data(), + counters.data()); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + for (auto c: counters) + { + entry.emplace_back("", std::to_string(c)); + } + } + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "get_stats_response"); +} + +void Proxy::processGetStatsExt( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto oi = sai_metadata_get_object_type_info(metaKey.objecttype); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(metaKey.objecttype).c_str()); + + std::string strStatus = sai_serialize_status(SAI_STATUS_FAILURE); + + m_selectableChannel->set(strStatus, {}, "get_stats_ext_response"); + + return; + } + + auto values = kfvFieldsValues(kco); + + sai_stats_mode_t mode = (sai_stats_mode_t)stoull(fvValue(values.back())); + + values.pop_back(); + + uint32_t numberOfCounters = (uint32_t)values.size(); + + std::vector counterIds; + std::vector counters; + + for (const auto&fv: values) + { + sai_stat_id_t stat; + sai_deserialize_enum(fvField(fv), oi->statenum, (int32_t&)stat); + + counters.push_back(stat); + } + + auto status = m_vendorSai->getStatsExt( + metaKey.objecttype, + metaKey.objectkey.key.object_id, + numberOfCounters, + counterIds.data(), + mode, + counters.data()); + + std::vector entry; + + if (status == SAI_STATUS_SUCCESS) + { + for (auto c: counters) + { + entry.emplace_back("", std::to_string(c)); + } + } + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "get_stats_ext_response"); +} + +void Proxy::processClearStats( + _In_ const swss::KeyOpFieldsValuesTuple &kco) +{ + SWSS_LOG_ENTER(); + + const std::string& key = kfvKey(kco); + + sai_object_meta_key_t metaKey; + sai_deserialize_object_meta_key(key, metaKey); + + if (!sai_metadata_is_object_type_valid(metaKey.objecttype)) + { + SWSS_LOG_THROW("invalid object type %s", key.c_str()); + } + + auto oi = sai_metadata_get_object_type_info(metaKey.objecttype); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(metaKey.objecttype).c_str()); + + std::string strStatus = sai_serialize_status(SAI_STATUS_FAILURE); + + m_selectableChannel->set(strStatus, {}, "clear_stats_response"); + + return; + } + + auto &values = kfvFieldsValues(kco); + + uint32_t numberOfCounters = (uint32_t)values.size(); + + std::vector counterIds; + std::vector counters; + + for (const auto&fv: values) + { + sai_stat_id_t stat; + sai_deserialize_enum(fvField(fv), oi->statenum, (int32_t&)stat); + + counters.push_back(stat); + } + + auto status = m_vendorSai->clearStats( + metaKey.objecttype, + metaKey.objectkey.key.object_id, + numberOfCounters, + counterIds.data()); + + std::vector entry; + + std::string strStatus = sai_serialize_status(status); + + m_selectableChannel->set(strStatus, entry, "clear_stats_response"); +} diff --git a/proxylib/Proxy.h b/proxylib/Proxy.h new file mode 100644 index 000000000..8fc3b6424 --- /dev/null +++ b/proxylib/Proxy.h @@ -0,0 +1,133 @@ +#pragma once + +#include "swss/selectableevent.h" + +#include "meta/SaiInterface.h" +#include "meta/SelectableChannel.h" + +#include "syncd/ServiceMethodTable.h" +#include "syncd/NotificationProducerBase.h" + +#include +#include +#include +#include + +namespace saiproxy +{ + class Proxy + { + public: + + Proxy( + _In_ std::shared_ptr vendorSai); + + virtual ~Proxy(); + + public: + + void run(); + + void stop(); + + private: + + const char* profileGetValue( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable); + + int profileGetNextValue( + _In_ sai_switch_profile_id_t profile_id, + _Out_ const char** variable, + _Out_ const char** value); + + void processEvent( + _In_ sairedis::SelectableChannel& consumer); + + void processSingleEvent( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + private: // api process methods + + // TODO implement bulk apis + + void processCreate( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processRemove( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processSet( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processGet( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processCreateEntry( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processFlushFdbEntries( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processObjectTypeGetAvailability( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processQueryAttributeCapability( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processQueryAttributeEnumValuesCapability( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processObjectTypeQuery( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processSwitchIdQuery( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processQueryApiVersion( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processLogSet( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processGetStats( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processGetStatsExt( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + void processClearStats( + _In_ const swss::KeyOpFieldsValuesTuple &kco); + + private: + + void loadProfileMap(); + + private: + + syncd::ServiceMethodTable m_smt; + + sai_service_method_table_t m_test_services; + + std::shared_ptr m_vendorSai; + + swss::SelectableEvent m_stopEvent; + + std::map m_profileMap; + + std::map::iterator m_profileIter; + + std::shared_ptr m_selectableChannel; + + std::shared_ptr m_notifications; + + std::string m_configFile; + + /** + * @brief Mutex for synchronizing api execution and notifications + */ + std::mutex m_mutex; + + bool m_apiInitialized; + }; +} diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp new file mode 100644 index 000000000..e99c6989f --- /dev/null +++ b/proxylib/Sai.cpp @@ -0,0 +1,1148 @@ +#include "Sai.h" +#include "Utils.h" +#include "SaiInternal.h" +#include "ZeroMQChannel.h" +#include "SaiAttributeList.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) + { + apiUninitialize(); + } +} + +// INITIALIZE UNINITIALIZE + +sai_status_t Sai::apiInitialize( + _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 hard coded values to config + + m_communicationChannel = std::make_shared( + "tcp://127.0.0.1:5555", + "tcp://127.0.0.1:5556", + std::bind(&Sai::handleNotification, this, _1, _2, _3)); + + m_apiInitialized = true; + + return SAI_STATUS_SUCCESS; +} + +sai_status_t Sai::apiUninitialize(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(); + + auto entry = saimeta::SaiAttributeList::serialize_attr_list(objectType, attr_count, attr_list, false); + + entry.emplace_back("SWITCH_ID", sai_serialize_object_id(switchId)); // last entry is switch_id + + auto serializedObjectType = sai_serialize_object_type(objectType); + + auto serializedObjectId = sai_serialize_object_id(SAI_NULL_OBJECT_ID); + + std::string key = serializedObjectType + ":" + serializedObjectId; + + m_communicationChannel->set(key, entry, "create"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("create_response", kco); + + // TODO SAVE pointers for notifications + + if (status == SAI_STATUS_SUCCESS) + { + auto& values = kfvFieldsValues(kco); + + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + SWSS_LOG_NOTICE("deserialize new object id: %s", fvValue(values[0]).c_str()); + + sai_deserialize_object_id(fvValue(values[0]), *objectId); + } + + return status; +} + +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(); + + return remove(objectType, sai_serialize_object_id(objectId)); +} + +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(); + + return set(objectType, sai_serialize_object_id(objectId), attr); +} + +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(); + + return get(objectType, sai_serialize_object_id(objectId), attr_count, attr_list); +} + +// 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) \ + return create( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + sai_serialize_ ## ot(*entry), \ + attr_count, \ + attr_list); \ +} + +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) \ + return remove( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + sai_serialize_ ## ot(*entry)); \ +} + +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) \ + return set( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + sai_serialize_ ## ot(*entry), \ + attr); \ +} + +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) \ + return get( \ + (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ + sai_serialize_ ## ot(*entry), \ + attr_count, \ + attr_list); \ +} + +SAIREDIS_DECLARE_EVERY_ENTRY(DECLARE_GET_ENTRY); + +sai_status_t Sai::create( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + auto vals = saimeta::SaiAttributeList::serialize_attr_list(objectType, attr_count, attr_list, false); + + auto serializedObjectType = sai_serialize_object_type(objectType); + + std::string key = serializedObjectType + ":" + entry; + + // TODO SAVE pointers for notifications + + m_communicationChannel->set(key, vals, "create_entry"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("create_entry_response", kco); +} + +sai_status_t Sai::remove( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry) +{ + SWSS_LOG_ENTER(); + + auto serializedObjectType = sai_serialize_object_type(objectType); + + std::string key = serializedObjectType + ":" + entry; + + m_communicationChannel->set(key, {}, "remove"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("remove_response", kco); +} + +sai_status_t Sai::set( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ const sai_attribute_t *attr) +{ + SWSS_LOG_ENTER(); + + auto val = saimeta::SaiAttributeList::serialize_attr_list(objectType, 1, attr, false); + + // TODO SAVE pointers for notifications + + auto serializedObjectType = sai_serialize_object_type(objectType); + + std::string key = serializedObjectType + ":" + entry; + + m_communicationChannel->set(key, val, "set"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("set_response", kco); +} + +sai_status_t Sai::get( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list) +{ + SWSS_LOG_ENTER(); + + /* + * Since user may reuse buffers, then oid list buffers maybe not cleared + * and contain some garbage, let's clean them so we send all oids as null to + * syncd. + */ + + sairedis::Utils::clearOidValues(objectType, attr_count, attr_list); + + auto vals = saimeta::SaiAttributeList::serialize_attr_list(objectType, attr_count, attr_list, false); + + std::string serializedObjectType = sai_serialize_object_type(objectType); + + std::string key = serializedObjectType + ":" + entry; + + m_communicationChannel->set(key, vals, "get"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("get_response", kco); + + auto &values = kfvFieldsValues(kco); + + if (status == SAI_STATUS_SUCCESS) + { + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + saimeta::SaiAttributeList list(objectType, values, false); + + transfer_attributes(objectType, attr_count, list.get_attr_list(), attr_list, false); + } + else if (status == SAI_STATUS_BUFFER_OVERFLOW) + { + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + saimeta::SaiAttributeList list(objectType, values, true); + + transfer_attributes(objectType, attr_count, list.get_attr_list(), attr_list, true); + } + + return status; +} + +// 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(); + + auto oi = sai_metadata_get_object_type_info(object_type); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(object_type).c_str()); + + return SAI_STATUS_INVALID_PARAMETER; + } + + auto strObjectType = sai_serialize_object_type(object_type); + auto strObjectId = sai_serialize_object_id(object_id); + + std::string key = strObjectType + ":" + strObjectId; + + std::vector entry; + + for (uint32_t i = 0; i < number_of_counters; i++) + { + entry.emplace_back(sai_serialize_enum(counter_ids[i], oi->statenum), ""); + } + + m_communicationChannel->set(key, entry, "get_stats"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("get_stats_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto &values = kfvFieldsValues(kco); + + if (values.size () != number_of_counters) + { + SWSS_LOG_THROW("logic error, wrong number of counters, got %zu, expected %u", values.size(), number_of_counters); + } + + for (uint32_t idx = 0; idx < number_of_counters; idx++) + { + counters[idx] = stoull(fvValue(values[idx])); + } + } + + return status; +} + +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(); + + auto oi = sai_metadata_get_object_type_info(object_type); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(object_type).c_str()); + + return SAI_STATUS_INVALID_PARAMETER; + } + + auto strObjectType = sai_serialize_object_type(object_type); + auto strObjectId = sai_serialize_object_id(object_id); + + std::string key = strObjectType + ":" + strObjectId; + + std::vector entry; + + for (uint32_t i = 0; i < number_of_counters; i++) + { + entry.emplace_back(sai_serialize_enum(counter_ids[i], oi->statenum), ""); + } + + entry.emplace_back("STATS_MODE", std::to_string(mode)); // TODO add serialize + + m_communicationChannel->set(key, entry, "get_stats_ext"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("get_stats_ext_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto &values = kfvFieldsValues(kco); + + if (values.size () != number_of_counters) + { + SWSS_LOG_THROW("logic error, wrong number of counters, got %zu, expected %u", values.size(), number_of_counters); + } + + for (uint32_t idx = 0; idx < number_of_counters; idx++) + { + counters[idx] = stoull(fvValue(values[idx])); + } + } + + return status; +} + +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(); + + auto oi = sai_metadata_get_object_type_info(object_type); + + if (oi == NULL) + { + SWSS_LOG_ERROR("invalid object type: %s", sai_serialize_object_type(object_type).c_str()); + + return SAI_STATUS_INVALID_PARAMETER; + } + + auto strObjectType = sai_serialize_object_type(object_type); + auto strObjectId = sai_serialize_object_id(object_id); + + std::string key = strObjectType + ":" + strObjectId; + + std::vector entry; + + for (uint32_t i = 0; i < number_of_counters; i++) + { + entry.emplace_back(sai_serialize_enum(counter_ids[i], oi->statenum), ""); + } + + m_communicationChannel->set(key, entry, "clear_stats"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("clear_stats_response", kco); +} + +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; +} + +// BULK STATS + +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; +} + +sai_status_t Sai::bulkGet( + _In_ sai_object_type_t object_type, + _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) +{ + MUTEX(); + SWSS_LOG_ENTER(); + + 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); + +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t Sai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_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(); + + auto entry = saimeta::SaiAttributeList::serialize_attr_list( + SAI_OBJECT_TYPE_FDB_FLUSH, + attr_count, + attr_list, + false); + + std::string serializedObjectId = sai_serialize_object_type(SAI_OBJECT_TYPE_FDB_FLUSH); + + // NOTE ! we actually give switch ID since FLUSH is not real object + std::string key = serializedObjectId + ":" + sai_serialize_object_id(switch_id); + + SWSS_LOG_NOTICE("flush key: %s, fields: %lu", key.c_str(), entry.size()); + + m_communicationChannel->set(key, entry, "flush_fdb_entries"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("flush_fdb_entries_response", kco); +} + +// 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(); + + auto strSwitchId = sai_serialize_object_id(switchId); + + auto entry = saimeta::SaiAttributeList::serialize_attr_list(objectType, attrCount, attrList, false); + + entry.emplace_back("OBJECT_TYPE", sai_serialize_object_type(objectType)); + + m_communicationChannel->set(strSwitchId, entry, "object_type_get_availability"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("object_type_get_availability_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto& values = kfvFieldsValues(kco); + + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + *count = std::stoull(fvValue(values[0])); + } + + return status; +} + +sai_status_t Sai::queryAttributeCapability( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t objectType, + _In_ sai_attr_id_t attrId, + _Out_ sai_attr_capability_t *capability) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + auto strSwitchId = sai_serialize_object_id(switchId); + auto strObjectType = sai_serialize_object_type(objectType); + + auto meta = sai_metadata_get_attr_metadata(objectType, attrId); + + if (meta == NULL) + { + SWSS_LOG_ERROR("Failed to find attribute metadata: object type %s, attr id %d", strObjectType.c_str(), attrId); + + return SAI_STATUS_INVALID_PARAMETER; + } + + const std::string attrIdStr = meta->attridname; + + const std::vector entry = + { + swss::FieldValueTuple("OBJECT_TYPE", strObjectType), + swss::FieldValueTuple("ATTR_ID", attrIdStr) + }; + + m_communicationChannel->set(strSwitchId, entry, "query_attribute_capability"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("query_attribute_capability_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto &values = kfvFieldsValues(kco); + + if (values.size() != 3) + { + SWSS_LOG_ERROR("logic error, api returned invalin numer in response: expected 3 values, received %zu", values.size()); + + return SAI_STATUS_FAILURE; + } + + capability->create_implemented = (fvValue(values[0]) == "true" ? true : false); + capability->set_implemented = (fvValue(values[1]) == "true" ? true : false); + capability->get_implemented = (fvValue(values[2]) == "true" ? true : false); + } + + return status; +} + +sai_status_t Sai::queryAttributeEnumValuesCapability( + _In_ sai_object_id_t switchId, + _In_ sai_object_type_t objectType, + _In_ sai_attr_id_t attrId, + _Inout_ sai_s32_list_t *enumValuesCapability) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + if (enumValuesCapability && enumValuesCapability->list) + { + // clear input list, since we use serialize to transfer values + for (uint32_t idx = 0; idx < enumValuesCapability->count; idx++) + { + enumValuesCapability->list[idx] = 0; + } + } + + auto strSwitchId = sai_serialize_object_id(switchId); + auto strObjectType = sai_serialize_object_type(objectType); + + auto meta = sai_metadata_get_attr_metadata(objectType, attrId); + + if (meta == NULL) + { + SWSS_LOG_ERROR("Failed to find attribute metadata: object type %s, attr id %d", strObjectType.c_str(), attrId); + + return SAI_STATUS_INVALID_PARAMETER; + } + + const std::string strAttrId = meta->attridname; + const std::string listSize = std::to_string(enumValuesCapability->count); + + const std::vector entry = + { + swss::FieldValueTuple("OBJECT_TYPE", strObjectType), + swss::FieldValueTuple("ATTR_ID", strAttrId), + swss::FieldValueTuple("LIST_SIZE", listSize) + }; + + m_communicationChannel->set(strSwitchId, entry, "query_attribute_enum_values_capability"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("query_attribute_enum_values_capability_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + const std::vector &values = kfvFieldsValues(kco); + + if (values.size() != 2) + { + SWSS_LOG_ERROR("logic error, expected 2 values, received %zu", values.size()); + + return SAI_STATUS_FAILURE; + } + + const std::string &capability_str = fvValue(values[0]); + const uint32_t num_capabilities = std::stoi(fvValue(values[1])); + + enumValuesCapability->count = num_capabilities; + + size_t position = 0; + + for (uint32_t i = 0; i < num_capabilities; i++) + { + size_t old_position = position; + position = capability_str.find(",", old_position); + std::string capability = capability_str.substr(old_position, position - old_position); + enumValuesCapability->list[i] = std::stoi(capability); + + // We have run out of values to add to our list + if (position == std::string::npos) + { + if (num_capabilities != i + 1) + { + SWSS_LOG_WARN("Query returned less attributes than expected: expected %d, received %d", num_capabilities, i+1); + } + + break; + } + + // Skip the commas + position++; + } + } + else if (status == SAI_STATUS_BUFFER_OVERFLOW) + { + const auto &values = kfvFieldsValues(kco); + + if (values.size() != 1) + { + SWSS_LOG_ERROR("logic error, expected 1 value, received %zu", values.size()); + + return SAI_STATUS_FAILURE; + } + + enumValuesCapability->count = std::stoi(fvValue(values[0])); + } + + return status; +} + +sai_object_type_t Sai::objectTypeQuery( + _In_ sai_object_id_t objectId) +{ + MUTEX(); + SWSS_LOG_ENTER(); + + if (!m_apiInitialized) + { + SWSS_LOG_ERROR("%s: api not initialized", __PRETTY_FUNCTION__); + + return SAI_OBJECT_TYPE_NULL; + } + + auto key = sai_serialize_object_id(objectId); + + m_communicationChannel->set(key, {}, "object_type_query"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("object_type_query_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto& values = kfvFieldsValues(kco); + + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + sai_object_type_t objectType; + sai_deserialize_object_type(fvValue(values[0]), objectType); + + return objectType; + } + else + { + SWSS_LOG_ERROR("switchIdQuery failed: %s", sai_serialize_status(status).c_str()); + } + + 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: api not initialized", __PRETTY_FUNCTION__); + + return SAI_NULL_OBJECT_ID; + } + + auto key = sai_serialize_object_id(objectId); + + m_communicationChannel->set(key, {}, "switch_id_query"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("switch_id_query_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto& values = kfvFieldsValues(kco); + + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + sai_object_id_t switchId; + sai_deserialize_object_id(fvValue(values[0]), switchId); + + return switchId; + } + else + { + SWSS_LOG_ERROR("switchIdQuery failed: %s", sai_serialize_status(status).c_str()); + } + + 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(); + + auto key = sai_serialize_api(api) + ":" + sai_serialize_log_level(log_level); + + m_communicationChannel->set(key, {}, "log_set"); + + swss::KeyOpFieldsValuesTuple kco; + + return m_communicationChannel->wait("log_set_response", kco); +} + +sai_status_t Sai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + PROXY_CHECK_API_INITIALIZED(); + + SWSS_LOG_NOTICE("compiled proxy headers SAI API version: %d", SAI_API_VERSION); + + if (version == NULL) + { + SWSS_LOG_ERROR("version parameter is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; + } + + m_communicationChannel->set("api", {}, "query_api_version"); + + swss::KeyOpFieldsValuesTuple kco; + + auto status = m_communicationChannel->wait("query_api_version_response", kco); + + if (status == SAI_STATUS_SUCCESS) + { + auto& values = kfvFieldsValues(kco); + + if (values.size() == 0) + { + SWSS_LOG_THROW("logic error, api returned 0 values!"); + } + + SWSS_LOG_NOTICE("returned sai api version: %s", fvValue(values[0]).c_str()); + + *version = std::stoull(fvValue(values[0])); + } + + return status; +} + +void Sai::handleNotification( + _In_ const std::string &name, + _In_ const std::string &serializedNotification, + _In_ const std::vector &values) +{ + SWSS_LOG_ENTER(); + + SWSS_LOG_ERROR("FIXME"); +} + +//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..889eb7b63 --- /dev/null +++ b/proxylib/Sai.h @@ -0,0 +1,236 @@ +#pragma once + +#include + +#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 apiInitialize( + _In_ uint64_t flags, + _In_ const sai_service_method_table_t *service_method_table) override; + + sai_status_t apiUninitialize(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; + + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) 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 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 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 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 queryAttributeEnumValuesCapability( + _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; + + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + + private: // QUAD helpers for entry + + virtual sai_status_t create( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ uint32_t attr_count, + _In_ const sai_attribute_t *attr_list); + + virtual sai_status_t remove( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry); + + virtual sai_status_t set( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ const sai_attribute_t *attr); + + virtual sai_status_t get( + _In_ sai_object_type_t objectType, + _In_ const std::string& entry, + _In_ uint32_t attr_count, + _Inout_ sai_attribute_t *attr_list); + + private: + + sai_switch_notifications_t handle_notification( + _In_ std::shared_ptr notification); + + void handleNotification( + _In_ const std::string &name, + _In_ const std::string &serializedNotification, + _In_ const std::vector &values); + + 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/saidiscovery/saidiscovery.cpp b/saidiscovery/saidiscovery.cpp index e36305a82..ef332a36c 100644 --- a/saidiscovery/saidiscovery.cpp +++ b/saidiscovery/saidiscovery.cpp @@ -554,7 +554,7 @@ int main(int argc, char **argv) auto sai = std::make_shared(vendorSai); - sai_status_t status = sai->initialize(0, (sai_service_method_table_t*)&test_services); + sai_status_t status = sai->apiInitialize(0, (sai_service_method_table_t*)&test_services); if (status != SAI_STATUS_SUCCESS) { @@ -665,7 +665,7 @@ int main(int argc, char **argv) sai_serialize_status(status).c_str()); } - status = sai->uninitialize(); + status = sai->apiUninitialize(); if (status != SAI_STATUS_SUCCESS) { diff --git a/saiplayer/SaiPlayer.cpp b/saiplayer/SaiPlayer.cpp index 7649008f0..4437f2906 100644 --- a/saiplayer/SaiPlayer.cpp +++ b/saiplayer/SaiPlayer.cpp @@ -87,6 +87,7 @@ SaiPlayer::SaiPlayer( m_sn.onFdbEvent = std::bind(&SaiPlayer::onFdbEvent, this, _1, _2); m_sn.onPortStateChange = std::bind(&SaiPlayer::onPortStateChange, this, _1, _2); m_sn.onQueuePfcDeadlock = std::bind(&SaiPlayer::onQueuePfcDeadlock, this, _1, _2); + m_sn.onSwitchAsicSdkHealthEvent = std::bind(&SaiPlayer::onSwitchAsicSdkHealthEvent, this, _1, _2, _3, _4, _5, _6); m_sn.onSwitchShutdownRequest = std::bind(&SaiPlayer::onSwitchShutdownRequest, this, _1); m_sn.onSwitchStateChange = std::bind(&SaiPlayer::onSwitchStateChange, this, _1, _2); m_sn.onBfdSessionStateChange = std::bind(&SaiPlayer::onBfdSessionStateChange, this, _1, _2); @@ -195,6 +196,19 @@ void SaiPlayer::onQueuePfcDeadlock( // empty } +void SaiPlayer::onSwitchAsicSdkHealthEvent( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); + + // empty +} + void SaiPlayer::onSwitchShutdownRequest( _In_ sai_object_id_t switch_id) { @@ -1684,6 +1698,23 @@ sai_status_t SaiPlayer::handle_bulk_entry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + + for (size_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(object_ids[it], entries[it]); + + entries[it].switch_id = translate_local_to_redis(entries[it].switch_id); + entries[it].rif_id = translate_local_to_redis(entries[it].rif_id); + } + + CALL_BULK_CREATE_API_WITH_TIMER("neighbor_entry"); + + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { @@ -1862,6 +1893,23 @@ sai_status_t SaiPlayer::handle_bulk_entry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + + for (size_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(object_ids[it], entries[it]); + + entries[it].switch_id = translate_local_to_redis(entries[it].switch_id); + entries[it].rif_id = translate_local_to_redis(entries[it].rif_id); + } + + CALL_BULK_REMOVE_API_WITH_TIMER("neighbor_entry"); + + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { @@ -2047,6 +2095,23 @@ sai_status_t SaiPlayer::handle_bulk_entry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + + for (size_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(object_ids[it], entries[it]); + + entries[it].switch_id = translate_local_to_redis(entries[it].switch_id); + entries[it].rif_id = translate_local_to_redis(entries[it].rif_id); + } + + CALL_BULK_SET_API_WITH_TIMER("neighbor_entry"); + + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { @@ -2438,6 +2503,7 @@ void SaiPlayer::processBulk( switch ((int)object_type) { case SAI_OBJECT_TYPE_ROUTE_ENTRY: + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: case SAI_OBJECT_TYPE_FDB_ENTRY: case SAI_OBJECT_TYPE_NAT_ENTRY: case SAI_OBJECT_TYPE_DIRECTION_LOOKUP_ENTRY: @@ -2836,7 +2902,7 @@ int SaiPlayer::run() m_test_services = m_smt.getServiceMethodTable(); - EXIT_ON_ERROR(m_sai->initialize(0, &m_test_services)); + EXIT_ON_ERROR(m_sai->apiInitialize(0, &m_test_services)); sai_attribute_t attr; @@ -2889,7 +2955,7 @@ int SaiPlayer::run() exitcode = replay(); } - m_sai->uninitialize(); + m_sai->apiUninitialize(); return exitcode; } diff --git a/saiplayer/SaiPlayer.h b/saiplayer/SaiPlayer.h index 10efad7f9..b8adc10f0 100644 --- a/saiplayer/SaiPlayer.h +++ b/saiplayer/SaiPlayer.h @@ -229,6 +229,14 @@ namespace saiplayer _In_ uint32_t count, _In_ const sai_queue_deadlock_notification_data_t *data); + void onSwitchAsicSdkHealthEvent( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description); + void onSwitchShutdownRequest( _In_ sai_object_id_t switch_id) __attribute__ ((noreturn)); diff --git a/stub.pl b/stub.pl new file mode 100755 index 000000000..208d8e9d0 --- /dev/null +++ b/stub.pl @@ -0,0 +1,433 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use diagnostics; +use sort 'stable'; + +use Getopt::Std; +use Data::Dumper; +use Term::ANSIColor; + +my %options = (); +getopts("d:c:n:f:s:", \%options); + +my $optionSaiDir = $options{d} if defined $options{d}; +my $optionClass = $options{c} if defined $options{c}; +my $optionNamespace = $options{n} if defined $options{n}; +my $optionFileName = $options{f} if defined $options{f}; +my $optionStub = $options{s} if defined $options{s}; + +my $STUB = $optionStub; + +my $DATA = ""; +my @OBJECT_TYPES = (); +my %objectTypes = (); +my @APIS = (); +my @FUNCTIONS = (); +my %FUNCTIONS = (); +my @globalApis = (); +my @apiStructs = (); +my %apiStructs = (); +my %ENTRIES = (); + +my $SOURCE_CONTENT = ""; + +my $warnings = 0; +my $errors = 0; + +sub LogInfo +{ + print color('bright_green') . "@_" . color('reset') . "\n"; +} + +sub LogWarning +{ + $warnings++; + print color('bright_yellow') . "WARNING: @_" . color('reset') . "\n"; +} + +sub LogError +{ + $errors++; + print color('bright_red') . "ERROR: @_" . color('reset') . "\n"; + exit 1; +} + +sub WriteFile +{ + my ($file, $content) = @_; + + open (F, ">", $file) or die "$0: open $file $!"; + + print F $content; + + close F; +} + +sub Write +{ + my $content = shift; + + my $ident = ""; #GetIdent($content); + + my $line = $ident . $content . "\n"; + + $line = "\n" if $content eq ""; + + $SOURCE_CONTENT .= $line; +} + +sub GetFunctionCamelCaseName +{ + my $fun = shift; + + $fun =~ s/^sai_//; + + my @tokens = split/_/,$fun; + + @tokens = map{ucfirst}@tokens; + + shift @tokens if $tokens[0] eq "api"; + + $tokens[0] = lcfirst $tokens[0]; + + $fun = join("",@tokens); + + return $fun; +} + +sub GetData +{ + $DATA = `cat $optionSaiDir/inc/sai*.h $optionSaiDir/experimental/sai*.h`; +} + +sub SanitizeData +{ + $DATA =~ s/SAI_OBJECT_TYPE_\w*(START|END|NULL|MAX)//gms; + $DATA =~ s/SAI_API_\w*(START|END|UNSPECIFIED|MAX)//gms; +} + +sub ExtractData +{ + @OBJECT_TYPES = $DATA =~ /^\s+SAI_OBJECT_TYPE\_(\w+)/gms; + @APIS = $DATA =~ /^\s+SAI_API\_(\w+)/gms; + + for my $ot (@OBJECT_TYPES) + { + $objectTypes{lc$ot} = $ot; + } + + @FUNCTIONS = $DATA =~ /(typedef sai_status_t \(\*(?:sai_\w+_fn)\).*?\))/gms; + + @globalApis = $DATA =~ /^((?:sai_\w+)\s+(?:sai_\w+).+?\))/gms; + + for my $fun (@FUNCTIONS) + { + next if not $fun =~ /sai_\w+\s+.*?(sai_\w+)/gms; + + $FUNCTIONS{$1} = $fun; + } + + @apiStructs = $DATA =~ /(_sai_\w+_api_t.+?sai_\w+_api_t)/gms; + + for my $struct (@apiStructs) + { + next if not $struct =~ /sai_(\w+)_api_t/; + + $apiStructs{$1} = $struct; + } + + my @entries = $DATA =~ /\bsai_(\w+_entry)_t\b/gms; + + for my $e (@entries) + { + $ENTRIES{uc$e} = $e; + } +} + +sub Entry +{ + my $i = shift; + $i =~ s/entries/entry/; + return $i; +} + +sub GetFunctionName +{ + my $fun = shift; + + my $OT = ""; + my $bulk = 0; + my $entry = 0; + + if ($fun =~ /(get|clear)_(\w+)_(stats(_ext)?)/ and defined $objectTypes{$2}) + { + $OT = $objectTypes{$2}; + $fun = "$1_$3"; + } + elsif ($fun =~ /(create|remove|set|get)_(\w+_entries)/ and defined $objectTypes{Entry($2)}) + { + $bulk = 1; + $OT = $objectTypes{Entry($2)}; + $fun = "bulk_$1"; + } + elsif ($fun =~ /(set|get)_(\w+)s_attribute/ and defined $objectTypes{$2}) + { + $bulk = 1; + $OT = $objectTypes{$2}; + $fun = "bulk_$1"; + } + elsif ($fun =~ /(set|get)_(\w+)_attribute/ and defined $objectTypes{$2}) + { + $OT = $objectTypes{$2}; + $fun = "$1"; + } + elsif ($fun =~ /(create|remove|set|get)_(\w+)s(_attribute)?/ and defined $objectTypes{$2}) + { + $bulk = 1; + $OT = $objectTypes{$2}; + $fun = "bulk_$1"; + } + elsif ($fun =~ /(create|remove|set|get)_(\w+)(_attribute)?/ and defined $objectTypes{$2}) + { + $OT = $objectTypes{$2}; + $fun = "$1"; + } + elsif ($fun =~ /(create|remove|set|get)_(\w+)(_attribute)?/ and defined $objectTypes{$2}) + { + $OT = $objectTypes{$2}; + $fun = $1; + } + else + { + LogInfo "Unique function $fun"; + } + + $entry = 1 if defined $ENTRIES{$OT}; + + my $f = GetFunctionCamelCaseName($fun); + + return ($OT, $f, $entry, $bulk); +} + +sub CreateApiStricts() +{ + Write ""; + Write "/* ==== API STRUCTS === */"; + Write ""; + + for my $API (@APIS) + { + my $api = lc $API; + + Write ""; + Write "/* SAI APIS for $API */"; + Write ""; + + my $struct = $apiStructs{$api}; + + LogError "api $api not found" if not defined $struct; + + while ($struct =~ /(sai_\w+_fn)\s+(\w+)/gms) + { + my $type = $1; + my $funname = $2; + + my $fun = $FUNCTIONS{$type}; + + LogError "function $fun not found" if not defined $fun; + + next if not $fun =~ /(sai_\w+).+\((.+?)\)/gms; + + my $rettype = $1; + my $params = $2; + my @par = $params =~ /(\w+,|\w+$)/gms; + + my ($OT, $fname, $entry, $bulk) = GetFunctionName($funname); + + $par[0] = "switch_id,SAI_NULL_OBJECT_ID," if $OT eq "SWITCH" and $bulk == 0 and $fname eq "create"; + + Write "static $rettype ${STUB}_$funname($params)"; + Write "{"; + Write " SWSS_LOG_ENTER();"; + Write ""; + + if ($fname =~ /(clearPortAllStats|removeAllNeighborEntries|recvHostifPacket|sendHostifPacket|allocateHostifPacket|freeHostifPacket)/) + { + Write " SWSS_LOG_ERROR(\"FIXME, no implementation for $fname!\");"; + Write " return SAI_STATUS_NOT_IMPLEMENTED;"; + Write "}"; + next; + } + + Write " return $STUB" . "->$fname(@par);" if $OT eq ""; + Write " return $STUB" . "->$fname(@par);" if $OT ne "" and $bulk == 1 and $entry == 1; + Write " return $STUB" . "->$fname(@par);" if $OT ne "" and $bulk == 0 and $entry == 1; + Write " return $STUB" . "->$fname((sai_object_type_t)(SAI_OBJECT_TYPE_$OT),@par);" if $OT ne "" and $bulk == 0 and $entry == 0; + Write " return $STUB" . "->$fname((sai_object_type_t)(SAI_OBJECT_TYPE_$OT),@par);" if $OT ne "" and $bulk == 1 and $entry == 0; + Write "}"; + Write ""; + } + + Write "const sai_${api}_api_t ${STUB}_${api} = {"; + + while ($struct =~ /(sai_\w+_fn)\s+(\w+)/gms) + { + my $type = $1; + my $funname = $2; + + Write " .$funname = ${STUB}_$funname,"; + } + + Write "};"; + Write ""; + } +} + +sub CreateHeader +{ + Write ""; + Write "/* DO NOT MODIFY, FILE AUTO GENERATED */"; + Write ""; + Write "extern \"C\" {"; + Write "#include \"sai.h\""; + Write "#include \"saiextensions.h\""; + Write "}"; + Write "#include \"meta/SaiInterface.h\""; + Write "#include \"$optionClass.h\""; + Write "#include \"swss/logger.h\""; + Write "#include "; + Write ""; + Write "static std::shared_ptr $STUB = std::make_shared<$optionNamespace" . "::$optionClass>();"; + Write "" +} + +sub CreateApiStruct +{ + Write ""; + Write "/* ==== API STRUCTS === */"; + Write ""; + + Write "static sai_apis_t ${STUB}_apis = {"; + + for my $API (@APIS) + { + my $api = lc $API; + + Write " .${api}_api = const_cast(&${STUB}_${api}),"; + } + + Write "};"; + Write ""; +} + +sub CreateApiQuery +{ + Write ""; + Write "/* ==== API QUERY === */"; + Write ""; + + Write "static_assert((sizeof(sai_apis_t)/sizeof(void*)) == (SAI_API_EXTENSIONS_MAX - 1));"; + Write ""; + Write "sai_status_t sai_api_query("; + Write " _In_ sai_api_t sai_api_id,"; + Write " _Out_ void** api_method_table)"; + Write "{"; + Write " SWSS_LOG_ENTER();"; + Write ""; + Write " if (api_method_table == NULL)"; + Write " {"; + Write " SWSS_LOG_ERROR(\"NULL method table passed to SAI API initialize\");"; + Write ""; + Write " return SAI_STATUS_INVALID_PARAMETER;"; + Write " }"; + Write ""; + Write " if (sai_api_id == SAI_API_UNSPECIFIED)"; + Write " {"; + Write " SWSS_LOG_ERROR(\"api ID is unspecified api\");"; + Write ""; + Write " return SAI_STATUS_INVALID_PARAMETER;"; + Write " }"; + Write ""; + Write " if (sai_metadata_get_enum_value_name(&sai_metadata_enum_sai_api_t, sai_api_id))"; + Write " {"; + Write " *api_method_table = ((void**)&${STUB}_apis)[sai_api_id - 1];"; + Write ""; + Write " return SAI_STATUS_SUCCESS;"; + Write " }"; + Write ""; + Write " SWSS_LOG_ERROR(\"Invalid API type %d\", sai_api_id);"; + Write ""; + Write " return SAI_STATUS_INVALID_PARAMETER;"; + Write "}"; + Write ""; +} + +sub CreateGlobalApis +{ + Write ""; + Write "/* ==== GLOBAL APIS === */"; + Write ""; + + for my $api (sort @globalApis) + { + next if not $api =~ /(sai_\w+)\s+(sai_\w+).*\((.+?)\)/gms; + + my $rettype = $1; + my $funname = $2; + my $params = $3; + + next if $funname eq "sai_api_query"; + + my @par = $params =~ /(\w+,|\w+$)/gms; + + my $fun = GetFunctionCamelCaseName($funname); + + $par[0] = "" if $par[0] eq "void"; + + Write "$rettype $funname($params)"; + Write "{"; + Write " SWSS_LOG_ENTER();"; + Write ""; + + if ($fun =~ /(bulkObjectClearStats|bulkObjectGetStats|dbgGenerateDump|getMaximumAttributeCount|getObjectKey|bulkGetAttribute|dbgGenerateDump|tamTelemetryGetData|getObjectCount|queryObjectStage)/) + { + Write " SWSS_LOG_ERROR(\"FIXME, no implementation for $fun!\");"; + Write " return SAI_STATUS_NOT_IMPLEMENTED;"; + Write "}"; + next; + } + + Write " return $STUB" . "->$fun(@par);"; + Write "}"; + Write ""; + } +} + +# +# MAIN +# + + +LogError "Option SaiDir not specifird (-d)" if not defined $optionSaiDir; +LogError "Option Class not specifird (-c)" if not defined $optionClass; +LogError "Option Namespace not specifird (-n)" if not defined $optionNamespace; +LogError "Option FileName not specifird (-f)" if not defined $optionFileName; +LogError "Option Stub not specifird (-s)" if not defined $optionStub; + +LogInfo "optionSaiDir = $optionSaiDir "; +LogInfo "optionClass = $optionClass "; +LogInfo "optionNamespace = $optionNamespace"; +LogInfo "optionFileName = $optionFileName "; +LogInfo "optionStub = $optionStub "; + +GetData(); +SanitizeData(); +ExtractData(); +CreateHeader(); +CreateApiStricts(); +CreateApiStruct(); +CreateApiQuery(); +CreateGlobalApis(); +WriteFile($optionFileName,$SOURCE_CONTENT); diff --git a/syncd/Makefile.am b/syncd/Makefile.am index 4982ea16c..3c546fb74 100644 --- a/syncd/Makefile.am +++ b/syncd/Makefile.am @@ -113,3 +113,15 @@ syncd_tests_LDADD = libSyncd.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/ -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) TESTS = syncd_tests + +if SAIVS +if DASHSAI +bin_PROGRAMS += syncd_dash +syncd_dash_SOURCES = $(syncd_SOURCES) +syncd_dash_CPPFLAGS = $(syncd_CPPFLAGS) +syncd_dash_CXXFLAGS = $(syncd_CXXFLAGS) +syncd_dash_LDADD = libSyncd.a $(top_srcdir)/lib/libSaiRedis.a -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta \ + -ldl -lhiredis -lswsscommon -lsai -lprotobuf -lpiprotobuf -lpiprotogrpc -lgrpc++ -lpthread -lzmq $(CODE_COVERAGE_LIBS) $(EXTRA_LIBSAI_LDFLAGS) +syncd_dash_LDFLAGS = $(syncd_LDFLAGS) +endif +endif diff --git a/syncd/MdioIpcServer.cpp b/syncd/MdioIpcServer.cpp index 7194332fb..1d827efa9 100644 --- a/syncd/MdioIpcServer.cpp +++ b/syncd/MdioIpcServer.cpp @@ -465,7 +465,10 @@ void MdioIpcServer::stopMdioThread(void) } m_taskAlive = 0; - m_taskThread.join(); + if(m_taskThread.joinable()) + { + m_taskThread.join(); + } SWSS_LOG_NOTICE("IPC task thread is stopped\n"); } diff --git a/syncd/NotificationHandler.cpp b/syncd/NotificationHandler.cpp index 9e535aa20..06bcb7bd8 100644 --- a/syncd/NotificationHandler.cpp +++ b/syncd/NotificationHandler.cpp @@ -96,6 +96,10 @@ void NotificationHandler::updateNotificationsPointers( attr.value.ptr = (void*)m_switchNotifications.on_switch_shutdown_request; break; + case SAI_SWITCH_ATTR_SWITCH_ASIC_SDK_HEALTH_EVENT_NOTIFY: + attr.value.ptr = (void*)m_switchNotifications.on_switch_asic_sdk_health_event; + break; + case SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY: attr.value.ptr = (void*)m_switchNotifications.on_fdb_event; break; @@ -205,6 +209,21 @@ void NotificationHandler::onSwitchShutdownRequest( enqueueNotification(SAI_SWITCH_NOTIFICATION_NAME_SWITCH_SHUTDOWN_REQUEST, s); } +void NotificationHandler::onSwitchAsicSdkHealthEvent( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); + + std::string s = sai_serialize_switch_asic_sdk_health_event(switch_id, severity, timestamp, category, data, description); + + enqueueNotification(SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT, s); +} + void NotificationHandler::onSwitchStateChange( _In_ sai_object_id_t switch_id, _In_ sai_switch_oper_status_t switch_oper_status) diff --git a/syncd/NotificationHandler.h b/syncd/NotificationHandler.h index a7909b4df..1ca355e58 100644 --- a/syncd/NotificationHandler.h +++ b/syncd/NotificationHandler.h @@ -58,6 +58,14 @@ namespace syncd _In_ uint32_t count, _In_ const sai_queue_deadlock_notification_data_t *data); + void onSwitchAsicSdkHealthEvent( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description); + void onSwitchShutdownRequest( _In_ sai_object_id_t switch_id); diff --git a/syncd/NotificationProcessor.cpp b/syncd/NotificationProcessor.cpp index 4fbd56750..f9b9be396 100644 --- a/syncd/NotificationProcessor.cpp +++ b/syncd/NotificationProcessor.cpp @@ -558,6 +558,24 @@ void NotificationProcessor::process_on_bfd_session_state_change( sendNotification(SAI_SWITCH_NOTIFICATION_NAME_BFD_SESSION_STATE_CHANGE, s); } + +void NotificationProcessor::process_on_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_rid, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); + + sai_object_id_t switch_vid = m_translator->translateRidToVid(switch_rid, SAI_NULL_OBJECT_ID); + + std::string s = sai_serialize_switch_asic_sdk_health_event(switch_vid, severity, timestamp, category, data, description); + + sendNotification(SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT, s); +} + void NotificationProcessor::process_on_switch_shutdown_request( _In_ sai_object_id_t switch_rid) { @@ -707,6 +725,35 @@ void NotificationProcessor::handle_bfd_session_state_change( sai_deserialize_free_bfd_session_state_ntf(count, bfdsessionstate); } +void NotificationProcessor::handle_switch_asic_sdk_health_event( + _In_ const std::string &data) +{ + SWSS_LOG_ENTER(); + + sai_object_id_t switch_id; + sai_switch_asic_sdk_health_severity_t severity; + sai_timespec_t timestamp; + sai_switch_asic_sdk_health_category_t category; + sai_switch_health_data_t health_data; + sai_u8_list_t description; + + sai_deserialize_switch_asic_sdk_health_event(data, + switch_id, + severity, + timestamp, + category, + health_data, + description); + + process_on_switch_asic_sdk_health_event(switch_id, + severity, + timestamp, + category, + health_data, + description); + + sai_deserialize_free_switch_asic_sdk_health_event(description); +} void NotificationProcessor::handle_switch_shutdown_request( _In_ const std::string &data) { @@ -774,6 +821,10 @@ void NotificationProcessor::syncProcessNotification( { handle_switch_shutdown_request(data); } + else if (notification == SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT) + { + handle_switch_asic_sdk_health_event(data); + } else if (notification == SAI_SWITCH_NOTIFICATION_NAME_QUEUE_PFC_DEADLOCK) { handle_queue_deadlock(data); diff --git a/syncd/NotificationProcessor.h b/syncd/NotificationProcessor.h index 15d44daaa..0c89260a0 100644 --- a/syncd/NotificationProcessor.h +++ b/syncd/NotificationProcessor.h @@ -97,6 +97,14 @@ namespace syncd _In_ sai_object_id_t port_id, _In_ sai_port_host_tx_ready_status_t *host_tx_ready_status); + void process_on_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description); + void process_on_switch_shutdown_request( _In_ sai_object_id_t switch_rid); @@ -124,6 +132,9 @@ namespace syncd void handle_bfd_session_state_change( _In_ const std::string &data); + void handle_switch_asic_sdk_health_event( + _In_ const std::string &data); + void handle_switch_shutdown_request( _In_ const std::string &data); diff --git a/syncd/ServiceMethodTable.cpp b/syncd/ServiceMethodTable.cpp index 38fb9b7c2..f954bbce2 100644 --- a/syncd/ServiceMethodTable.cpp +++ b/syncd/ServiceMethodTable.cpp @@ -2,6 +2,7 @@ #include "swss/logger.h" +#include #include using namespace syncd; diff --git a/syncd/SwitchNotifications.cpp b/syncd/SwitchNotifications.cpp index 1c470a989..9204825f5 100644 --- a/syncd/SwitchNotifications.cpp +++ b/syncd/SwitchNotifications.cpp @@ -1,6 +1,7 @@ #include "SwitchNotifications.h" #include "swss/logger.h" +#include using namespace syncd; @@ -97,6 +98,19 @@ void SwitchNotifications::SlotBase::onQueuePfcDeadlock( return m_slots[context]->m_handler->onQueuePfcDeadlock(count, data); } +void SwitchNotifications::SlotBase::onSwitchAsicSdkHealthEvent( + _In_ int context, + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); + + return m_slots.at(context)->m_handler->onSwitchAsicSdkHealthEvent(switch_id, severity, timestamp, category, data, description); +} void SwitchNotifications::SlotBase::onSwitchShutdownRequest( _In_ int context, diff --git a/syncd/SwitchNotifications.h b/syncd/SwitchNotifications.h index 8cc606145..2921a9cc1 100644 --- a/syncd/SwitchNotifications.h +++ b/syncd/SwitchNotifications.h @@ -62,6 +62,15 @@ namespace syncd _In_ uint32_t count, _In_ const sai_queue_deadlock_notification_data_t *data); + static void onSwitchAsicSdkHealthEvent( + _In_ int context, + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description); + static void onSwitchShutdownRequest( _In_ int context, _In_ sai_object_id_t switch_id); @@ -106,9 +115,11 @@ namespace syncd .on_tam_event = nullptr, .on_ipsec_sa_status_change = nullptr, .on_nat_event = &Slot::onNatEvent, - .on_switch_asic_sdk_health_event = nullptr, + .on_switch_asic_sdk_health_event = &Slot::onSwitchAsicSdkHealthEvent, .on_port_host_tx_ready = &Slot::onPortHostTxReady, .on_twamp_session_event = &Slot::onTwampSessionEvent, + .on_ha_set_event = nullptr, + .on_ha_scope_event = nullptr, }) { } virtual ~Slot() {} @@ -170,6 +181,25 @@ namespace syncd return SlotBase::onQueuePfcDeadlock(context, count, data); } + static void onSwitchAsicSdkHealthEvent( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) + { + SWSS_LOG_ENTER(); + + return SlotBase::onSwitchAsicSdkHealthEvent(context, + switch_id, + severity, + timestamp, + category, + data, + description); + } + static void onSwitchShutdownRequest( _In_ sai_object_id_t switch_id) { @@ -216,6 +246,12 @@ namespace syncd std::function onPortStateChange; std::function onPortHostTxReady; std::function onQueuePfcDeadlock; + std::function onSwitchAsicSdkHealthEvent; std::function onSwitchShutdownRequest; std::function onSwitchStateChange; std::function onBfdSessionStateChange; diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index 1dd2366eb..980886f8f 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -155,6 +155,7 @@ Syncd::Syncd( m_sn.onNatEvent = std::bind(&NotificationHandler::onNatEvent, m_handler.get(), _1, _2); m_sn.onPortStateChange = std::bind(&NotificationHandler::onPortStateChange, m_handler.get(), _1, _2); m_sn.onQueuePfcDeadlock = std::bind(&NotificationHandler::onQueuePfcDeadlock, m_handler.get(), _1, _2); + m_sn.onSwitchAsicSdkHealthEvent = std::bind(&NotificationHandler::onSwitchAsicSdkHealthEvent, m_handler.get(), _1, _2, _3, _4, _5, _6); m_sn.onSwitchShutdownRequest = std::bind(&NotificationHandler::onSwitchShutdownRequest, m_handler.get(), _1); m_sn.onSwitchStateChange = std::bind(&NotificationHandler::onSwitchStateChange, m_handler.get(), _1, _2); m_sn.onBfdSessionStateChange = std::bind(&NotificationHandler::onBfdSessionStateChange, m_handler.get(), _1, _2); @@ -169,6 +170,8 @@ Syncd::Syncd( m_dbFlexCounter = std::make_shared(m_contextConfig->m_dbFlex, 0); m_flexCounter = std::make_shared(m_dbFlexCounter.get(), FLEX_COUNTER_TABLE); m_flexCounterGroup = std::make_shared(m_dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE); + m_flexCounterTable = std::make_shared(m_dbFlexCounter.get(), FLEX_COUNTER_TABLE); + m_flexCounterGroupTable = std::make_shared(m_dbFlexCounter.get(), FLEX_COUNTER_GROUP_TABLE); m_switchConfigContainer = std::make_shared(); m_redisVidIndexGenerator = std::make_shared(m_dbAsic, REDIS_KEY_VIDCOUNTER); @@ -193,7 +196,7 @@ Syncd::Syncd( m_test_services = m_smt.getServiceMethodTable(); - sai_status_t status = vendorSai->initialize(0, &m_test_services); + sai_status_t status = vendorSai->apiInitialize(0, &m_test_services); if (status != SAI_STATUS_SUCCESS) { @@ -380,6 +383,18 @@ sai_status_t Syncd::processSingleEvent( if (op == REDIS_ASIC_STATE_COMMAND_OBJECT_TYPE_GET_AVAILABILITY_QUERY) return processObjectTypeGetAvailabilityQuery(kco); + if (op == REDIS_FLEX_COUNTER_COMMAND_START_POLL) + return processFlexCounterEvent(key, SET_COMMAND, kfvFieldsValues(kco)); + + if (op == REDIS_FLEX_COUNTER_COMMAND_STOP_POLL) + return processFlexCounterEvent(key, DEL_COMMAND, kfvFieldsValues(kco)); + + if (op == REDIS_FLEX_COUNTER_COMMAND_SET_GROUP) + return processFlexCounterGroupEvent(key, SET_COMMAND, kfvFieldsValues(kco)); + + if (op == REDIS_FLEX_COUNTER_COMMAND_DEL_GROUP) + return processFlexCounterGroupEvent(key, DEL_COMMAND, kfvFieldsValues(kco)); + SWSS_LOG_THROW("event op '%s' is not implemented, FIXME", op.c_str()); } @@ -474,7 +489,7 @@ sai_status_t Syncd::processAttrEnumValuesCapabilityQuery( enumCapList.count = list_size; enumCapList.list = enum_capabilities_list.data(); - sai_status_t status = m_vendorSai->queryAattributeEnumValuesCapability(switchRid, objectType, attrId, &enumCapList); + sai_status_t status = m_vendorSai->queryAttributeEnumValuesCapability(switchRid, objectType, attrId, &enumCapList); std::vector entry; @@ -1000,6 +1015,27 @@ sai_status_t Syncd::processBulkCreateEntry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + for (uint32_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(objectIds[it], entries[it]); + + entries[it].switch_id = m_translator->translateVidToRid(entries[it].switch_id); + entries[it].rif_id = m_translator->translateVidToRid(entries[it].rif_id); + } + + status = m_vendorSai->bulkCreate( + object_count, + entries.data(), + attr_counts.data(), + attr_lists.data(), + mode, + statuses.data()); + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { std::vector entries(object_count); @@ -1286,6 +1322,25 @@ sai_status_t Syncd::processBulkRemoveEntry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + for (uint32_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(objectIds[it], entries[it]); + + entries[it].switch_id = m_translator->translateVidToRid(entries[it].switch_id); + entries[it].rif_id = m_translator->translateVidToRid(entries[it].rif_id); + } + + status = m_vendorSai->bulkRemove( + object_count, + entries.data(), + mode, + statuses.data()); + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { std::vector entries(object_count); @@ -1559,6 +1614,26 @@ sai_status_t Syncd::processBulkSetEntry( } break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + { + std::vector entries(object_count); + for (uint32_t it = 0; it < object_count; it++) + { + sai_deserialize_neighbor_entry(objectIds[it], entries[it]); + + entries[it].switch_id = m_translator->translateVidToRid(entries[it].switch_id); + entries[it].rif_id = m_translator->translateVidToRid(entries[it].rif_id); + } + + status = m_vendorSai->bulkSet( + object_count, + entries.data(), + attr_lists.data(), + mode, + statuses.data()); + } + break; + case SAI_OBJECT_TYPE_FDB_ENTRY: { std::vector entries(object_count); @@ -1715,6 +1790,10 @@ sai_status_t Syncd::processBulkEntry( sai_deserialize_route_entry(objectIds[idx], metaKey.objectkey.key.route_entry); break; + case SAI_OBJECT_TYPE_NEIGHBOR_ENTRY: + sai_deserialize_neighbor_entry(objectIds[idx], metaKey.objectkey.key.neighbor_entry); + break; + case SAI_OBJECT_TYPE_NAT_ENTRY: sai_deserialize_nat_entry(objectIds[idx], metaKey.objectkey.key.nat_entry); break; @@ -2442,18 +2521,44 @@ void Syncd::processFlexCounterGroupEvent( // TODO must be moved to go via ASIC c WatchdogScope ws(m_timerWatchdog, op + ":" + groupName, &kco); + processFlexCounterGroupEvent(groupName, op, values, false); +} + +sai_status_t Syncd::processFlexCounterGroupEvent( + _In_ const std::string &groupName, + _In_ const std::string &op, + _In_ const std::vector &values, + _In_ bool fromAsicChannel) +{ + SWSS_LOG_ENTER(); + if (op == SET_COMMAND) { m_manager->addCounterPlugin(groupName, values); + if (fromAsicChannel) + { + m_flexCounterGroupTable->set(groupName, values); + } } else if (op == DEL_COMMAND) { + if (fromAsicChannel) + { + m_flexCounterGroupTable->del(groupName); + } m_manager->removeCounterPlugins(groupName); } else { SWSS_LOG_ERROR("unknown command: %s", op.c_str()); } + + if (fromAsicChannel) + { + sendApiResponse(SAI_COMMON_API_SET, SAI_STATUS_SUCCESS); + } + + return SAI_STATUS_SUCCESS; } void Syncd::processFlexCounterEvent( // TODO must be moved to go via ASIC channel queue @@ -2469,21 +2574,40 @@ void Syncd::processFlexCounterEvent( // TODO must be moved to go via ASIC channe auto& key = kfvKey(kco); auto& op = kfvOp(kco); + auto& values = kfvFieldsValues(kco); WatchdogScope ws(m_timerWatchdog, op + ":" + key, &kco); + processFlexCounterEvent(key, op, values, false); +} + +sai_status_t Syncd::processFlexCounterEvent( + _In_ const std::string &key, + _In_ const std::string &op, + _In_ const std::vector &values, + _In_ bool fromAsicChannel) +{ + SWSS_LOG_ENTER(); + auto delimiter = key.find_first_of(":"); if (delimiter == std::string::npos) { SWSS_LOG_ERROR("Failed to parse the key %s", key.c_str()); - return; // if key is invalid there is no need to process this event again + if (fromAsicChannel) + { + sendApiResponse(SAI_COMMON_API_SET, SAI_STATUS_FAILURE); + } + + return SAI_STATUS_FAILURE; // if key is invalid there is no need to process this event again } auto groupName = key.substr(0, delimiter); auto strVid = key.substr(delimiter + 1); + auto effective_op = op; + sai_object_id_t vid; sai_deserialize_object_id(strVid, vid); @@ -2491,26 +2615,46 @@ void Syncd::processFlexCounterEvent( // TODO must be moved to go via ASIC channe if (!m_translator->tryTranslateVidToRid(vid, rid)) { - SWSS_LOG_WARN("port VID %s, was not found (probably port was removed/splitted) and will remove from counters now", - sai_serialize_object_id(vid).c_str()); - - op = DEL_COMMAND; + if (fromAsicChannel) + { + SWSS_LOG_ERROR("port VID %s, was not found (probably port was removed/splitted) and will remove from counters now", + sai_serialize_object_id(vid).c_str()); + } + else + { + SWSS_LOG_WARN("port VID %s, was not found (probably port was removed/splitted) and will remove from counters now", + sai_serialize_object_id(vid).c_str()); + } + effective_op = DEL_COMMAND; } - const auto values = kfvFieldsValues(kco); - - if (op == SET_COMMAND) + if (effective_op == SET_COMMAND) { m_manager->addCounter(vid, rid, groupName, values); + if (fromAsicChannel) + { + m_flexCounterTable->set(key, values); + } } - else if (op == DEL_COMMAND) + else if (effective_op == DEL_COMMAND) { + if (fromAsicChannel) + { + m_flexCounterTable->del(key); + } m_manager->removeCounter(vid, groupName); } else { SWSS_LOG_ERROR("unknown command: %s", op.c_str()); } + + if (fromAsicChannel) + { + sendApiResponse(SAI_COMMON_API_SET, SAI_STATUS_SUCCESS); + } + + return SAI_STATUS_SUCCESS; } void Syncd::syncUpdateRedisQuadEvent( @@ -5126,7 +5270,7 @@ void Syncd::run() SWSS_LOG_NOTICE("calling api uninitialize"); - status = m_vendorSai->uninitialize(); + status = m_vendorSai->apiUninitialize(); if (status != SAI_STATUS_SUCCESS) { diff --git a/syncd/Syncd.h b/syncd/Syncd.h index a19fcd972..06eb84a62 100644 --- a/syncd/Syncd.h +++ b/syncd/Syncd.h @@ -198,6 +198,18 @@ namespace syncd _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list); + sai_status_t processFlexCounterGroupEvent( + _In_ const std::string &key, + _In_ const std::string &op, + _In_ const std::vector &values, + _In_ bool fromAsicChannel=true); + + sai_status_t processFlexCounterEvent( + _In_ const std::string &key, + _In_ const std::string &op, + _In_ const std::vector &values, + _In_ bool fromAsicChannel=true); + private: // process quad oid sai_status_t processOidCreate( @@ -485,6 +497,8 @@ namespace syncd std::shared_ptr m_dbFlexCounter; std::shared_ptr m_flexCounter; std::shared_ptr m_flexCounterGroup; + std::shared_ptr m_flexCounterTable; + std::shared_ptr m_flexCounterGroupTable; std::shared_ptr m_notifications; diff --git a/syncd/VendorSai.cpp b/syncd/VendorSai.cpp index a0234aa7d..db8aba66b 100644 --- a/syncd/VendorSai.cpp +++ b/syncd/VendorSai.cpp @@ -66,13 +66,13 @@ VendorSai::~VendorSai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } // INITIALIZE UNINITIALIZE -sai_status_t VendorSai::initialize( +sai_status_t VendorSai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -93,6 +93,23 @@ sai_status_t VendorSai::initialize( return SAI_STATUS_INVALID_PARAMETER; } + memcpy(&m_service_method_table, service_method_table, sizeof(m_service_method_table)); + + auto status = m_globalApis.api_initialize(flags, service_method_table); + + if (status == SAI_STATUS_SUCCESS) + { + memset(&m_apis, 0, sizeof(m_apis)); + + int failed = sai_metadata_apis_query(m_globalApis.api_query, &m_apis); + + if (failed > 0) + { + SWSS_LOG_NOTICE("sai_api_query failed for %d apis", failed); + } + + } + sai_api_version_t version{}; auto api_status = m_globalApis.query_api_version(&version); @@ -120,28 +137,12 @@ sai_status_t VendorSai::initialize( return SAI_STATUS_FAILURE; } - memcpy(&m_service_method_table, service_method_table, sizeof(m_service_method_table)); - - auto status = m_globalApis.api_initialize(flags, service_method_table); - - if (status == SAI_STATUS_SUCCESS) - { - memset(&m_apis, 0, sizeof(m_apis)); - - int failed = sai_metadata_apis_query(m_globalApis.api_query, &m_apis); - - if (failed > 0) - { - SWSS_LOG_NOTICE("sai_api_query failed for %d apis", failed); - } - - m_apiInitialized = true; - } + m_apiInitialized = true; return status; } -sai_status_t VendorSai::uninitialize(void) +sai_status_t VendorSai::apiUninitialize(void) { SWSS_LOG_ENTER(); VENDOR_CHECK_API_INITIALIZED(); @@ -607,6 +608,43 @@ sai_status_t VendorSai::bulkSet( return SAI_STATUS_NOT_SUPPORTED; } +sai_status_t VendorSai::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t VendorSai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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) \ +{ \ + MUTEX(); \ + SWSS_LOG_ENTER(); \ + VENDOR_CHECK_API_INITIALIZED(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + + // BULK QUAD ENTRY sai_status_t VendorSai::bulkCreate( @@ -1628,7 +1666,7 @@ sai_status_t VendorSai::queryAttributeCapability( capability); } -sai_status_t VendorSai::queryAattributeEnumValuesCapability( +sai_status_t VendorSai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switchId, _In_ sai_object_type_t objectType, _In_ sai_attr_id_t attrId, @@ -1686,6 +1724,14 @@ sai_status_t VendorSai::logSet( return m_globalApis.log_set(api, log_level); } +sai_status_t VendorSai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + return m_globalApis.query_api_version(version); +} + sai_log_level_t VendorSai::logGet( _In_ sai_api_t api) { diff --git a/syncd/VendorSai.h b/syncd/VendorSai.h index 7a6c4937f..3f2ccc48c 100644 --- a/syncd/VendorSai.h +++ b/syncd/VendorSai.h @@ -25,11 +25,11 @@ namespace syncd public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -87,6 +87,15 @@ namespace syncd _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -186,7 +195,7 @@ namespace syncd _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -202,6 +211,9 @@ namespace syncd _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + public: // extra API virtual sai_log_level_t logGet( diff --git a/syncd/Workaround.cpp b/syncd/Workaround.cpp index bcbc9d89b..a7dbae5e4 100644 --- a/syncd/Workaround.cpp +++ b/syncd/Workaround.cpp @@ -12,6 +12,11 @@ using namespace syncd; * Some attributes are not supported on SET API on different platforms. * For example SAI_SWITCH_ATTR_SRC_MAC_ADDRESS. * + * Some attributes like SAI_HOSTIF_ATTR_QUEUE may not be supported on BRCM + * platform until vendor will implement them, but it will return success on + * querySwitchCapability on OA. Support for query switch capability can show up + * on warm boot when booting new SAI firmware. + * * @param[in] objectType Object type. * @param[in] attrId Attribute Id. * @param[in] status Status from SET API. @@ -40,5 +45,15 @@ bool Workaround::isSetAttributeWorkaround( return true; } + if (objectType == SAI_OBJECT_TYPE_HOSTIF && + attrId == SAI_HOSTIF_ATTR_QUEUE) + { + SWSS_LOG_WARN("setting %s failed: %s, not all platforms support this attribute", + sai_metadata_get_attr_metadata(objectType, attrId)->attridname, + sai_serialize_status(status).c_str()); + + return true; + } + return false; } diff --git a/syncd/scripts/syncd_init_common.sh b/syncd/scripts/syncd_init_common.sh index c538c23e8..e2b56229b 100644 --- a/syncd/scripts/syncd_init_common.sh +++ b/syncd/scripts/syncd_init_common.sh @@ -99,6 +99,11 @@ function set_start_type() fi } +config_syncd_pensando() +{ + CMD_ARGS+=" -l" +} + config_syncd_cisco_8000() { export BASE_OUTPUT_DIR=/opt/cisco/silicon-one @@ -211,14 +216,23 @@ config_syncd_mlnx() DUAL_TOR="$(echo $SYNCD_VARS | jq -r '.dual_tor')" DSCP_REMAPPING="$(echo $SYNCD_VARS | jq -r '.dscp_remapping')" - # Make default sai.profile + SAI_COMMON_FILE_PATH=/etc/mlnx/sai-common.profile + if [[ -f $HWSKU_DIR/sai.profile.j2 ]]; then export RESOURCE_TYPE="$(echo $SYNCD_VARS | jq -r '.resource_type')" - j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai.profile + j2 -e RESOURCE_TYPE $HWSKU_DIR/sai.profile.j2 -o /tmp/sai-temp.profile else - cat $HWSKU_DIR/sai.profile > /tmp/sai.profile + cat $HWSKU_DIR/sai.profile > /tmp/sai-temp.profile fi + if [[ -f $SAI_COMMON_FILE_PATH ]]; then + cat $SAI_COMMON_FILE_PATH >> /tmp/sai-temp.profile + fi + + # keep only the first occurence of each prefix with '=' sign, and remove the others. + awk -F= '!seen[$1]++' /tmp/sai-temp.profile > /tmp/sai.profile + rm -f /tmp/sai-temp.profile + # Update sai.profile with MAC_ADDRESS and WARM_BOOT settings echo "DEVICE_MAC_ADDRESS=$MAC_ADDRESS" >> /tmp/sai.profile echo "SAI_WARM_BOOT_WRITE_FILE=/var/warmboot/" >> /tmp/sai.profile @@ -240,11 +254,6 @@ config_syncd_mlnx() if [[ -f /tmp/sai_extra.profile ]]; then cat /tmp/sai_extra.profile >> /tmp/sai.profile fi - - if [[ -f /$HWSKU_DIR/module_control_support.profile ]]; then - cat /$HWSKU_DIR/module_control_support.profile >> /tmp/sai.profile - fi - } config_syncd_centec() @@ -340,33 +349,47 @@ config_syncd_nvidia_bluefield() { # Read MAC addresses base_mac="$(echo $SYNCD_VARS | jq -r '.mac')" + hwsku=$(sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]') + single_port=$([[ $hwsku == *"-com-dpu" ]] && echo true || echo false) + eth0_mac=$(cat /sys/class/net/Ethernet0/address) - eth4_mac=$(cat /sys/class/net/Ethernet4/address) cp $HWSKU_DIR/sai.profile /tmp/sai.profile # Update sai.profile with MAC_ADDRESS echo "DEVICE_MAC_ADDRESS=$base_mac" >> /tmp/sai.profile echo "PORT_1_MAC_ADDRESS=$eth0_mac" >> /tmp/sai.profile - echo "PORT_2_MAC_ADDRESS=$eth4_mac" >> /tmp/sai.profile CMD_ARGS+=" -l -p /tmp/sai.profile -w 180000000" - echo 4096 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages + SDK_DUMP_PATH=$(cat /tmp/sai.profile | grep "SAI_DUMP_STORE_PATH" | cut -d = -f2) + if [ ! -d "$SDK_DUMP_PATH" ]; then + mkdir -p "$SDK_DUMP_PATH" + fi + + echo 9216 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages mkdir -p /mnt/huge mount -t hugetlbfs pagesize=1GB /mnt/huge devlink dev eswitch set pci/0000:03:00.0 mode legacy - devlink dev eswitch set pci/0000:03:00.1 mode legacy devlink dev eswitch set pci/0000:03:00.0 mode switchdev - devlink dev eswitch set pci/0000:03:00.1 mode switchdev - devlink dev param set pci/0000:03:00.0 name esw_multiport value 1 cmode runtime - devlink dev param set pci/0000:03:00.1 name esw_multiport value 1 cmode runtime + + if [[ $hwsku != *"-C1" ]] && [[ $single_port == false ]]; then + devlink dev param set pci/0000:03:00.0 name esw_multiport value 1 cmode runtime + devlink dev param set pci/0000:03:00.1 name esw_multiport value 1 cmode runtime + fi ethtool -A Ethernet0 rx off tx off - ethtool -A Ethernet4 rx off tx off - mlnx-sf --device 0000:03:00.0 --action create --sfnum 1 --hwaddr ${base_mac} -t + if [[ $single_port == false ]]; then + eth4_mac=$(cat /sys/class/net/Ethernet4/address) + echo "PORT_2_MAC_ADDRESS=$eth4_mac" >> /tmp/sai.profile + + devlink dev eswitch set pci/0000:03:00.1 mode legacy + devlink dev eswitch set pci/0000:03:00.1 mode switchdev + + ethtool -A Ethernet4 rx off tx off + fi } config_syncd_xsight() @@ -449,6 +472,8 @@ config_syncd() config_syncd_nvidia_bluefield elif [ "$SONIC_ASIC_TYPE" == "xsight" ]; then config_syncd_xsight + elif [ "$SONIC_ASIC_TYPE" == "pensando" ]; then + config_syncd_pensando else echo "Unknown ASIC type $SONIC_ASIC_TYPE" exit 1 diff --git a/syncd/tests.cpp b/syncd/tests.cpp index 332b8c80f..27b89dfa7 100644 --- a/syncd/tests.cpp +++ b/syncd/tests.cpp @@ -671,6 +671,145 @@ void test_bulk_route_set() ASSERT_SUCCESS("Failed to bulk remove route entry"); } +void test_bulk_neighbor_set() +{ + SWSS_LOG_ENTER(); + + + sai_reinit(); + + + sai_status_t status; + + sai_neighbor_api_t *sai_neighbor_api = NULL; + sai_switch_api_t *sai_switch_api = NULL; + sai_virtual_router_api_t * sai_virtual_router_api = NULL; + sai_lag_api_t *sai_lag_api = NULL; + sai_router_interface_api_t *sai_rif_api = NULL; + + sai_api_query(SAI_API_NEIGHBOR, (void**)&sai_neighbor_api); + sai_api_query(SAI_API_SWITCH, (void**)&sai_switch_api); + sai_api_query(SAI_API_VIRTUAL_ROUTER, (void**)&sai_virtual_router_api); + sai_api_query(SAI_API_ROUTER_INTERFACE, (void **)&sai_rif_api); + sai_api_query(SAI_API_LAG, (void**)&sai_lag_api); + + uint32_t count = 3; + + std::vector neighbors; + std::vector attrs; + + sai_attribute_t swattr; + + swattr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + swattr.value.booldata = true; + + sai_object_id_t switch_id; + status = sai_switch_api->create_switch(&switch_id, 1, &swattr); + + ASSERT_SUCCESS("Failed to create switch"); + + std::vector> neighbor_attrs; + std::vector neighbor_attrs_array; + std::vector neighbor_attrs_count; + + for (uint32_t i = 0; i < count; ++i) + { + sai_neighbor_entry_t neighbor_entry; + + // virtual router + sai_object_id_t vr; + + status = sai_virtual_router_api->create_virtual_router(&vr, switch_id, 0, NULL); + + ASSERT_SUCCESS("failed to create virtual router"); + + // create lag + sai_object_id_t lag; + status = sai_lag_api->create_lag(&lag, switch_id, 0, NULL); + + // create router interface + sai_object_id_t rif; + sai_attribute_t rifattr[3]; + rifattr[0].id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID; + rifattr[0].value.oid = vr; + rifattr[1].id = SAI_ROUTER_INTERFACE_ATTR_TYPE; + rifattr[1].value.s32 = SAI_ROUTER_INTERFACE_TYPE_PORT; + rifattr[2].id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; + rifattr[2].value.oid = lag; + status = sai_rif_api->create_router_interface(&rif, switch_id, 3, rifattr); + ASSERT_SUCCESS("Failed to create router interface"); + + neighbor_entry.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV4; + neighbor_entry.ip_address.addr.ip4 = 0x10000001 + i; + neighbor_entry.rif_id = rif; + neighbor_entry.switch_id = switch_id; + neighbors.push_back(neighbor_entry); + + std::vector list(1); + sai_attribute_t &attr = list[0]; + + sai_mac_t mac = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS; + memcpy(attr.value.mac, mac, 6); + neighbor_attrs.push_back(list); + neighbor_attrs_count.push_back(1); + } + + for (size_t j = 0; j < neighbor_attrs.size(); j++) + { + neighbor_attrs_array.push_back(neighbor_attrs[j].data()); + } + + std::vector statuses(count); + status = sai_neighbor_api->create_neighbor_entries(count, neighbors.data(), neighbor_attrs_count.data(), neighbor_attrs_array.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); + ASSERT_SUCCESS("Failed to create neighbor"); + for (size_t j = 0; j < statuses.size(); j++) + { + status = statuses[j]; + ASSERT_SUCCESS("Failed to create neighbor # %zu", j); + } + + for (uint32_t i = 0; i < count; ++i) + { + sai_attribute_t attr; + attr.id = SAI_NEIGHBOR_ENTRY_ATTR_PACKET_ACTION; + attr.value.s32 = SAI_PACKET_ACTION_FORWARD; + + status = sai_neighbor_api->set_neighbor_entry_attribute(&neighbors[i], &attr); + + attrs.push_back(attr); + + ASSERT_SUCCESS("Failed to set neighbor"); + } + + statuses.clear(); + statuses.resize(attrs.size()); + + for (auto &attr: attrs) + { + attr.value.s32 = SAI_PACKET_ACTION_FORWARD; + } + + status = sai_neighbor_api->set_neighbor_entries_attribute( + count, + neighbors.data(), + attrs.data(), + SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, + statuses.data()); + + ASSERT_SUCCESS("Failed to bulk set neighbor"); + + for (auto s: statuses) + { + status = s; + + ASSERT_SUCCESS("Failed to bulk set neighbor on one of the neighbors"); + } + + status = sai_neighbor_api->remove_neighbor_entries(count, neighbors.data(), SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, statuses.data()); + ASSERT_SUCCESS("Failed to bulk remove neighbor entry"); +} + void syncdThread() { SWSS_LOG_ENTER(); @@ -699,6 +838,7 @@ void test_invoke_dump() SWSS_LOG_ENTER(); clearDB(); + swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); auto syncd = std::make_shared(syncdThread); syncd->detach(); @@ -708,7 +848,7 @@ void test_invoke_dump() auto sairedis = std::make_shared(); - sai_status_t status = sairedis->initialize(0, &test_services); + sai_status_t status = sairedis->apiInitialize(0, &test_services); CHECK_STATUS(status); @@ -764,15 +904,17 @@ int main() test_bulk_fdb_create(); + test_bulk_neighbor_set(); + test_bulk_route_set(); sai_api_uninitialize(); - printf("\n[ %s ]\n\n", sai_serialize_status(SAI_STATUS_SUCCESS).c_str()); - - test_watchdog_timer_clock_rollback(); + //test_watchdog_timer_clock_rollback(); test_invoke_dump(); + + printf("\n[ %s ]\n\n", sai_serialize_status(SAI_STATUS_SUCCESS).c_str()); } catch (const std::exception &e) { diff --git a/syncd/tests/TestSyncdBrcm.cpp b/syncd/tests/TestSyncdBrcm.cpp index 385b0a11d..892a3ca0e 100644 --- a/syncd/tests/TestSyncdBrcm.cpp +++ b/syncd/tests/TestSyncdBrcm.cpp @@ -109,7 +109,7 @@ class SyncdBrcmTest : public ::testing::Test m_sairedis = std::make_shared(); - auto status = m_sairedis->initialize(0, &test_services); + auto status = m_sairedis->apiInitialize(0, &test_services); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // set communication mode @@ -137,7 +137,7 @@ class SyncdBrcmTest : public ::testing::Test // uninitialize SAI redis - auto status = m_sairedis->uninitialize(); + auto status = m_sairedis->apiUninitialize(); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // stop syncd worker @@ -243,3 +243,149 @@ TEST_F(SyncdBrcmTest, routeBulkCreate) status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, attrs); ASSERT_EQ(status, SAI_STATUS_SUCCESS); } + +TEST_F(SyncdBrcmTest, neighborBulkTest) +{ + sai_object_id_t switchId; + sai_object_id_t rif; + sai_object_id_t port; + sai_attribute_t attrs[3]; + + // init view + + attrs[0].id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD; + attrs[0].value.s32 = SAI_REDIS_NOTIFY_SYNCD_INIT_VIEW; + + auto status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + // create switch + + attrs[0].id = SAI_SWITCH_ATTR_INIT_SWITCH; + attrs[0].value.booldata = true; + + status = m_sairedis->create(SAI_OBJECT_TYPE_SWITCH, &switchId, SAI_NULL_OBJECT_ID, 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + attrs[0].id = SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID; + status = m_sairedis->get(SAI_OBJECT_TYPE_SWITCH, switchId, 1, attrs); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + sai_object_id_t vr = attrs[0].value.oid; + + // create port + static uint32_t id = 1; + id++; + + uint32_t hw_lane_list[1] = { id }; + + attrs[0].id = SAI_PORT_ATTR_HW_LANE_LIST; + attrs[0].value.u32list.count = 1; + attrs[0].value.u32list.list = hw_lane_list; + + attrs[1].id = SAI_PORT_ATTR_SPEED; + attrs[1].value.u32 = 10000; + + status = m_sairedis->create(SAI_OBJECT_TYPE_PORT, &port, switchId, 2, attrs); + EXPECT_EQ(SAI_STATUS_SUCCESS, status); + + // create rif + attrs[0].id = SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID; + attrs[0].value.oid = vr; + + attrs[1].id = SAI_ROUTER_INTERFACE_ATTR_TYPE; + attrs[1].value.s32 = SAI_ROUTER_INTERFACE_TYPE_PORT; + + attrs[2].id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID; + attrs[2].value.oid = port; + + status = m_sairedis->create(SAI_OBJECT_TYPE_ROUTER_INTERFACE, &rif, switchId, 3, attrs); + EXPECT_EQ(SAI_STATUS_SUCCESS, status); + + // create neighbor bulk neighbors in init view mode + + std::vector> neighbor_attrs; + std::vector neighbor_attrs_array; + std::vector neighbor_attrs_count; + std::vector neighbors; + + uint32_t count = 3; + for (uint32_t i = 0; i < count; ++i) + { + sai_neighbor_entry_t neighbor_entry; + + neighbor_entry.ip_address.addr_family = SAI_IP_ADDR_FAMILY_IPV4; + neighbor_entry.ip_address.addr.ip4 = 0x10000001 + i; + neighbor_entry.rif_id = rif; + neighbor_entry.switch_id = switchId; + + neighbors.push_back(neighbor_entry); + + std::vector list(1); // no attributes + sai_attribute_t &neigh_attr = list[0]; + + sai_mac_t mac = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; + neigh_attr.id = SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS; + memcpy(neigh_attr.value.mac, mac, 6); + + neighbor_attrs.push_back(list); + neighbor_attrs_count.push_back(1); + } + + for (size_t j = 0; j < neighbor_attrs.size(); j++) + { + neighbor_attrs_array.push_back(neighbor_attrs[j].data()); + } + + std::vector statuses(count); + + status = m_sairedis->bulkCreate( + count, + neighbors.data(), + neighbor_attrs_count.data(), + neighbor_attrs_array.data(), + SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, + statuses.data()); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + for (size_t j = 0; j < statuses.size(); j++) + { + status = statuses[j]; + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + } + + statuses.clear(); + + for (uint32_t i = 0; i < count; ++i) + { + attrs[i].id = SAI_NEIGHBOR_ENTRY_ATTR_PACKET_ACTION; + attrs[i].value.s32 = SAI_PACKET_ACTION_FORWARD; + } + + status = m_sairedis->bulkSet( + count, + neighbors.data(), + attrs, + SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, + statuses.data()); + + for (size_t j = 0; j < statuses.size(); j++) + { + status = statuses[j]; + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + } + + statuses.clear(); + + status = m_sairedis->bulkRemove( + count, + neighbors.data(), + SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, + statuses.data()); + + for (size_t j = 0; j < statuses.size(); j++) + { + status = statuses[j]; + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + } +} diff --git a/syncd/tests/TestSyncdLib.cpp b/syncd/tests/TestSyncdLib.cpp index 241a307e2..e22bdbeb7 100644 --- a/syncd/tests/TestSyncdLib.cpp +++ b/syncd/tests/TestSyncdLib.cpp @@ -8,18 +8,31 @@ #include "TestSyncdLib.h" -void flushAsicDb() +void flushDb(std::string name) { SWSS_LOG_ENTER(); - auto db = std::make_shared("ASIC_DB", 0, true); + auto db = std::make_shared(name, 0, true); auto reply = std::make_shared(db.get(), "FLUSHALL", REDIS_REPLY_STATUS); reply->checkStatusOK(); - SWSS_LOG_NOTICE("Flushed ASIC DB"); + SWSS_LOG_NOTICE("Flushed %s", name.c_str()); } +void flushAsicDb() +{ + SWSS_LOG_ENTER(); + + flushDb("ASIC_DB"); +} + +void flushFlexCounterDb() +{ + SWSS_LOG_ENTER(); + + flushDb("FLEX_COUNTER_DB"); +} void sendSyncdShutdownNotification() { SWSS_LOG_ENTER(); diff --git a/syncd/tests/TestSyncdLib.h b/syncd/tests/TestSyncdLib.h index 99d27a8b4..edf142eee 100644 --- a/syncd/tests/TestSyncdLib.h +++ b/syncd/tests/TestSyncdLib.h @@ -1,4 +1,5 @@ #pragma once void flushAsicDb(); +void flushFlexCounterDb(); void sendSyncdShutdownNotification(); diff --git a/syncd/tests/TestSyncdMlnx.cpp b/syncd/tests/TestSyncdMlnx.cpp index 457f621a9..34311cb42 100644 --- a/syncd/tests/TestSyncdMlnx.cpp +++ b/syncd/tests/TestSyncdMlnx.cpp @@ -11,7 +11,9 @@ #include #include +#include +#include "meta/sai_serialize.h" #include "Sai.h" #include "Syncd.h" #include "MetadataLogger.h" @@ -102,6 +104,9 @@ class SyncdMlnxTest : public ::testing::Test flushAsicDb(); + // flush FLEX COUNTER DB + flushFlexCounterDb(); + // start syncd worker m_worker = std::make_shared(syncdMlnxWorkerThread); @@ -110,7 +115,7 @@ class SyncdMlnxTest : public ::testing::Test m_sairedis = std::make_shared(); - auto status = m_sairedis->initialize(0, &test_services); + auto status = m_sairedis->apiInitialize(0, &test_services); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // set communication mode @@ -138,6 +143,10 @@ class SyncdMlnxTest : public ::testing::Test status = m_sairedis->create(SAI_OBJECT_TYPE_SWITCH, &m_switchId, SAI_NULL_OBJECT_ID, 1, &attr); ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + auto db = std::make_shared("FLEX_COUNTER_DB", 0); + m_flexCounterGroupTable = std::make_shared(db.get(), "FLEX_COUNTER_GROUP_TABLE"); + m_flexCounterTable = std::make_shared(db.get(), "FLEX_COUNTER_TABLE"); } virtual void TearDown() override @@ -146,7 +155,7 @@ class SyncdMlnxTest : public ::testing::Test // uninitialize SAI redis - auto status = m_sairedis->uninitialize(); + auto status = m_sairedis->apiUninitialize(); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // stop syncd worker @@ -158,6 +167,8 @@ class SyncdMlnxTest : public ::testing::Test protected: std::shared_ptr m_worker; std::shared_ptr m_sairedis; + std::shared_ptr m_flexCounterGroupTable; + std::shared_ptr m_flexCounterTable; sai_object_id_t m_switchId = SAI_NULL_OBJECT_ID; }; @@ -166,7 +177,7 @@ TEST_F(SyncdMlnxTest, queryAttrEnumValuesCapability) { sai_s32_list_t data = { .count = 0, .list = nullptr }; - auto status = m_sairedis->queryAattributeEnumValuesCapability( + auto status = m_sairedis->queryAttributeEnumValuesCapability( m_switchId, SAI_OBJECT_TYPE_HASH, SAI_HASH_ATTR_NATIVE_HASH_FIELD_LIST, &data ); ASSERT_EQ(status, SAI_STATUS_BUFFER_OVERFLOW); @@ -174,7 +185,7 @@ TEST_F(SyncdMlnxTest, queryAttrEnumValuesCapability) std::vector hfList(data.count); data.list = hfList.data(); - status = m_sairedis->queryAattributeEnumValuesCapability( + status = m_sairedis->queryAttributeEnumValuesCapability( m_switchId, SAI_OBJECT_TYPE_HASH, SAI_HASH_ATTR_NATIVE_HASH_FIELD_LIST, &data ); ASSERT_EQ(status, SAI_STATUS_SUCCESS); @@ -248,6 +259,102 @@ TEST_F(SyncdMlnxTest, portBulkAddRemove) ASSERT_EQ(statusList.at(i), SAI_STATUS_SUCCESS); } + // Counter operations based on the created port + // 1. Enable counter polling for port stat counter group + sai_redis_flex_counter_group_parameter_t flexCounterGroupParam; + + std::string group("PORT_STAT_COUNTER"); + std::string poll_interval = "10000"; + std::string stats_mode = "STATS_MODE_READ"; + std::string operation = "enable"; + + flexCounterGroupParam.counter_group_name.list = (int8_t*)const_cast(group.c_str()); + flexCounterGroupParam.counter_group_name.count = (uint32_t)group.length(); + flexCounterGroupParam.poll_interval.list = (int8_t*)const_cast(poll_interval.c_str()); + flexCounterGroupParam.poll_interval.count = (uint32_t)poll_interval.length(); + flexCounterGroupParam.plugin_name.list = nullptr; + flexCounterGroupParam.plugin_name.count = 0; + flexCounterGroupParam.plugins.list = nullptr; + flexCounterGroupParam.plugins.count = 0; + flexCounterGroupParam.stats_mode.list = (int8_t*)const_cast(stats_mode.c_str()); + flexCounterGroupParam.stats_mode.count = (uint32_t)stats_mode.length(); + flexCounterGroupParam.operation.list = (int8_t*)const_cast(operation.c_str());; + flexCounterGroupParam.operation.count = (uint32_t)operation.length(); + + attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP; + attr.value.ptr = (void*)&flexCounterGroupParam; + + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + std::vector fvVector, fvVectorExpected; + ASSERT_TRUE(m_flexCounterGroupTable->get("PORT_STAT_COUNTER", fvVector)); + fvVectorExpected.emplace_back(POLL_INTERVAL_FIELD, poll_interval); + fvVectorExpected.emplace_back(STATS_MODE_FIELD, stats_mode); + fvVectorExpected.emplace_back(FLEX_COUNTER_STATUS_FIELD, operation); + ASSERT_EQ(fvVectorExpected, fvVector); + fvVectorExpected.clear(); + fvVector.clear(); + + // 2. Start counter polling for the port just created + // Try with a bad key first + sai_redis_flex_counter_parameter_t flexCounterParam; + std::string key = "PORT_STAT_COUNTER"; + std::string counters = "SAI_PORT_STAT_IF_IN_OCTETS"; + std::string counter_field_name = "PORT_COUNTER_ID_LIST"; + + flexCounterParam.counter_key.list = (int8_t*)const_cast(key.c_str()); + flexCounterParam.counter_key.count = (uint32_t)key.length(); + flexCounterParam.counter_ids.list = (int8_t*)const_cast(counters.c_str()); + flexCounterParam.counter_ids.count = (uint32_t)counters.length(); + flexCounterParam.counter_field_name.list = (int8_t*)const_cast(counter_field_name.c_str()); + flexCounterParam.counter_field_name.count = (uint32_t)counter_field_name.length(); + flexCounterParam.stats_mode.list = nullptr; + flexCounterParam.stats_mode.count = 0; + + attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER; + attr.value.ptr = (void*)&flexCounterParam; + + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr); + ASSERT_EQ(status, SAI_STATUS_FAILURE); + ASSERT_FALSE(m_flexCounterTable->get(key, fvVector)); + + // Try with a good key + key = "PORT_STAT_COUNTER:" + sai_serialize_object_id(oidList[0]); + flexCounterParam.counter_key.list = (int8_t*)const_cast(key.c_str()); + flexCounterParam.counter_key.count = (uint32_t)key.length(); + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + + ASSERT_TRUE(m_flexCounterTable->get(key, fvVector)); + fvVectorExpected.emplace_back(counter_field_name, counters); + ASSERT_EQ(fvVectorExpected, fvVector); + + flexCounterParam.counter_ids.list = nullptr; + flexCounterParam.counter_ids.count = 0; + flexCounterParam.counter_field_name.list = nullptr; + flexCounterParam.counter_field_name.count = 0; + + // 3. Stop counter polling for the port + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + ASSERT_FALSE(m_flexCounterTable->get(key, fvVector)); + + // 4. Disable counter polling for the group + flexCounterGroupParam.poll_interval.list = nullptr; + flexCounterGroupParam.poll_interval.count = 0; + flexCounterGroupParam.stats_mode.list = nullptr; + flexCounterGroupParam.stats_mode.count = 0; + flexCounterGroupParam.operation.list = nullptr; + flexCounterGroupParam.operation.count = 0; + + attr.id = SAI_REDIS_SWITCH_ATTR_FLEX_COUNTER_GROUP; + attr.value.ptr = (void*)&flexCounterGroupParam; + + status = m_sairedis->set(SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr); + ASSERT_EQ(status, SAI_STATUS_SUCCESS); + ASSERT_FALSE(m_flexCounterTable->get(key, fvVector)); + // Validate port bulk remove status = m_sairedis->bulkRemove( SAI_OBJECT_TYPE_PORT, portCount, oidList.data(), diff --git a/syncd/tests/TestSyncdNvdaBf.cpp b/syncd/tests/TestSyncdNvdaBf.cpp index 33c1d1227..f86ba08a9 100644 --- a/syncd/tests/TestSyncdNvdaBf.cpp +++ b/syncd/tests/TestSyncdNvdaBf.cpp @@ -132,7 +132,7 @@ void SyncdNvdaBfTest::SetUp() m_sairedis = std::make_shared(); - auto status = m_sairedis->initialize(0, &test_services); + auto status = m_sairedis->apiInitialize(0, &test_services); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // set communication mode @@ -168,7 +168,7 @@ void SyncdNvdaBfTest::TearDown() // uninitialize SAI redis - auto status = m_sairedis->uninitialize(); + auto status = m_sairedis->apiUninitialize(); ASSERT_EQ(status, SAI_STATUS_SUCCESS); // stop syncd worker @@ -578,7 +578,7 @@ TEST_F(SyncdNvdaBfTest, dashVip) EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->get(&vip, (uint32_t)attrs.size(), attrs.data())); EXPECT_EQ(attrs[0].value.s32, SAI_VIP_ENTRY_ACTION_ACCEPT); - attr.id = SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID; + attr.id = SAI_VIP_ENTRY_ATTR_ACTION; attr.value.s32 = SAI_VIP_ENTRY_ACTION_ACCEPT; EXPECT_EQ(SAI_STATUS_SUCCESS, m_sairedis->set(&vip, &attr)); diff --git a/tests/BCM56850.pl b/tests/BCM56850.pl index 5127757c7..7dd6ea0a8 100755 --- a/tests/BCM56850.pl +++ b/tests/BCM56850.pl @@ -580,6 +580,13 @@ sub test_bulk_route play "bulk_route.rec" } +sub test_bulk_neighbor +{ + fresh_start; + + play "bulk_neighbor.rec" +} + sub test_bulk_fdb { fresh_start; @@ -862,6 +869,7 @@ sub test_acl_pre_match_999 test_acl_mask; test_empty_lag_buffer_acl; test_bulk_route; +test_bulk_neighbor; test_bulk_fdb; test_bulk_object; test_brcm_config_acl; diff --git a/tests/BCM56850/bulk_neighbor.rec b/tests/BCM56850/bulk_neighbor.rec new file mode 100644 index 000000000..4d0887031 --- /dev/null +++ b/tests/BCM56850/bulk_neighbor.rec @@ -0,0 +1,12 @@ +2024-05-22.01:55:46.541806|#|recording on: ./sairedis.2024-05-22.01:55:46.541389.rec +2024-05-22.01:55:46.543987|a|INIT_VIEW +2024-05-22.01:55:46.551164|A|SAI_STATUS_SUCCESS +2024-05-22.01:55:46.555975|c|SAI_OBJECT_TYPE_SWITCH:oid:0x21000000000000|SAI_SWITCH_ATTR_INIT_SWITCH=true|SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY=0x417890|SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY=0x4179f0|SAI_SWITCH_ATTR_SWITCH_SHUTDOWN_REQUEST_NOTIFY=0x417b50 +2024-05-22.01:56:05.508992|c|SAI_OBJECT_TYPE_VIRTUAL_ROUTER:oid:0x3000000000004 +2024-05-22.01:56:05.708992|c|SAI_OBJECT_TYPE_PORT:oid:0x20000000006ee|SAI_PORT_ATTR_SPEED=10000|SAI_PORT_ATTR_HW_LANE_LIST=1:202 +2024-05-22.01:56:05.805336|c|SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000727|SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID=oid:0x3000000000004|SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS=00:E0:EC:C2:AF:7A|SAI_ROUTER_INTERFACE_ATTR_TYPE=SAI_ROUTER_INTERFACE_TYPE_PORT|SAI_ROUTER_INTERFACE_ATTR_PORT_ID=oid:0x20000000006ee|SAI_ROUTER_INTERFACE_ATTR_MTU=9100|SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID=0 +2024-05-22.01:56:06.105336|C|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:FF||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:FF +2024-05-22.01:56:06.205336|S|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:00||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}|SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS=FF:FF:FF:FF:FF:00 +2024-05-22.01:56:06.205336|R|SAI_OBJECT_TYPE_NEIGHBOR_ENTRY||{"ip":"10.0.0.57","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"}||{"ip":"10.0.0.59","rif":"oid:0x6000000000727","switch_id":"oid:0x21000000000000"} +2024-05-22.01:56:06.151337|a|APPLY_VIEW +2024-05-22.01:56:06.156740|A|SAI_STATUS_SUCCESS \ No newline at end of file diff --git a/tests/Makefile.am b/tests/Makefile.am index 7405bab0d..b86eb095b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,4 +33,4 @@ testdash_gtest_LDADD = -lgtest -lhiredis -lswsscommon -lpthread \ $(top_srcdir)/lib/libsairedis.la $(top_srcdir)/syncd/libSyncd.a \ -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) -TESTS = aspellcheck.pl conflictnames.pl swsslogentercheck.sh checkwhitespace.sh tests BCM56850.pl MLNX2700.pl BCM56971B0.pl NVDAMBF2H536C.pl testdash_gtest +TESTS = checksaiapi.sh aspellcheck.pl conflictnames.pl swsslogentercheck.sh checkwhitespace.sh tests BCM56850.pl MLNX2700.pl BCM56971B0.pl NVDAMBF2H536C.pl testdash_gtest diff --git a/tests/TestDash.cpp b/tests/TestDash.cpp index 1e1ec5057..49da8e510 100644 --- a/tests/TestDash.cpp +++ b/tests/TestDash.cpp @@ -261,7 +261,7 @@ TEST(APIBulk, eni_ether_address_map_entry) } for (uint32_t i = 0; i < entries_count; i++) { - attr.id = SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION; + attr.id = SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID; ASSERT_SUCCESS(dash_api->get_eni_ether_address_map_entry_attribute(&entries[i], 1, &attr)); ASSERT_EQ(attr.value.oid, attr_list[i][0].value.oid); } @@ -535,7 +535,7 @@ TEST(API, vip_entry) ASSERT_SUCCESS(dash_api->get_vip_entry_attribute(&vip, (uint32_t)attrs.size(), attrs.data())); ASSERT_EQ(attrs[0].value.s32, SAI_VIP_ENTRY_ACTION_ACCEPT); - attr.id = SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID; + attr.id = SAI_VIP_ENTRY_ATTR_ACTION; attr.value.s32 = SAI_VIP_ENTRY_ACTION_ACCEPT; ASSERT_SUCCESS(dash_api->set_vip_entry_attribute(&vip, &attr)); ASSERT_SUCCESS(dash_api->get_vip_entry_attribute(&vip, (uint32_t)attrs.size(), attrs.data())); diff --git a/tests/aspell.en.pws b/tests/aspell.en.pws index 256c8ae9d..86403451e 100644 --- a/tests/aspell.en.pws +++ b/tests/aspell.en.pws @@ -82,6 +82,7 @@ SAs SCs SDK SGs +SHA SONiC SRC STP @@ -248,6 +249,7 @@ IPG ipgs IPGs ipmc +iproute IPv isobjectid isoidattribute @@ -472,3 +474,4 @@ ZMQ ZMQ uncreated TWAMP +saiproxy diff --git a/tests/aspellcheck.pl b/tests/aspellcheck.pl index 73c2609a7..4b28a6b18 100755 --- a/tests/aspellcheck.pl +++ b/tests/aspellcheck.pl @@ -151,6 +151,7 @@ sub RunAspell next if $file =~ m!/config.h!; next if $file =~ m!/python/.+wrap.cpp!; next if $file =~ m!/pyext/.+wrap.cpp!; + next if $file =~ m!sai_(redis|proxy|vs|stub).cpp!; my $data = ReadFile $file; diff --git a/tests/checksaiapi.sh b/tests/checksaiapi.sh new file mode 100755 index 000000000..05894fd8d --- /dev/null +++ b/tests/checksaiapi.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# this script checks if only allowed files are using global sai apis + +# in entire project we only allow VendorSai.cpp and saisdkdump.cpp to use global SAI API, + +# PLEASE DO NOT ADD ANY MORE EXCEPTIONS + +# we want to keep track of usage global apis to minimize scope of usage for +# possible future mistakes that we will be using dynmically loaded libsai.so +# and by mistake someone will be calling global api that was linked with syncd, +# this will be hard error to locate + +set -e + +cd .. + +find -name "*.o" | +grep -v pyext | +grep -v tests | +while read all; +do + echo -n $all; + nm $all | + grep "U sai_" | + grep -vP "sai_metadata|sai_serialize|sai_deserialize" | + perl -npe 'chomp' + echo +done | +grep "U sai_" | +awk '{print $1}' | +perl -ne 'chomp; die "file $_ is using global sai_xxx API, please correct your code" if not /VendorSai.o|sai_redis.o|sai_vs.o|sai_proxy.o|saisdkdump/' + +REGEX=`cat SAI/meta/saimetadata.c|grep dlsym|grep handle|perl -ne 'print "$1|" if /(sai_\w+)/'|perl -pe 'chop'|perl -ne 'print "\\\\b($_)\\\\b"'` + +set +e +find -name "*.cpp" -o -name "*.c" | +xargs grep -P "$REGEX" | +grep -vP "/unittest/|/tests/|/SAI/|/pyext/|tests.cpp|sai_vs.cpp|sai_proxy.cpp|sai_redis.cpp|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 + exit 1 +fi + 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/lib/Makefile.am b/unittest/lib/Makefile.am index 11384eee0..62e3a187f 100644 --- a/unittest/lib/Makefile.am +++ b/unittest/lib/Makefile.am @@ -1,6 +1,6 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/lib -bin_PROGRAMS = tests testslibsairedis +bin_PROGRAMS = tests LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main @@ -22,72 +22,13 @@ tests_SOURCES = \ TestServerConfig.cpp \ TestRedisVidIndexGenerator.cpp \ TestRecorder.cpp \ - TestRedisChannel.cpp + TestRedisChannel.cpp \ + TestClientSai.cpp \ + TestRedisRemoteSaiInterface.cpp \ + TestServerSai.cpp \ + TestSai.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) -testslibsairedis_SOURCES = main_libsairedis.cpp \ - test_sai_redis_acl.cpp \ - test_sai_redis_bfd.cpp \ - test_sai_redis_bmtor.cpp \ - test_sai_redis_bridge.cpp \ - test_sai_redis_buffer.cpp \ - test_sai_redis_counter.cpp \ - test_sai_redis_dash_vip.cpp \ - test_sai_redis_dash_pa_validation.cpp \ - test_sai_redis_dash_vnet.cpp \ - test_sai_redis_dash_outbound_routing.cpp \ - test_sai_redis_dash_outbound_ca_to_pa.cpp \ - test_sai_redis_dash_inbound_routing.cpp \ - test_sai_redis_dash_eni.cpp \ - test_sai_redis_dash_direction_lookup.cpp \ - test_sai_redis_dash_acl.cpp \ - test_sai_redis_debug_counter.cpp \ - test_sai_redis_dtel.cpp \ - test_sai_redis_fdb.cpp \ - test_sai_redis_generic_programmable.cpp \ - test_sai_redis_ipmc.cpp \ - test_sai_redis_l2mc.cpp \ - test_sai_redis_l2mcgroup.cpp \ - test_sai_redis_lag.cpp \ - test_sai_redis_ipmc_group.cpp \ - test_sai_redis_macsec.cpp \ - test_sai_redis_isolation_group.cpp \ - test_sai_redis_interfacequery.cpp \ - test_sai_redis_mcastfdb.cpp \ - test_sai_redis_mirror.cpp \ - test_sai_redis_mpls.cpp \ - test_sai_redis_nat.cpp \ - test_sai_redis_hash.cpp \ - test_sai_redis_neighbor.cpp \ - test_sai_redis_nexthop.cpp \ - test_sai_redis_nexthopgroup.cpp \ - test_sai_redis_port.cpp \ - test_sai_redis_qosmap.cpp \ - test_sai_redis_policer.cpp \ - test_sai_redis_queue.cpp \ - test_sai_redis_route.cpp \ - test_sai_redis_router_interface.cpp \ - test_sai_redis_router_rpfgroup.cpp \ - test_sai_redis_router_samplepacket.cpp \ - test_sai_redis_schedulergroup.cpp \ - test_sai_redis_scheduler.cpp \ - test_sai_redis_srv6.cpp \ - test_sai_redis_switch.cpp \ - test_sai_redis_system_port.cpp \ - test_sai_redis_tam.cpp \ - test_sai_redis_tunnel.cpp \ - test_sai_redis_stp.cpp \ - test_sai_redis_udf.cpp \ - test_sai_redis_virtual_router.cpp \ - test_sai_redis_vlan.cpp \ - test_sai_redis_hostif.cpp \ - test_sai_redis_wred.cpp \ - test_sai_redis_ars.cpp \ - test_sai_redis_ars_profile.cpp - -testslibsairedis_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -testslibsairedis_LDADD = $(LDADD_GTEST) -L$(top_srcdir)/lib/.libs -lsairedis -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) - -TESTS = testslibsairedis tests +TESTS = tests diff --git a/unittest/lib/TestClientSai.cpp b/unittest/lib/TestClientSai.cpp new file mode 100644 index 000000000..b080fd23a --- /dev/null +++ b/unittest/lib/TestClientSai.cpp @@ -0,0 +1,52 @@ +#include "ClientSai.h" + +#include + +#include + +using namespace sairedis; + +static const char* profile_get_value( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable) +{ + SWSS_LOG_ENTER(); + return NULL; +} + +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(); + return -1; +} + +static sai_service_method_table_t test_services = { + profile_get_value, + profile_get_next_value +}; + +TEST(ClientSai, bulkGet) +{ + ClientSai sai; + + sai.apiInitialize(0,&test_services); + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/lib/TestClientServerSai.cpp b/unittest/lib/TestClientServerSai.cpp index 67894f7c2..1f6c06a50 100644 --- a/unittest/lib/TestClientServerSai.cpp +++ b/unittest/lib/TestClientServerSai.cpp @@ -61,23 +61,23 @@ TEST(ClientServerSai, ctr) auto css = std::make_shared(); } -TEST(ClientServerSai, initialize) +TEST(ClientServerSai, apiInitialize) { auto css = std::make_shared(); - EXPECT_NE(SAI_STATUS_SUCCESS, css->initialize(1, nullptr)); + EXPECT_NE(SAI_STATUS_SUCCESS, css->apiInitialize(1, nullptr)); - EXPECT_NE(SAI_STATUS_SUCCESS, css->initialize(0, nullptr)); + EXPECT_NE(SAI_STATUS_SUCCESS, css->apiInitialize(0, nullptr)); - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); css = nullptr; // invoke uninitialize in destructor css = std::make_shared(); - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); - EXPECT_NE(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); + EXPECT_NE(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); } TEST(ClientServerSai, objectTypeQuery) @@ -100,7 +100,7 @@ TEST(ClientServerSai, logSet) EXPECT_NE(SAI_STATUS_SUCCESS, css->logSet(SAI_API_PORT, SAI_LOG_LEVEL_NOTICE)); - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); EXPECT_EQ(SAI_STATUS_SUCCESS, css->logSet(SAI_API_PORT, SAI_LOG_LEVEL_NOTICE)); } @@ -128,7 +128,7 @@ TEST(ClientServerSai, bulkGetClearStats) SAI_STATS_MODE_BULK_CLEAR, nullptr)); - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, css->bulkGetStats(SAI_NULL_OBJECT_ID, SAI_OBJECT_TYPE_PORT, @@ -150,7 +150,7 @@ TEST(ClientServerSai, bulkGetClearStats) nullptr)); css = std::make_shared(); - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_client_services)); + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_client_services)); EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, css->bulkGetStats(SAI_NULL_OBJECT_ID, SAI_OBJECT_TYPE_PORT, @@ -177,14 +177,14 @@ TEST(ClientServerSai, OT) \ { \ auto css = std::make_shared(); \ sai_ ## ot ## _t e = {}; \ - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); \ + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->create(&e, 0, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->set(&e, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->get(&e, 0, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->remove(&e)); \ \ auto ss = std::make_shared(); \ - EXPECT_EQ(SAI_STATUS_SUCCESS, ss->initialize(0, &test_services)); \ + EXPECT_EQ(SAI_STATUS_SUCCESS, ss->apiInitialize(0, &test_services)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->create(&e, 0, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->set(&e, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->get(&e, 0, nullptr)); \ @@ -198,16 +198,38 @@ TEST(ClientServerSai, bulk_ ## OT) { \ auto css = std::make_shared(); \ sai_ ## ot ## _t e[2] = {}; \ - EXPECT_EQ(SAI_STATUS_SUCCESS, css->initialize(0, &test_services)); \ + EXPECT_EQ(SAI_STATUS_SUCCESS, css->apiInitialize(0, &test_services)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->bulkCreate(0, e, nullptr, nullptr, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->bulkSet(2, e, nullptr, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, css->bulkRemove(2, e, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ \ auto ss = std::make_shared(); \ - EXPECT_EQ(SAI_STATUS_SUCCESS, ss->initialize(0, &test_client_services)); \ + EXPECT_EQ(SAI_STATUS_SUCCESS, ss->apiInitialize(0, &test_client_services)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->bulkCreate(0, e, nullptr, nullptr, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->bulkSet(0, e, nullptr, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ EXPECT_NE(SAI_STATUS_SUCCESS, ss->bulkRemove(0, e, SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR, nullptr)); \ } SAIREDIS_DECLARE_EVERY_BULK_ENTRY(TEST_BULK_ENTRY) + + +TEST(ClientServerSai, bulkGet) +{ + ClientServerSai sai; + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/lib/TestRedisRemoteSaiInterface.cpp b/unittest/lib/TestRedisRemoteSaiInterface.cpp new file mode 100644 index 000000000..a638228a0 --- /dev/null +++ b/unittest/lib/TestRedisRemoteSaiInterface.cpp @@ -0,0 +1,30 @@ +#include "RedisRemoteSaiInterface.h" +#include "ContextConfigContainer.h" + +#include + +using namespace sairedis; + +TEST(RedisRemoteSaiInterface, bulkGet) +{ + auto ctx = ContextConfigContainer::loadFromFile("foo"); + auto rec = std::make_shared(); + + RedisRemoteSaiInterface sai(ctx->get(0), nullptr, rec); + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/lib/TestSai.cpp b/unittest/lib/TestSai.cpp new file mode 100644 index 000000000..9d3e11790 --- /dev/null +++ b/unittest/lib/TestSai.cpp @@ -0,0 +1,62 @@ +#include "Sai.h" + +#include + +#include + +using namespace sairedis; + +static const char* profile_get_value( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable) +{ + SWSS_LOG_ENTER(); + return NULL; +} + +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(); + return -1; +} + +static sai_service_method_table_t test_services = { + profile_get_value, + profile_get_next_value +}; + +TEST(Sai, queryApiVersion) +{ + Sai sai; + + sai_api_version_t version; + + sai.apiInitialize(0,&test_services); + + EXPECT_EQ(sai.queryApiVersion(NULL), SAI_STATUS_INVALID_PARAMETER); + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); +} + +TEST(Sai, bulkGet) +{ + Sai sai; + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/lib/TestServerSai.cpp b/unittest/lib/TestServerSai.cpp new file mode 100644 index 000000000..91185c025 --- /dev/null +++ b/unittest/lib/TestServerSai.cpp @@ -0,0 +1,52 @@ +#include "ServerSai.h" + +#include + +#include + +using namespace sairedis; + +static const char* profile_get_value( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable) +{ + SWSS_LOG_ENTER(); + return NULL; +} + +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(); + return -1; +} + +static sai_service_method_table_t test_services = { + profile_get_value, + profile_get_next_value +}; + +TEST(ServerSai, bulkGet) +{ + ServerSai sai; + + sai.apiInitialize(0,&test_services); + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/lib/TestSwitch.cpp b/unittest/lib/TestSwitch.cpp index 8cb25f7bc..58a635b0a 100644 --- a/unittest/lib/TestSwitch.cpp +++ b/unittest/lib/TestSwitch.cpp @@ -22,7 +22,7 @@ TEST(Switch, updateNotifications) { auto s = std::make_shared(7); - sai_attribute_t attrs[10]; + sai_attribute_t attrs[11]; attrs[0].id = 10000; @@ -38,6 +38,7 @@ TEST(Switch, updateNotifications) attrs[7].value.ptr = (void*)1; attrs[8].value.ptr = (void*)1; attrs[9].value.ptr = (void*)1; + attrs[10].value.ptr = (void*)1; attrs[0].id = SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY; attrs[1].id = SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY; @@ -48,9 +49,10 @@ TEST(Switch, updateNotifications) attrs[6].id = SAI_SWITCH_ATTR_BFD_SESSION_STATE_CHANGE_NOTIFY; attrs[7].id = SAI_SWITCH_ATTR_NAT_EVENT_NOTIFY; attrs[8].id = SAI_SWITCH_ATTR_PORT_HOST_TX_READY_NOTIFY; - attrs[9].id = SAI_SWITCH_ATTR_INIT_SWITCH; + attrs[9].id = SAI_SWITCH_ATTR_SWITCH_ASIC_SDK_HEALTH_EVENT_NOTIFY; + attrs[10].id = SAI_SWITCH_ATTR_INIT_SWITCH; - s->updateNotifications(9, attrs); + s->updateNotifications(10, attrs); auto sn = s->getSwitchNotifications(); @@ -63,4 +65,5 @@ TEST(Switch, updateNotifications) EXPECT_EQ((void*)1, sn.on_switch_state_change); EXPECT_EQ((void*)1, sn.on_nat_event); EXPECT_EQ((void*)1, sn.on_port_host_tx_ready); + EXPECT_EQ((void*)1, sn.on_switch_asic_sdk_health_event); } diff --git a/unittest/lib/TestUtils.cpp b/unittest/lib/TestUtils.cpp index cc91c8505..e43df06a3 100644 --- a/unittest/lib/TestUtils.cpp +++ b/unittest/lib/TestUtils.cpp @@ -12,7 +12,7 @@ TEST(Utils, clearOidValues) { sai_attribute_t attr; - sai_object_id_t oids[1]; + sai_object_id_t oids[1] = {0}; attr.id = 1000; diff --git a/unittest/lib/test_sai_redis_acl.cpp b/unittest/lib/test_sai_redis_acl.cpp deleted file mode 100644 index d1db2481e..000000000 --- a/unittest/lib/test_sai_redis_acl.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_ars.cpp b/unittest/lib/test_sai_redis_ars.cpp deleted file mode 100644 index 79befdb48..000000000 --- a/unittest/lib/test_sai_redis_ars.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_ars_profile.cpp b/unittest/lib/test_sai_redis_ars_profile.cpp deleted file mode 100644 index 3cb586d12..000000000 --- a/unittest/lib/test_sai_redis_ars_profile.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_bfd.cpp b/unittest/lib/test_sai_redis_bfd.cpp deleted file mode 100644 index 419b3e7cb..000000000 --- a/unittest/lib/test_sai_redis_bfd.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_bmtor.cpp b/unittest/lib/test_sai_redis_bmtor.cpp deleted file mode 100644 index 60db78606..000000000 --- a/unittest/lib/test_sai_redis_bmtor.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_bridge.cpp b/unittest/lib/test_sai_redis_bridge.cpp deleted file mode 100644 index 6575ab41f..000000000 --- a/unittest/lib/test_sai_redis_bridge.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_buffer.cpp b/unittest/lib/test_sai_redis_buffer.cpp deleted file mode 100644 index aad915ec9..000000000 --- a/unittest/lib/test_sai_redis_buffer.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_counter.cpp b/unittest/lib/test_sai_redis_counter.cpp deleted file mode 100644 index 97000adf1..000000000 --- a/unittest/lib/test_sai_redis_counter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_acl.cpp b/unittest/lib/test_sai_redis_dash_acl.cpp deleted file mode 100644 index f54435572..000000000 --- a/unittest/lib/test_sai_redis_dash_acl.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_direction_lookup.cpp b/unittest/lib/test_sai_redis_dash_direction_lookup.cpp deleted file mode 100644 index 4ecd63a1b..000000000 --- a/unittest/lib/test_sai_redis_dash_direction_lookup.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_eni.cpp b/unittest/lib/test_sai_redis_dash_eni.cpp deleted file mode 100644 index 5949762c6..000000000 --- a/unittest/lib/test_sai_redis_dash_eni.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_inbound_routing.cpp b/unittest/lib/test_sai_redis_dash_inbound_routing.cpp deleted file mode 100644 index 132e014eb..000000000 --- a/unittest/lib/test_sai_redis_dash_inbound_routing.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_outbound_ca_to_pa.cpp b/unittest/lib/test_sai_redis_dash_outbound_ca_to_pa.cpp deleted file mode 100644 index 91671cce5..000000000 --- a/unittest/lib/test_sai_redis_dash_outbound_ca_to_pa.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_outbound_routing.cpp b/unittest/lib/test_sai_redis_dash_outbound_routing.cpp deleted file mode 100644 index 87791668d..000000000 --- a/unittest/lib/test_sai_redis_dash_outbound_routing.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_pa_validation.cpp b/unittest/lib/test_sai_redis_dash_pa_validation.cpp deleted file mode 100644 index ff8ea16b3..000000000 --- a/unittest/lib/test_sai_redis_dash_pa_validation.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_vip.cpp b/unittest/lib/test_sai_redis_dash_vip.cpp deleted file mode 100644 index 67337fcc6..000000000 --- a/unittest/lib/test_sai_redis_dash_vip.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dash_vnet.cpp b/unittest/lib/test_sai_redis_dash_vnet.cpp deleted file mode 100644 index 61c4d694a..000000000 --- a/unittest/lib/test_sai_redis_dash_vnet.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_debug_counter.cpp b/unittest/lib/test_sai_redis_debug_counter.cpp deleted file mode 100644 index 8382f138a..000000000 --- a/unittest/lib/test_sai_redis_debug_counter.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_dtel.cpp b/unittest/lib/test_sai_redis_dtel.cpp deleted file mode 100644 index 681ba5dbb..000000000 --- a/unittest/lib/test_sai_redis_dtel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_fdb.cpp b/unittest/lib/test_sai_redis_fdb.cpp deleted file mode 100644 index 12133a886..000000000 --- a/unittest/lib/test_sai_redis_fdb.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_generic_programmable.cpp b/unittest/lib/test_sai_redis_generic_programmable.cpp deleted file mode 100644 index 37e79f28f..000000000 --- a/unittest/lib/test_sai_redis_generic_programmable.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_hash.cpp b/unittest/lib/test_sai_redis_hash.cpp deleted file mode 100644 index b68cb1581..000000000 --- a/unittest/lib/test_sai_redis_hash.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_hostif.cpp b/unittest/lib/test_sai_redis_hostif.cpp deleted file mode 100644 index f1dfaadb3..000000000 --- a/unittest/lib/test_sai_redis_hostif.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_interfacequery.cpp b/unittest/lib/test_sai_redis_interfacequery.cpp deleted file mode 100644 index 3bc28c9f6..000000000 --- a/unittest/lib/test_sai_redis_interfacequery.cpp +++ /dev/null @@ -1,115 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, sai_log_set) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_log_set(SAI_API_VLAN, SAI_LOG_LEVEL_NOTICE)); -} - -TEST(libsairedis, 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(libsairedis, sai_query_attribute_capability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_query_attribute_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); -} - -TEST(libsairedis, sai_query_attribute_enum_values_capability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_query_attribute_enum_values_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); -} - -TEST(libsairedis, sai_object_type_get_availability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_object_type_get_availability(0,SAI_OBJECT_TYPE_NULL,0,0,0)); -} - -TEST(libsairedis, sai_dbg_generate_dump) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_dbg_generate_dump(nullptr)); -} - -TEST(libsairedis, sai_object_type_query) -{ - EXPECT_EQ(SAI_OBJECT_TYPE_NULL, sai_object_type_query(SAI_NULL_OBJECT_ID)); -} - -TEST(libsairedis, sai_switch_id_query) -{ - EXPECT_EQ(SAI_NULL_OBJECT_ID, sai_switch_id_query(SAI_NULL_OBJECT_ID)); -} - -TEST(libsairedis, 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(libsairedis, sai_get_maximum_attribute_count) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_maximum_attribute_count(0, SAI_OBJECT_TYPE_NULL,0)); -} - -TEST(libsairedis, sai_get_object_count) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_object_count(0,SAI_OBJECT_TYPE_NULL,0)); -} - -TEST(libsairedis, sai_get_object_key) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_get_object_key(0,SAI_OBJECT_TYPE_NULL,0,0)); -} - -TEST(libsairedis, sai_query_stats_capability) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_query_stats_capability(0,SAI_OBJECT_TYPE_NULL,0)); -} - -TEST(libsairedis, 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(libsairedis, 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(libsairedis, 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/lib/test_sai_redis_ipmc.cpp b/unittest/lib/test_sai_redis_ipmc.cpp deleted file mode 100644 index 1587a0381..000000000 --- a/unittest/lib/test_sai_redis_ipmc.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_ipmc_group.cpp b/unittest/lib/test_sai_redis_ipmc_group.cpp deleted file mode 100644 index 9d18702e3..000000000 --- a/unittest/lib/test_sai_redis_ipmc_group.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_isolation_group.cpp b/unittest/lib/test_sai_redis_isolation_group.cpp deleted file mode 100644 index da2e6b72f..000000000 --- a/unittest/lib/test_sai_redis_isolation_group.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_l2mc.cpp b/unittest/lib/test_sai_redis_l2mc.cpp deleted file mode 100644 index 532869c4e..000000000 --- a/unittest/lib/test_sai_redis_l2mc.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_l2mcgroup.cpp b/unittest/lib/test_sai_redis_l2mcgroup.cpp deleted file mode 100644 index 8ebc28014..000000000 --- a/unittest/lib/test_sai_redis_l2mcgroup.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_lag.cpp b/unittest/lib/test_sai_redis_lag.cpp deleted file mode 100644 index b8f316ab8..000000000 --- a/unittest/lib/test_sai_redis_lag.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_macsec.cpp b/unittest/lib/test_sai_redis_macsec.cpp deleted file mode 100644 index ca80607d9..000000000 --- a/unittest/lib/test_sai_redis_macsec.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_mcastfdb.cpp b/unittest/lib/test_sai_redis_mcastfdb.cpp deleted file mode 100644 index fd03a340e..000000000 --- a/unittest/lib/test_sai_redis_mcastfdb.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_mirror.cpp b/unittest/lib/test_sai_redis_mirror.cpp deleted file mode 100644 index c474736c1..000000000 --- a/unittest/lib/test_sai_redis_mirror.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_mpls.cpp b/unittest/lib/test_sai_redis_mpls.cpp deleted file mode 100644 index 626972a7b..000000000 --- a/unittest/lib/test_sai_redis_mpls.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_nat.cpp b/unittest/lib/test_sai_redis_nat.cpp deleted file mode 100644 index 8acafc988..000000000 --- a/unittest/lib/test_sai_redis_nat.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_neighbor.cpp b/unittest/lib/test_sai_redis_neighbor.cpp deleted file mode 100644 index 2322873de..000000000 --- a/unittest/lib/test_sai_redis_neighbor.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_nexthop.cpp b/unittest/lib/test_sai_redis_nexthop.cpp deleted file mode 100644 index dbcd8d2b1..000000000 --- a/unittest/lib/test_sai_redis_nexthop.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_nexthopgroup.cpp b/unittest/lib/test_sai_redis_nexthopgroup.cpp deleted file mode 100644 index d8eea4595..000000000 --- a/unittest/lib/test_sai_redis_nexthopgroup.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_policer.cpp b/unittest/lib/test_sai_redis_policer.cpp deleted file mode 100644 index bb8924e47..000000000 --- a/unittest/lib/test_sai_redis_policer.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_port.cpp b/unittest/lib/test_sai_redis_port.cpp deleted file mode 100644 index 8e920f963..000000000 --- a/unittest/lib/test_sai_redis_port.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_qosmap.cpp b/unittest/lib/test_sai_redis_qosmap.cpp deleted file mode 100644 index c7b980f29..000000000 --- a/unittest/lib/test_sai_redis_qosmap.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_queue.cpp b/unittest/lib/test_sai_redis_queue.cpp deleted file mode 100644 index b4548c3ab..000000000 --- a/unittest/lib/test_sai_redis_queue.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_route.cpp b/unittest/lib/test_sai_redis_route.cpp deleted file mode 100644 index 9d03cf9a9..000000000 --- a/unittest/lib/test_sai_redis_route.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_router_interface.cpp b/unittest/lib/test_sai_redis_router_interface.cpp deleted file mode 100644 index 34a363720..000000000 --- a/unittest/lib/test_sai_redis_router_interface.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_router_rpfgroup.cpp b/unittest/lib/test_sai_redis_router_rpfgroup.cpp deleted file mode 100644 index c92424862..000000000 --- a/unittest/lib/test_sai_redis_router_rpfgroup.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_router_samplepacket.cpp b/unittest/lib/test_sai_redis_router_samplepacket.cpp deleted file mode 100644 index 60f23e210..000000000 --- a/unittest/lib/test_sai_redis_router_samplepacket.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_scheduler.cpp b/unittest/lib/test_sai_redis_scheduler.cpp deleted file mode 100644 index 56849186a..000000000 --- a/unittest/lib/test_sai_redis_scheduler.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_schedulergroup.cpp b/unittest/lib/test_sai_redis_schedulergroup.cpp deleted file mode 100644 index 4d56a3eae..000000000 --- a/unittest/lib/test_sai_redis_schedulergroup.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_srv6.cpp b/unittest/lib/test_sai_redis_srv6.cpp deleted file mode 100644 index d9c03e99d..000000000 --- a/unittest/lib/test_sai_redis_srv6.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_stp.cpp b/unittest/lib/test_sai_redis_stp.cpp deleted file mode 100644 index 0cf4e1ced..000000000 --- a/unittest/lib/test_sai_redis_stp.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_switch.cpp b/unittest/lib/test_sai_redis_switch.cpp deleted file mode 100644 index c6c97693c..000000000 --- a/unittest/lib/test_sai_redis_switch.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_system_port.cpp b/unittest/lib/test_sai_redis_system_port.cpp deleted file mode 100644 index ee2c5d9f3..000000000 --- a/unittest/lib/test_sai_redis_system_port.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_tam.cpp b/unittest/lib/test_sai_redis_tam.cpp deleted file mode 100644 index 8a8b974bb..000000000 --- a/unittest/lib/test_sai_redis_tam.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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)); -} - -TEST(libsairedis, 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/lib/test_sai_redis_tunnel.cpp b/unittest/lib/test_sai_redis_tunnel.cpp deleted file mode 100644 index 1eb42b0b8..000000000 --- a/unittest/lib/test_sai_redis_tunnel.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_udf.cpp b/unittest/lib/test_sai_redis_udf.cpp deleted file mode 100644 index c233859dc..000000000 --- a/unittest/lib/test_sai_redis_udf.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_virtual_router.cpp b/unittest/lib/test_sai_redis_virtual_router.cpp deleted file mode 100644 index 0128d532c..000000000 --- a/unittest/lib/test_sai_redis_virtual_router.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_vlan.cpp b/unittest/lib/test_sai_redis_vlan.cpp deleted file mode 100644 index e0a0faac6..000000000 --- a/unittest/lib/test_sai_redis_vlan.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/lib/test_sai_redis_wred.cpp b/unittest/lib/test_sai_redis_wred.cpp deleted file mode 100644 index dfeffcd22..000000000 --- a/unittest/lib/test_sai_redis_wred.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsairedis, 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/meta/Makefile.am b/unittest/meta/Makefile.am index 3b51294d3..f88d6ea1f 100644 --- a/unittest/meta/Makefile.am +++ b/unittest/meta/Makefile.am @@ -15,6 +15,7 @@ tests_SOURCES = \ ../../lib/Channel.cpp \ MockMeta.cpp \ TestAttrKeyMap.cpp \ + TestDummySaiInterface.cpp \ TestGlobals.cpp \ TestMetaKeyHasher.cpp \ TestNotificationFactory.cpp \ @@ -23,6 +24,7 @@ tests_SOURCES = \ TestNotificationPortStateChange.cpp \ TestNotificationQueuePfcDeadlock.cpp \ TestNotificationSwitchShutdownRequest.cpp \ + TestNotificationSwitchAsicSdkHealthEvent.cpp \ TestNotificationSwitchStateChange.cpp \ TestNotificationBfdSessionStateChange.cpp \ TestOidRefCounter.cpp \ diff --git a/unittest/meta/TestDummySaiInterface.cpp b/unittest/meta/TestDummySaiInterface.cpp new file mode 100644 index 000000000..c85294d57 --- /dev/null +++ b/unittest/meta/TestDummySaiInterface.cpp @@ -0,0 +1,53 @@ +#include "DummySaiInterface.h" + +#include + +#include + +using namespace saimeta; + +TEST(DummySaiInterface, queryApiVersion) +{ + DummySaiInterface sai; + + sai.apiInitialize(0,0); + + sai_api_version_t version; + + EXPECT_EQ(sai.queryApiVersion(NULL), SAI_STATUS_SUCCESS); + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); +} + +TEST(DummySaiInterface, bulkGet) +{ + DummySaiInterface sai; + + sai.apiInitialize(0,0); + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + +TEST(DummySaiInterface, create) +{ + DummySaiInterface sai; + + sai.apiInitialize(0,0); + + sai_object_id_t oid; + sai.create(SAI_OBJECT_TYPE_SWITCH,&oid, 0, 0, 0); + + EXPECT_NE(oid, SAI_NULL_OBJECT_ID); +} diff --git a/unittest/meta/TestMeta.cpp b/unittest/meta/TestMeta.cpp index 63427e6c2..2aae01635 100644 --- a/unittest/meta/TestMeta.cpp +++ b/unittest/meta/TestMeta.cpp @@ -450,14 +450,14 @@ TEST(Meta, initialize) { Meta m(std::make_shared()); - EXPECT_EQ(SAI_STATUS_SUCCESS, m.initialize(0, 0)); + EXPECT_EQ(SAI_STATUS_SUCCESS, m.apiInitialize(0, 0)); } TEST(Meta, uninitialize) { Meta m(std::make_shared()); - EXPECT_EQ(SAI_STATUS_SUCCESS, m.uninitialize()); + EXPECT_EQ(SAI_STATUS_SUCCESS, m.apiUninitialize()); } TEST(Meta, quad_mcast_fdb_entry) @@ -898,7 +898,7 @@ TEST(Meta, queryAttributeCapability) EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAttributeCapability(switchId, SAI_OBJECT_TYPE_ACL_ENTRY, 100000, &cap)); } -TEST(Meta, queryAattributeEnumValuesCapability) +TEST(Meta, queryAttributeEnumValuesCapability) { Meta m(std::make_shared()); @@ -921,21 +921,21 @@ TEST(Meta, queryAattributeEnumValuesCapability) vals[0] = 0; vals[1] = 100000; - EXPECT_EQ(SAI_STATUS_SUCCESS, m.queryAattributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_SWITCHING_MODE, &list)); + EXPECT_EQ(SAI_STATUS_SUCCESS, m.queryAttributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_SWITCHING_MODE, &list)); // set count without list; list.list = nullptr; - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAattributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_SWITCHING_MODE, &list)); + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAttributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_SWITCHING_MODE, &list)); // non enum attribute - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAattributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_BCAST_CPU_FLOOD_ENABLE, &list)); + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAttributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_BCAST_CPU_FLOOD_ENABLE, &list)); // invalid attribute - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAattributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, 10000, &list)); + EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, m.queryAttributeEnumValuesCapability(switchId, SAI_OBJECT_TYPE_SWITCH, 10000, &list)); } TEST(Meta, meta_validate_stats) @@ -1803,3 +1803,23 @@ TEST(Meta, quad_ars_profile) EXPECT_EQ(SAI_STATUS_SUCCESS, m.remove(SAI_OBJECT_TYPE_ARS_PROFILE, ars_profile)); } + +TEST(Meta, bulkGet) +{ + Meta sai(std::make_shared()); + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} diff --git a/unittest/meta/TestMetaDash.cpp b/unittest/meta/TestMetaDash.cpp index 5fec7d475..b7b4234d1 100644 --- a/unittest/meta/TestMetaDash.cpp +++ b/unittest/meta/TestMetaDash.cpp @@ -529,7 +529,7 @@ TEST(Meta, quad_dash_vip) EXPECT_EQ(SAI_STATUS_SUCCESS, m.get(&vip, (uint32_t)attrs.size(), attrs.data())); EXPECT_EQ(attrs[0].value.s32, SAI_VIP_ENTRY_ACTION_ACCEPT); - attr.id = SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID; + attr.id = SAI_VIP_ENTRY_ATTR_ACTION; attr.value.s32 = SAI_VIP_ENTRY_ACTION_ACCEPT; EXPECT_EQ(SAI_STATUS_SUCCESS, m.set(&vip, &attr)); diff --git a/unittest/meta/TestNotificationFactory.cpp b/unittest/meta/TestNotificationFactory.cpp index 66d5938b5..f8f9541e8 100644 --- a/unittest/meta/TestNotificationFactory.cpp +++ b/unittest/meta/TestNotificationFactory.cpp @@ -68,6 +68,25 @@ TEST(NotificationFactory, deserialize_queue_pfc_deadlock) EXPECT_EQ(str, ntf->getSerializedNotification()); } +TEST(NotificationFactory, deserialize_switch_asic_sdk_health_event) +{ + auto ntf = NotificationFactory::deserialize( + SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT, + "{" + "\"category\":\"SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_FW\"," + "\"data.data_type\":\"SAI_HEALTH_DATA_TYPE_GENERAL\"," + "\"description\":\"2:30,30\"," + "\"severity\":\"SAI_SWITCH_ASIC_SDK_HEALTH_SEVERITY_FATAL\"," + "\"switch_id\":\"oid:0x21000000000000\"," + "\"timestamp\":\"{" + "\\\"tv_nsec\\\":\\\"28715881\\\"," + "\\\"tv_sec\\\":\\\"1700042919\\\"" + "}\"" + "}"); + + EXPECT_EQ(ntf->getNotificationType(), SAI_SWITCH_NOTIFICATION_TYPE_SWITCH_ASIC_SDK_HEALTH_EVENT); +} + TEST(NotificationFactory, deserialize_shutdown_request) { auto ntf = NotificationFactory::deserialize( diff --git a/unittest/meta/TestNotificationSwitchAsicSdkHealthEvent.cpp b/unittest/meta/TestNotificationSwitchAsicSdkHealthEvent.cpp new file mode 100644 index 000000000..3f62ef8b8 --- /dev/null +++ b/unittest/meta/TestNotificationSwitchAsicSdkHealthEvent.cpp @@ -0,0 +1,78 @@ +#include "NotificationSwitchAsicSdkHealthEvent.h" +#include "Meta.h" +#include "MetaTestSaiInterface.h" + +#include "sairediscommon.h" +#include "sai_serialize.h" + +#include +#include + +using namespace sairedis; +using namespace saimeta; + +//static std::string s = "[{\"host_tx_ready_status\":\"SAI_PORT_HOST_TX_READY_STATUS_READY\",\"port_id\":\"oid:0x100000000001a\",\"switch_id\":\"oid:0x2100000000\"}]"; +static std::string s = "{" + "\"category\":\"SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_FW\"," + "\"data.data_type\":\"SAI_HEALTH_DATA_TYPE_GENERAL\"," + "\"description\":\"2:30,30\"," + "\"severity\":\"SAI_SWITCH_ASIC_SDK_HEALTH_SEVERITY_FATAL\"," + "\"switch_id\":\"oid:0x21000000000000\"," + "\"timestamp\":\"{" + "\\\"tv_nsec\\\":\\\"28715881\\\"," + "\\\"tv_sec\\\":\\\"1700042919\\\"" + "}\"" + "}"; +static std::string null = "[{\"host_tx_ready_status\":\"SAI_PORT_HOST_TX_READY_STATUS_READY\",\"port_id\":\"oid:0x0\",\"switch_id\":\"oid:0x0\"}]"; +static std::string fullnull = "[]"; + +TEST(NotificationSwitchAsicSdkHealthEvent, ctr) +{ + NotificationSwitchAsicSdkHealthEvent n(s); +} + +TEST(NotificationSwitchAsicSdkHealthEvent, getSwitchId) +{ + NotificationSwitchAsicSdkHealthEvent n(s); + + EXPECT_EQ(n.getSwitchId(), 0x21000000000000); +} + +TEST(NotificationSwitchAsicSdkHealthEvent, getAnyObjectId) +{ + NotificationSwitchAsicSdkHealthEvent n(s); + + EXPECT_EQ(n.getAnyObjectId(), 0x21000000000000); +} + +TEST(NotificationSwitchAsicSdkHealthEvent, processMetadata) +{ + NotificationSwitchAsicSdkHealthEvent n(s); + + auto sai = std::make_shared(); + auto meta = std::make_shared(sai); + + n.processMetadata(meta); +} + +static void on_switch_asic_sdk_health_event( + _In_ sai_object_id_t switch_id, + _In_ sai_switch_asic_sdk_health_severity_t severity, + _In_ sai_timespec_t timestamp, + _In_ sai_switch_asic_sdk_health_category_t category, + _In_ sai_switch_health_data_t data, + _In_ const sai_u8_list_t description) +{ + SWSS_LOG_ENTER(); +} + +TEST(NotificationSwitchAsicSdkHealthEvent, executeCallback) +{ + NotificationSwitchAsicSdkHealthEvent n(s); + + sai_switch_notifications_t ntfs; + + ntfs.on_switch_asic_sdk_health_event = &on_switch_asic_sdk_health_event; + + n.executeCallback(ntfs); +} diff --git a/unittest/proxylib/Makefile.am b/unittest/proxylib/Makefile.am new file mode 100644 index 000000000..a7c5d8ac6 --- /dev/null +++ b/unittest/proxylib/Makefile.am @@ -0,0 +1,21 @@ +AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/proxylib -I$(top_srcdir)/lib + +bin_PROGRAMS = tests + +LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main + +tests_SOURCES = \ + ../../meta/DummySaiInterface.cpp \ + main.cpp \ + TestProxy.cpp \ + TestSai.cpp + +tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) +tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/proxylib/libSaiProxy.a \ + $(top_srcdir)/lib/libSaiRedis.a \ + $(top_srcdir)/syncd/libSyncd.a \ + -lhiredis -lswsscommon -lpthread \ + -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta \ + -lzmq $(CODE_COVERAGE_LIBS) + +TESTS = tests diff --git a/unittest/proxylib/TestProxy.cpp b/unittest/proxylib/TestProxy.cpp new file mode 100644 index 000000000..00060593b --- /dev/null +++ b/unittest/proxylib/TestProxy.cpp @@ -0,0 +1,25 @@ +#include + +#include +#include +#include + +#include + +#include "meta/DummySaiInterface.h" + +#include "Sai.h" +#include "Proxy.h" + +using namespace saiproxy; + +TEST(Proxy, ctr) +{ + Sai sai; + + std::shared_ptr dummy = std::make_shared(); + + // will test loadProfileMap + + auto proxy = std::make_shared(dummy); +} diff --git a/unittest/proxylib/TestSai.cpp b/unittest/proxylib/TestSai.cpp new file mode 100644 index 000000000..933cf2402 --- /dev/null +++ b/unittest/proxylib/TestSai.cpp @@ -0,0 +1,602 @@ +#include + +#include +#include +#include + +#include + +#include "meta/DummySaiInterface.h" + +#include "Sai.h" +#include "Proxy.h" + +// TODO fix join when tests will fail + +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 +}; + +static const char* profile_get_value( + _In_ sai_switch_profile_id_t profile_id, + _In_ const char* variable) +{ + SWSS_LOG_ENTER(); + + if (variable == NULL) + return NULL; + + return nullptr; +} + +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(); + + return 0; +} + +static sai_service_method_table_t test_services = { + profile_get_value, + profile_get_next_value +}; + +TEST_F(SaiTest, Ctr) +{ + auto s = std::make_shared(); +} + +TEST(Sai, bulkGet) +{ + Sai sai; + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + +TEST(Sai, apiInitialize) +{ + Sai sai; + + // non zero flags + EXPECT_EQ(sai.apiInitialize(1, &test_services), SAI_STATUS_INVALID_PARAMETER); + + // table null + EXPECT_EQ(sai.apiInitialize(0, NULL), SAI_STATUS_INVALID_PARAMETER); + + // correct one + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + // second initialize + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_FAILURE); +} + +TEST(Sai, apiUninitialize) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + EXPECT_EQ(sai.apiUninitialize(), SAI_STATUS_SUCCESS); +} + +static void fun(std::shared_ptr proxy) +{ + SWSS_LOG_ENTER(); + + proxy->run(); +} + +TEST(Sai, create) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_object_id_t switch_id = SAI_NULL_OBJECT_ID; + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + attr.value.booldata = true; + + // create oid + auto status = sai.create( + SAI_OBJECT_TYPE_SWITCH, + &switch_id, + SAI_NULL_OBJECT_ID, // creating switch + 1, + &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + EXPECT_NE(switch_id, SAI_NULL_OBJECT_ID); + + sai_fdb_entry_t fdb = {}; + + attr.id = SAI_FDB_ENTRY_ATTR_META_DATA; + attr.value.u32 = 0; + + // create entry + status = sai.create(&fdb, 1, &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, remove) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + // remove oid + auto status = sai.remove( + SAI_OBJECT_TYPE_SWITCH, + (sai_object_id_t)1); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + sai_fdb_entry_t fdb = {}; + + // remove entry + status = sai.remove(&fdb); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, set) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + attr.value.booldata = true; + + // set oid + auto status = sai.set( + SAI_OBJECT_TYPE_SWITCH, + (sai_object_id_t)1, + &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + sai_fdb_entry_t fdb = {}; + + attr.id = SAI_FDB_ENTRY_ATTR_META_DATA; + attr.value.u32 = 0; + + // set entry + status = sai.set(&fdb, &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, get) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_INIT_SWITCH; + + // get oid + auto status = sai.get( + SAI_OBJECT_TYPE_SWITCH, + (sai_object_id_t)1, + 1, + &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + sai_fdb_entry_t fdb = {}; + + attr.id = SAI_FDB_ENTRY_ATTR_META_DATA; + + // get entry + status = sai.get(&fdb, 1, &attr); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, flushFdbEntries) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + auto status = sai.flushFdbEntries((sai_object_id_t)1, 0, 0); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + + +TEST(Sai, processObjectTypeGetAvailability) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + uint64_t count; + + auto status = sai.objectTypeGetAvailability( + (sai_object_id_t)1, + SAI_OBJECT_TYPE_SWITCH, + 0, + 0, + &count); + + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, processQueryAttributeCapability) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_attr_capability_t cap; + + auto status = sai.queryAttributeCapability( + (sai_object_id_t)1, + SAI_OBJECT_TYPE_SWITCH, + SAI_SWITCH_ATTR_INIT_SWITCH, + &cap); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, queryAttributeEnumValuesCapability) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_s32_list_t list; + + int32_t arr[10]; + + list.count = 10; + list.list = arr; + + auto status = sai.queryAttributeEnumValuesCapability( + (sai_object_id_t)1, + SAI_OBJECT_TYPE_SWITCH, + SAI_SWITCH_ATTR_INIT_SWITCH, + &list); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, objectTypeQuery) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + auto objectType = sai.objectTypeQuery(SAI_NULL_OBJECT_ID); + + EXPECT_EQ(objectType, SAI_OBJECT_TYPE_NULL); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, switchIdQuery) +{ + Sai sai; + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + auto objectId = sai.switchIdQuery(SAI_NULL_OBJECT_ID); + + EXPECT_EQ(objectId, SAI_NULL_OBJECT_ID); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, queryApiVersion) +{ + Sai sai; + + sai_api_version_t version; + + // api not initialized + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_FAILURE); + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + EXPECT_EQ(sai.queryApiVersion(NULL), SAI_STATUS_INVALID_PARAMETER); + + auto status = sai.queryApiVersion(&version); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + EXPECT_EQ(version, SAI_API_VERSION); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, logSet) +{ + Sai sai; + + sai_api_version_t version; + + // api not initialized + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_FAILURE); + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + auto status = sai.logSet(SAI_API_SWITCH, SAI_LOG_LEVEL_NOTICE); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, getStats) +{ + Sai sai; + + sai_api_version_t version; + + // api not initialized + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_FAILURE); + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_stat_id_t counter_ids[2] = { SAI_PORT_STAT_IF_IN_OCTETS, SAI_PORT_STAT_IF_IN_UCAST_PKTS }; + + uint64_t counters[2]; + + auto status = sai.getStats( + SAI_OBJECT_TYPE_PORT, + (sai_object_id_t)1, + 2, + counter_ids, + counters); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, getStatsExt) +{ + Sai sai; + + sai_api_version_t version; + + // api not initialized + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_FAILURE); + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_stat_id_t counter_ids[2] = { SAI_PORT_STAT_IF_IN_OCTETS, SAI_PORT_STAT_IF_IN_UCAST_PKTS }; + + uint64_t counters[2]; + + auto status = sai.getStatsExt( + SAI_OBJECT_TYPE_PORT, + (sai_object_id_t)1, + 2, + counter_ids, + SAI_STATS_MODE_READ, + counters); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + +TEST(Sai, clearStats) +{ + Sai sai; + + sai_api_version_t version; + + // api not initialized + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_FAILURE); + + EXPECT_EQ(sai.apiInitialize(0, &test_services), SAI_STATUS_SUCCESS); + + std::shared_ptr dummy = std::make_shared(); + + auto proxy = std::make_shared(dummy); + + auto thread = std::make_shared(fun,proxy); + + sai_stat_id_t counter_ids[2] = { SAI_PORT_STAT_IF_IN_OCTETS, SAI_PORT_STAT_IF_IN_UCAST_PKTS }; + + auto status = sai.clearStats( + SAI_OBJECT_TYPE_PORT, + (sai_object_id_t)1, + 2, + counter_ids); + + EXPECT_EQ(status, SAI_STATUS_SUCCESS); + + proxy->stop(); + + thread->join(); +} + diff --git a/unittest/proxylib/config.ini b/unittest/proxylib/config.ini new file mode 100644 index 000000000..da5334b45 --- /dev/null +++ b/unittest/proxylib/config.ini @@ -0,0 +1,8 @@ +# test proxu config comment +; comment + +invalid line + +VARIABLE=VALUE +FOO=bar +BAR=baz 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/syncd/Makefile.am b/unittest/syncd/Makefile.am index 27c301e25..4c75d3672 100644 --- a/unittest/syncd/Makefile.am +++ b/unittest/syncd/Makefile.am @@ -17,6 +17,7 @@ tests_SOURCES = main.cpp \ TestNotificationHandler.cpp \ TestMdioIpcServer.cpp \ TestPortStateChangeHandler.cpp \ + TestWorkaround.cpp \ TestVendorSai.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) diff --git a/unittest/syncd/MockableSaiInterface.cpp b/unittest/syncd/MockableSaiInterface.cpp index 79dac43b1..df2fdc302 100644 --- a/unittest/syncd/MockableSaiInterface.cpp +++ b/unittest/syncd/MockableSaiInterface.cpp @@ -11,7 +11,7 @@ MockableSaiInterface::~MockableSaiInterface() SWSS_LOG_ENTER(); } -sai_status_t MockableSaiInterface::initialize( +sai_status_t MockableSaiInterface::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -19,7 +19,7 @@ sai_status_t MockableSaiInterface::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t MockableSaiInterface::uninitialize() +sai_status_t MockableSaiInterface::apiUninitialize() { SWSS_LOG_ENTER(); return SAI_STATUS_SUCCESS; @@ -137,6 +137,22 @@ sai_status_t MockableSaiInterface::bulkSet( return SAI_STATUS_SUCCESS; } +sai_status_t MockableSaiInterface::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t MockableSaiInterface::getStats( _In_ sai_object_type_t object_type, _In_ sai_object_id_t object_id, @@ -347,16 +363,16 @@ sai_status_t MockableSaiInterface::queryAttributeCapability( return SAI_STATUS_SUCCESS; } -sai_status_t MockableSaiInterface::queryAattributeEnumValuesCapability( +sai_status_t MockableSaiInterface::queryAttributeEnumValuesCapability( _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(); - if (mock_queryAattributeEnumValuesCapability) + if (mock_queryAttributeEnumValuesCapability) { - return mock_queryAattributeEnumValuesCapability(switch_id, object_type, attr_id, enum_values_capability); + return mock_queryAttributeEnumValuesCapability(switch_id, object_type, attr_id, enum_values_capability); } return SAI_STATUS_SUCCESS; diff --git a/unittest/syncd/MockableSaiInterface.h b/unittest/syncd/MockableSaiInterface.h index c01b51206..f6ab10def 100644 --- a/unittest/syncd/MockableSaiInterface.h +++ b/unittest/syncd/MockableSaiInterface.h @@ -14,10 +14,10 @@ class MockableSaiInterface: public saimeta::DummySaiInterface public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - virtual sai_status_t uninitialize(void) override; + virtual sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -82,8 +82,18 @@ class MockableSaiInterface: public saimeta::DummySaiInterface _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + std::function mock_bulkSet; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -211,13 +221,13 @@ class MockableSaiInterface: public saimeta::DummySaiInterface std::function mock_queryAttributeCapability; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _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; - std::function mock_queryAattributeEnumValuesCapability; + std::function mock_queryAttributeEnumValuesCapability; virtual sai_object_type_t objectTypeQuery( _In_ sai_object_id_t objectId) override; diff --git a/unittest/syncd/TestNotificationHandler.cpp b/unittest/syncd/TestNotificationHandler.cpp index 9891dfebf..59566676c 100644 --- a/unittest/syncd/TestNotificationHandler.cpp +++ b/unittest/syncd/TestNotificationHandler.cpp @@ -9,6 +9,20 @@ using namespace syncd; static std::string natData = "[{\"nat_entry\":\"{\\\"nat_data\\\":{\\\"key\\\":{\\\"dst_ip\\\":\\\"10.10.10.10\\\",\\\"l4_dst_port\\\":\\\"20006\\\",\\\"l4_src_port\\\":\\\"0\\\",\\\"proto\\\":\\\"6\\\",\\\"src_ip\\\":\\\"0.0.0.0\\\"},\\\"mask\\\":{\\\"dst_ip\\\":\\\"255.255.255.255\\\",\\\"l4_dst_port\\\":\\\"65535\\\",\\\"l4_src_port\\\":\\\"0\\\",\\\"proto\\\":\\\"255\\\",\\\"src_ip\\\":\\\"0.0.0.0\\\"}},\\\"nat_type\\\":\\\"SAI_NAT_TYPE_DESTINATION_NAT\\\",\\\"switch_id\\\":\\\"oid:0x21000000000000\\\",\\\"vr\\\":\\\"oid:0x3000000000048\\\"}\",\"nat_event\":\"SAI_NAT_EVENT_AGED\"}]"; +// Test ASIC/SDK health event +std::string asheData = "{" + "\"category\":\"SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_FW\"," + "\"data.data_type\":\"SAI_HEALTH_DATA_TYPE_GENERAL\"," + "\"description\":\"2:30,30\"," + "\"severity\":\"SAI_SWITCH_ASIC_SDK_HEALTH_SEVERITY_FATAL\"," + "\"switch_id\":\"oid:0x21000000000000\"," + "\"timestamp\":\"{" + "\\\"tv_nsec\\\":\\\"28715881\\\"," + "\\\"tv_sec\\\":\\\"1700042919\\\"" + "}\"" +"}"; + + TEST(NotificationHandler, NotificationHandlerTest) { std::vector attrs; @@ -29,4 +43,27 @@ TEST(NotificationHandler, NotificationHandlerTest) sai_deserialize_nat_event_ntf(natData, count, &natevent); notificationHandler->onNatEvent(count, natevent); + + sai_object_id_t switch_id; + sai_switch_asic_sdk_health_severity_t severity; + sai_timespec_t timestamp; + sai_switch_asic_sdk_health_category_t category; + sai_switch_health_data_t data; + sai_u8_list_t description; + sai_deserialize_switch_asic_sdk_health_event(asheData, + switch_id, + severity, + timestamp, + category, + data, + description); + assert(switch_id == 0x21000000000000); + assert(severity == SAI_SWITCH_ASIC_SDK_HEALTH_SEVERITY_FATAL); + assert(category == SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_FW); + notificationHandler->onSwitchAsicSdkHealthEvent(switch_id, + severity, + timestamp, + category, + data, + description); } diff --git a/unittest/syncd/TestNotificationProcessor.cpp b/unittest/syncd/TestNotificationProcessor.cpp index 0c955d7cc..d683f105d 100644 --- a/unittest/syncd/TestNotificationProcessor.cpp +++ b/unittest/syncd/TestNotificationProcessor.cpp @@ -73,4 +73,22 @@ TEST(NotificationProcessor, NotificationProcessorTest) EXPECT_NE(bridgeport, nullptr); EXPECT_EQ(*bridgeport, "oid:0x3a000000000a99"); EXPECT_EQ(ip, nullptr); + + // Test ASIC/SDK health event + std::string asheString = "{" + "\"category\":\"SAI_SWITCH_ASIC_SDK_HEALTH_CATEGORY_FW\"," + "\"data.data_type\":\"SAI_HEALTH_DATA_TYPE_GENERAL\"," + "\"description\":\"2:30,30\"," + "\"severity\":\"SAI_SWITCH_ASIC_SDK_HEALTH_SEVERITY_FATAL\"," + "\"switch_id\":\"oid:0x21000000000000\"," + "\"timestamp\":\"{" + "\\\"tv_nsec\\\":\\\"28715881\\\"," + "\\\"tv_sec\\\":\\\"1700042919\\\"" + "}\"" + "}"; + std::vector asheEntry; + swss::KeyOpFieldsValuesTuple asheItem(SAI_SWITCH_NOTIFICATION_NAME_SWITCH_ASIC_SDK_HEALTH_EVENT, asheString, asheEntry); + translator->insertRidAndVid(0x21000000000000,0x210000000000); + notificationProcessor->syncProcessNotification(asheItem); + translator->eraseRidAndVid(0x21000000000000,0x210000000000); } diff --git a/unittest/syncd/TestVendorSai.cpp b/unittest/syncd/TestVendorSai.cpp index f3efbc75d..10a0c1356 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -54,7 +54,7 @@ class VendorSaiTest : public ::testing::Test { m_vsai = std::make_shared(); - auto status = m_vsai->initialize(0, &test_services); + auto status = m_vsai->apiInitialize(0, &test_services); ASSERT_EQ(status, SAI_STATUS_SUCCESS); sai_attribute_t attr; @@ -70,7 +70,7 @@ class VendorSaiTest : public ::testing::Test auto status = m_vsai->remove(SAI_OBJECT_TYPE_SWITCH, m_swid); ASSERT_EQ(status, SAI_STATUS_SUCCESS); - status = m_vsai->uninitialize(); + status = m_vsai->apiUninitialize(); ASSERT_EQ(status, SAI_STATUS_SUCCESS); } @@ -136,7 +136,7 @@ TEST_F(VendorSaiTest, portBulkAddRemove) TEST(VendorSai, bulkGetStats) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); ASSERT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.bulkGetStats(SAI_NULL_OBJECT_ID, SAI_OBJECT_TYPE_PORT, 0, @@ -211,7 +211,7 @@ sai_object_id_t create_rif( TEST(VendorSai, quad_bulk_neighbor_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchId = 0; @@ -380,7 +380,7 @@ static void remove_eni(VendorSai &sai, sai_object_id_t eni) TEST(VendorSai, quad_dash_direction_lookup) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -405,7 +405,7 @@ TEST(VendorSai, quad_dash_direction_lookup) TEST(VendorSai, bulk_dash_direction_lookup) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -447,7 +447,7 @@ TEST(VendorSai, bulk_dash_direction_lookup) TEST(VendorSai, quad_dash_eni) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -501,7 +501,7 @@ TEST(VendorSai, quad_dash_eni) TEST(VendorSai, bulk_dash_eni) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -562,7 +562,7 @@ TEST(VendorSai, bulk_dash_eni) TEST(VendorSai, quad_dash_eni_acl) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -615,7 +615,7 @@ TEST(VendorSai, quad_dash_eni_acl) TEST(VendorSai, quad_dash_vip) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -642,7 +642,7 @@ TEST(VendorSai, quad_dash_vip) TEST(VendorSai, bulk_dash_vip) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -690,7 +690,7 @@ TEST(VendorSai, bulk_dash_vip) TEST(VendorSai, quad_dash_acl_group) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -711,7 +711,7 @@ TEST(VendorSai, quad_dash_acl_group) TEST(VendorSai, bulk_dash_acl_group) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -749,7 +749,7 @@ TEST(VendorSai, bulk_dash_acl_group) TEST(VendorSai, quad_dash_acl_rule) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -827,7 +827,7 @@ TEST(VendorSai, quad_dash_acl_rule) TEST(VendorSai, bulk_dash_acl_rule) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -924,7 +924,7 @@ TEST(VendorSai, bulk_dash_acl_rule) TEST(VendorSai, quad_dash_vnet) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -941,7 +941,7 @@ TEST(VendorSai, quad_dash_vnet) TEST(VendorSai, bulk_dash_vnet) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -979,7 +979,7 @@ TEST(VendorSai, bulk_dash_vnet) TEST(VendorSai, quad_dash_inbound_routing_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1015,7 +1015,7 @@ TEST(VendorSai, quad_dash_inbound_routing_entry) TEST(VendorSai, bulk_dash_inbound_routing_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1081,7 +1081,7 @@ TEST(VendorSai, bulk_dash_inbound_routing_entry) TEST(VendorSai, quad_dash_pa_validation) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1109,7 +1109,7 @@ TEST(VendorSai, quad_dash_pa_validation) TEST(VendorSai, bulk_dash_pa_validation) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1164,7 +1164,7 @@ TEST(VendorSai, bulk_dash_pa_validation) TEST(VendorSai, quad_dash_outbound_routing_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1210,7 +1210,7 @@ TEST(VendorSai, quad_dash_outbound_routing_entry) TEST(VendorSai, bulk_dash_outbound_routing_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1288,7 +1288,7 @@ TEST(VendorSai, bulk_dash_outbound_routing_entry) TEST(VendorSai, quad_dash_outbound_ca_to_pa_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1337,7 +1337,7 @@ TEST(VendorSai, quad_dash_outbound_ca_to_pa_entry) TEST(VendorSai, bulk_dash_outbound_ca_to_pa_entry) { VendorSai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); sai_object_id_t switchid = create_switch(sai); @@ -1405,3 +1405,24 @@ TEST(VendorSai, bulk_dash_outbound_ca_to_pa_entry) remove_counter(sai, counter0); remove_counter(sai, counter1); } + +TEST(VendorSie, bulkGet) +{ + VendorSai sai; + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/syncd/TestVirtualOidTranslator.cpp b/unittest/syncd/TestVirtualOidTranslator.cpp index 90ac58461..09d992a37 100644 --- a/unittest/syncd/TestVirtualOidTranslator.cpp +++ b/unittest/syncd/TestVirtualOidTranslator.cpp @@ -91,7 +91,7 @@ TEST(VirtualOidTranslator, tryTranslateVidToRid) sai_service_method_table_t test_services = smt.getServiceMethodTable(); - sai_status_t status = sai->initialize(0, &test_services); + sai_status_t status = sai->apiInitialize(0, &test_services); EXPECT_EQ(status, SAI_STATUS_SUCCESS); @@ -158,5 +158,5 @@ TEST(VirtualOidTranslator, tryTranslateVidToRid) EXPECT_FALSE(vot.tryTranslateVidToRid(mk)); - sai->uninitialize(); + sai->apiUninitialize(); } diff --git a/unittest/syncd/TestWorkaround.cpp b/unittest/syncd/TestWorkaround.cpp new file mode 100644 index 000000000..36dd822e6 --- /dev/null +++ b/unittest/syncd/TestWorkaround.cpp @@ -0,0 +1,21 @@ +#include + +#include +#include +#include + +#include +#include "Workaround.h" +#include "swss/logger.h" + +#include + +using namespace syncd; + +TEST(Workaround, isSetAttributeWorkaround) +{ + ASSERT_EQ(Workaround::isSetAttributeWorkaround(SAI_OBJECT_TYPE_HOSTIF, SAI_HOSTIF_ATTR_QUEUE, SAI_STATUS_FAILURE), true); + ASSERT_EQ(Workaround::isSetAttributeWorkaround(SAI_OBJECT_TYPE_SWITCH, SAI_SWITCH_ATTR_SRC_MAC_ADDRESS, SAI_STATUS_FAILURE), true); + ASSERT_EQ(Workaround::isSetAttributeWorkaround(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TYPE, SAI_STATUS_FAILURE), false); + ASSERT_EQ(Workaround::isSetAttributeWorkaround(SAI_OBJECT_TYPE_PORT, SAI_PORT_ATTR_TYPE, SAI_STATUS_SUCCESS), false); +} diff --git a/unittest/vslib/Makefile.am b/unittest/vslib/Makefile.am index af3983260..092bcf046 100644 --- a/unittest/vslib/Makefile.am +++ b/unittest/vslib/Makefile.am @@ -1,6 +1,6 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/meta -I$(top_srcdir)/vslib -I$(top_srcdir)/lib -I/usr/include/libnl3 -bin_PROGRAMS = tests testslibsaivs +bin_PROGRAMS = tests LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main @@ -45,73 +45,11 @@ tests_SOURCES = main.cpp \ TestSwitchStateBaseMACsec.cpp \ TestMACsecManager.cpp \ TestSwitchStateBase.cpp \ + TestSai.cpp \ TestVirtualSwitchSaiInterface.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -fno-access-control tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/vslib/libSaiVS.a -lhiredis -lswsscommon -lnl-genl-3 -lnl-nf-3 -lnl-route-3 -lnl-3 \ -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) -testslibsaivs_SOURCES = main_libsaivs.cpp \ - test_sai_vs_acl.cpp \ - test_sai_vs_bfd.cpp \ - test_sai_vs_bmtor.cpp \ - test_sai_vs_bridge.cpp \ - test_sai_vs_buffer.cpp \ - test_sai_vs_counter.cpp \ - test_sai_vs_dash_vip.cpp \ - test_sai_vs_dash_pa_validation.cpp \ - test_sai_vs_dash_vnet.cpp \ - test_sai_vs_dash_outbound_routing.cpp \ - test_sai_vs_dash_outbound_ca_to_pa.cpp \ - test_sai_vs_dash_inbound_routing.cpp \ - test_sai_vs_dash_eni.cpp \ - test_sai_vs_dash_direction_lookup.cpp \ - test_sai_vs_dash_acl.cpp \ - test_sai_vs_debug_counter.cpp \ - test_sai_vs_dtel.cpp \ - test_sai_vs_fdb.cpp \ - test_sai_vs_generic_programmable.cpp \ - test_sai_vs_ipmc.cpp \ - test_sai_vs_l2mc.cpp \ - test_sai_vs_l2mcgroup.cpp \ - test_sai_vs_lag.cpp \ - test_sai_vs_ipmc_group.cpp \ - test_sai_vs_macsec.cpp \ - test_sai_vs_isolation_group.cpp \ - test_sai_vs_interfacequery.cpp \ - test_sai_vs_mcastfdb.cpp \ - test_sai_vs_mirror.cpp \ - test_sai_vs_mpls.cpp \ - test_sai_vs_nat.cpp \ - test_sai_vs_hash.cpp \ - test_sai_vs_neighbor.cpp \ - test_sai_vs_nexthop.cpp \ - test_sai_vs_nexthopgroup.cpp \ - test_sai_vs_port.cpp \ - test_sai_vs_qosmap.cpp \ - test_sai_vs_policer.cpp \ - test_sai_vs_queue.cpp \ - test_sai_vs_route.cpp \ - test_sai_vs_router_interface.cpp \ - test_sai_vs_router_rpfgroup.cpp \ - test_sai_vs_router_samplepacket.cpp \ - test_sai_vs_schedulergroup.cpp \ - test_sai_vs_scheduler.cpp \ - test_sai_vs_srv6.cpp \ - test_sai_vs_switch.cpp \ - test_sai_vs_system_port.cpp \ - test_sai_vs_tam.cpp \ - test_sai_vs_tunnel.cpp \ - test_sai_vs_stp.cpp \ - test_sai_vs_udf.cpp \ - test_sai_vs_virtual_router.cpp \ - test_sai_vs_vlan.cpp \ - test_sai_vs_hostif.cpp \ - test_sai_vs_wred.cpp \ - test_sai_vs_ars.cpp \ - test_sai_vs_ars_profile.cpp - -testslibsaivs_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -testslibsaivs_LDADD = $(LDADD_GTEST) -L$(top_srcdir)/vslib/.libs -lsaivs -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) - -TESTS = testslibsaivs tests +TESTS = tests diff --git a/unittest/vslib/TestMACsecManager.cpp b/unittest/vslib/TestMACsecManager.cpp index bc1468b45..13135f145 100644 --- a/unittest/vslib/TestMACsecManager.cpp +++ b/unittest/vslib/TestMACsecManager.cpp @@ -30,6 +30,27 @@ TEST(MACsecManager, create_macsec_ingress_sa) manager.create_macsec_ingress_sa(attr); } +TEST(MACsecManager, create_macsec_egress_sa) +{ + // This is a system call that may not be valid in the test environment, + // So, this case is just for the testing coverage checking. + + MACsecManager manager; + + MACsecAttr attr; + attr.m_vethName = "eth0"; + attr.m_macsecName = "macsec_eth0"; + attr.m_sci = "02:42:ac:11:00:03"; + attr.m_an = 0; + attr.m_pn = 1; + attr.m_cipher = MACsecAttr::CIPHER_NAME_GCM_AES_XPN_128; + attr.m_ssci = 0x1; + attr.m_salt = ""; + attr.m_authKey = ""; + attr.m_sak = ""; + manager.create_macsec_egress_sa(attr); +} + TEST(MACsecManager, update_macsec_sa_pn) { // This is a system call that may not be valid in the test environment, diff --git a/unittest/vslib/TestSai.cpp b/unittest/vslib/TestSai.cpp new file mode 100644 index 000000000..c45663de8 --- /dev/null +++ b/unittest/vslib/TestSai.cpp @@ -0,0 +1,28 @@ +#include "Sai.h" + +#include + +#include + +using namespace saivs; + +TEST(Sai, bulkGet) +{ + Sai sai; + + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + sai.bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/vslib/TestSaiUnittests.cpp b/unittest/vslib/TestSaiUnittests.cpp index e59a1dac5..18fe5f647 100644 --- a/unittest/vslib/TestSaiUnittests.cpp +++ b/unittest/vslib/TestSaiUnittests.cpp @@ -43,7 +43,7 @@ TEST(SaiUnittests, ctr) { Sai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); std::vector values; @@ -101,7 +101,7 @@ TEST(SaiUnittests, handleUnittestChannelOp) // api not initialized vsntf.send("unknown op", "true", entry); - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); vsntf.send("unknown op", "true", entry); @@ -112,7 +112,7 @@ TEST(SaiUnittests, channelOpSetReadOnlyAttribute) { Sai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); std::vector values; @@ -154,7 +154,7 @@ TEST(SaiUnittests, channelOpSetStats) { Sai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); std::vector values; @@ -187,7 +187,7 @@ TEST(SaiUnittests, bulkGetClearStats) { Sai sai; - sai.initialize(0, &test_services); + sai.apiInitialize(0, &test_services); EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.bulkGetStats(SAI_NULL_OBJECT_ID, SAI_OBJECT_TYPE_PORT, diff --git a/unittest/vslib/TestSwitchStateBaseMACsec.cpp b/unittest/vslib/TestSwitchStateBaseMACsec.cpp index 5a55bc3d7..9ab4849ce 100644 --- a/unittest/vslib/TestSwitchStateBaseMACsec.cpp +++ b/unittest/vslib/TestSwitchStateBaseMACsec.cpp @@ -20,8 +20,11 @@ TEST(SwitchStateBase, loadMACsecAttrFromMACsecSA) sai_attribute_t attr; std::vector attrs; MACsecAttr macsecAttr; + sai_attribute_t attrList[6]; + sai_attribute_t attrListXpn[8]; attr.id = SAI_MACSEC_SC_ATTR_FLOW_ID; + attr.value.oid = 0; attrs.push_back(attr); attr.id = SAI_MACSEC_SC_ATTR_MACSEC_SCI; attrs.push_back(attr); @@ -41,11 +44,101 @@ TEST(SwitchStateBase, loadMACsecAttrFromMACsecSA) static_cast(attrs.size()), attrs.data())); - attr.id = SAI_MACSEC_SA_ATTR_SC_ID; + attr.id = SAI_MACSEC_SC_ATTR_FLOW_ID; attr.value.oid = 0; - ss.loadMACsecAttrFromMACsecSA(0, 1 , &attr, macsecAttr); + attrs.push_back(attr); + attr.id = SAI_MACSEC_SC_ATTR_MACSEC_SCI; + attrs.push_back(attr); + attr.id = SAI_MACSEC_SC_ATTR_ENCRYPTION_ENABLE; + attrs.push_back(attr); + attr.id = SAI_MACSEC_SC_ATTR_MACSEC_CIPHER_SUITE; + attr.value.s32 = sai_macsec_cipher_suite_t::SAI_MACSEC_CIPHER_SUITE_GCM_AES_XPN_256; + attrs.push_back(attr); + attr.id = SAI_MACSEC_SC_ATTR_MACSEC_EXPLICIT_SCI_ENABLE; + attrs.push_back(attr); + EXPECT_EQ( + SAI_STATUS_SUCCESS, + ss.create_internal( + SAI_OBJECT_TYPE_MACSEC_SC, + "oid:0x1", + 0, + static_cast(attrs.size()), + attrs.data())); + + ss.m_macsecFlowPortMap[0] = 0; + auto eq = std::make_shared(std::make_shared()); + int s = socket(AF_INET, SOCK_DGRAM, 0); + int fd = socket(AF_INET, SOCK_DGRAM, 0); + auto hii = std::make_shared(0, s, fd, "tap", 0, eq); + ss.m_hostif_info_map["tap"] = hii; + + memset(attrList, 0, sizeof(attrList)); + attrList[0].id = SAI_MACSEC_SA_ATTR_SC_ID; + attrList[0].value.oid = 0; + attrList[1].id = SAI_MACSEC_SA_ATTR_MACSEC_DIRECTION; + attrList[1].value.s32 = sai_macsec_direction_t::SAI_MACSEC_DIRECTION_INGRESS; + attrList[2].id = SAI_MACSEC_SA_ATTR_AN; + attrList[2].value.s32 = 0; + attrList[3].id = SAI_MACSEC_SA_ATTR_SAK; + attrList[4].id = SAI_MACSEC_SA_ATTR_AUTH_KEY; + attrList[5].id = SAI_MACSEC_SA_ATTR_MINIMUM_INGRESS_XPN; + EXPECT_EQ(SAI_STATUS_SUCCESS, ss.loadMACsecAttrFromMACsecSA(0, sizeof(attrList)/sizeof(attrList[0]), attrList, macsecAttr)); + + EXPECT_EQ(macsecAttr.m_cipher, MACsecAttr::CIPHER_NAME_GCM_AES_128); + EXPECT_EQ(macsecAttr.m_direction, sai_macsec_direction_t::SAI_MACSEC_DIRECTION_INGRESS); + + memset(attrList, 0, sizeof(attrList)); + attrList[0].id = SAI_MACSEC_SA_ATTR_SC_ID; + attrList[0].value.oid = 0; + attrList[1].id = SAI_MACSEC_SA_ATTR_MACSEC_DIRECTION; + attrList[1].value.s32 = sai_macsec_direction_t::SAI_MACSEC_DIRECTION_EGRESS; + attrList[2].id = SAI_MACSEC_SA_ATTR_AN; + attrList[2].value.s32 = 0; + attrList[3].id = SAI_MACSEC_SA_ATTR_SAK; + attrList[4].id = SAI_MACSEC_SA_ATTR_AUTH_KEY; + attrList[5].id = SAI_MACSEC_SA_ATTR_CONFIGURED_EGRESS_XPN; + EXPECT_EQ(SAI_STATUS_SUCCESS, ss.loadMACsecAttrFromMACsecSA(0, sizeof(attrList)/sizeof(attrList[0]), attrList, macsecAttr)); EXPECT_EQ(macsecAttr.m_cipher, MACsecAttr::CIPHER_NAME_GCM_AES_128); + EXPECT_EQ(macsecAttr.m_direction, sai_macsec_direction_t::SAI_MACSEC_DIRECTION_EGRESS); + + memset(attrListXpn, 0, sizeof(attrListXpn)); + attrListXpn[0].id = SAI_MACSEC_SA_ATTR_SC_ID; + attrListXpn[0].value.oid = 1; + attrListXpn[1].id = SAI_MACSEC_SA_ATTR_MACSEC_DIRECTION; + attrListXpn[1].value.s32 = sai_macsec_direction_t::SAI_MACSEC_DIRECTION_INGRESS; + attrListXpn[2].id = SAI_MACSEC_SA_ATTR_AN; + attrListXpn[2].value.s32 = 0; + attrListXpn[3].id = SAI_MACSEC_SA_ATTR_SAK; + attrListXpn[4].id = SAI_MACSEC_SA_ATTR_AUTH_KEY; + attrListXpn[5].id = SAI_MACSEC_SA_ATTR_MINIMUM_INGRESS_XPN; + attrListXpn[6].id = SAI_MACSEC_SA_ATTR_MACSEC_SSCI; + attrListXpn[6].value.u32 = 0x23456789; + attrListXpn[7].id = SAI_MACSEC_SA_ATTR_SALT; + EXPECT_EQ(SAI_STATUS_SUCCESS, ss.loadMACsecAttrFromMACsecSA(0, sizeof(attrListXpn)/sizeof(attrListXpn[0]), attrListXpn, macsecAttr)); + + EXPECT_EQ(macsecAttr.m_cipher, MACsecAttr::CIPHER_NAME_GCM_AES_XPN_256); + EXPECT_EQ(macsecAttr.m_direction, sai_macsec_direction_t::SAI_MACSEC_DIRECTION_INGRESS); + EXPECT_EQ(macsecAttr.m_ssci, "23456789"); + + memset(attrListXpn, 0, sizeof(attrListXpn)); + attrListXpn[0].id = SAI_MACSEC_SA_ATTR_SC_ID; + attrListXpn[0].value.oid = 1; + attrListXpn[1].id = SAI_MACSEC_SA_ATTR_MACSEC_DIRECTION; + attrListXpn[1].value.s32 = sai_macsec_direction_t::SAI_MACSEC_DIRECTION_EGRESS; + attrListXpn[2].id = SAI_MACSEC_SA_ATTR_AN; + attrListXpn[2].value.s32 = 0; + attrListXpn[3].id = SAI_MACSEC_SA_ATTR_SAK; + attrListXpn[4].id = SAI_MACSEC_SA_ATTR_AUTH_KEY; + attrListXpn[5].id = SAI_MACSEC_SA_ATTR_CONFIGURED_EGRESS_XPN; + attrListXpn[6].id = SAI_MACSEC_SA_ATTR_MACSEC_SSCI; + attrListXpn[6].value.u32 = 0x23456789; + attrListXpn[7].id = SAI_MACSEC_SA_ATTR_SALT; + EXPECT_EQ(SAI_STATUS_SUCCESS, ss.loadMACsecAttrFromMACsecSA(0, sizeof(attrListXpn)/sizeof(attrListXpn[0]), attrListXpn, macsecAttr)); + + EXPECT_EQ(macsecAttr.m_cipher, MACsecAttr::CIPHER_NAME_GCM_AES_XPN_256); + EXPECT_EQ(macsecAttr.m_direction, sai_macsec_direction_t::SAI_MACSEC_DIRECTION_EGRESS); + EXPECT_EQ(macsecAttr.m_ssci, "23456789"); } TEST(SwitchStateBase, retryCreateIngressMaCsecSAs) diff --git a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp index 701b3d05e..445bc56b6 100644 --- a/unittest/vslib/TestVirtualSwitchSaiInterface.cpp +++ b/unittest/vslib/TestVirtualSwitchSaiInterface.cpp @@ -113,3 +113,30 @@ TEST_F(VirtualSwitchSaiInterfaceTest, portBulkAddRemove) ASSERT_EQ(statusList.at(i), SAI_STATUS_SUCCESS); } } + +TEST_F(VirtualSwitchSaiInterfaceTest, queryApiVersion) +{ + sai_api_version_t version; + + EXPECT_EQ(m_vssai->queryApiVersion(NULL), SAI_STATUS_INVALID_PARAMETER); + EXPECT_EQ(m_vssai->queryApiVersion(&version), SAI_STATUS_SUCCESS); +} + +TEST_F(VirtualSwitchSaiInterfaceTest, bulkGet) +{ + sai_object_id_t oids[1] = {0}; + uint32_t attrcount[1] = {0}; + sai_attribute_t* attrs[1] = {0}; + sai_status_t statuses[1] = {0}; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, + m_vssai->bulkGet( + SAI_OBJECT_TYPE_PORT, + 1, + oids, + attrcount, + attrs, + SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, + statuses)); +} + diff --git a/unittest/vslib/test_sai_vs_acl.cpp b/unittest/vslib/test_sai_vs_acl.cpp deleted file mode 100644 index 73d0bcbcc..000000000 --- a/unittest/vslib/test_sai_vs_acl.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_ars.cpp b/unittest/vslib/test_sai_vs_ars.cpp deleted file mode 100644 index 6ae0d2eae..000000000 --- a/unittest/vslib/test_sai_vs_ars.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_ars_profile.cpp b/unittest/vslib/test_sai_vs_ars_profile.cpp deleted file mode 100644 index f10e421ed..000000000 --- a/unittest/vslib/test_sai_vs_ars_profile.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_bfd.cpp b/unittest/vslib/test_sai_vs_bfd.cpp deleted file mode 100644 index 64c3e7fec..000000000 --- a/unittest/vslib/test_sai_vs_bfd.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_bmtor.cpp b/unittest/vslib/test_sai_vs_bmtor.cpp deleted file mode 100644 index 31ac349f2..000000000 --- a/unittest/vslib/test_sai_vs_bmtor.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_bridge.cpp b/unittest/vslib/test_sai_vs_bridge.cpp deleted file mode 100644 index 2e8c8c481..000000000 --- a/unittest/vslib/test_sai_vs_bridge.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_buffer.cpp b/unittest/vslib/test_sai_vs_buffer.cpp deleted file mode 100644 index b60b31684..000000000 --- a/unittest/vslib/test_sai_vs_buffer.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_counter.cpp b/unittest/vslib/test_sai_vs_counter.cpp deleted file mode 100644 index 917be9059..000000000 --- a/unittest/vslib/test_sai_vs_counter.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_acl.cpp b/unittest/vslib/test_sai_vs_dash_acl.cpp deleted file mode 100644 index b5da844d0..000000000 --- a/unittest/vslib/test_sai_vs_dash_acl.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_direction_lookup.cpp b/unittest/vslib/test_sai_vs_dash_direction_lookup.cpp deleted file mode 100644 index 6c0735796..000000000 --- a/unittest/vslib/test_sai_vs_dash_direction_lookup.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_eni.cpp b/unittest/vslib/test_sai_vs_dash_eni.cpp deleted file mode 100644 index c40c7d724..000000000 --- a/unittest/vslib/test_sai_vs_dash_eni.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_inbound_routing.cpp b/unittest/vslib/test_sai_vs_dash_inbound_routing.cpp deleted file mode 100644 index 7e45d141c..000000000 --- a/unittest/vslib/test_sai_vs_dash_inbound_routing.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_outbound_ca_to_pa.cpp b/unittest/vslib/test_sai_vs_dash_outbound_ca_to_pa.cpp deleted file mode 100644 index a6778cf82..000000000 --- a/unittest/vslib/test_sai_vs_dash_outbound_ca_to_pa.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_outbound_routing.cpp b/unittest/vslib/test_sai_vs_dash_outbound_routing.cpp deleted file mode 100644 index e77838975..000000000 --- a/unittest/vslib/test_sai_vs_dash_outbound_routing.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_pa_validation.cpp b/unittest/vslib/test_sai_vs_dash_pa_validation.cpp deleted file mode 100644 index 911dda16b..000000000 --- a/unittest/vslib/test_sai_vs_dash_pa_validation.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_vip.cpp b/unittest/vslib/test_sai_vs_dash_vip.cpp deleted file mode 100644 index b6cdcc5d1..000000000 --- a/unittest/vslib/test_sai_vs_dash_vip.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dash_vnet.cpp b/unittest/vslib/test_sai_vs_dash_vnet.cpp deleted file mode 100644 index b2c390db2..000000000 --- a/unittest/vslib/test_sai_vs_dash_vnet.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -#include "saiextensions.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_debug_counter.cpp b/unittest/vslib/test_sai_vs_debug_counter.cpp deleted file mode 100644 index 551570bbc..000000000 --- a/unittest/vslib/test_sai_vs_debug_counter.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_dtel.cpp b/unittest/vslib/test_sai_vs_dtel.cpp deleted file mode 100644 index a77ebdff0..000000000 --- a/unittest/vslib/test_sai_vs_dtel.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_fdb.cpp b/unittest/vslib/test_sai_vs_fdb.cpp deleted file mode 100644 index ec0f2e7bb..000000000 --- a/unittest/vslib/test_sai_vs_fdb.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_generic_programmable.cpp b/unittest/vslib/test_sai_vs_generic_programmable.cpp deleted file mode 100644 index ca457c518..000000000 --- a/unittest/vslib/test_sai_vs_generic_programmable.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_hash.cpp b/unittest/vslib/test_sai_vs_hash.cpp deleted file mode 100644 index 29ebebcad..000000000 --- a/unittest/vslib/test_sai_vs_hash.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_hostif.cpp b/unittest/vslib/test_sai_vs_hostif.cpp deleted file mode 100644 index 919b0cabd..000000000 --- a/unittest/vslib/test_sai_vs_hostif.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_interfacequery.cpp b/unittest/vslib/test_sai_vs_interfacequery.cpp deleted file mode 100644 index f10592aa9..000000000 --- a/unittest/vslib/test_sai_vs_interfacequery.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, sai_log_set) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_log_set(SAI_API_VLAN, SAI_LOG_LEVEL_NOTICE)); -} - -TEST(libsaivs, 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(libsaivs, sai_query_attribute_capability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_query_attribute_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); -} - -TEST(libsaivs, sai_query_attribute_enum_values_capability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_query_attribute_enum_values_capability(0,SAI_OBJECT_TYPE_NULL,0,0)); -} - -TEST(libsaivs, sai_object_type_get_availability) -{ - EXPECT_EQ(SAI_STATUS_INVALID_PARAMETER, sai_object_type_get_availability(0,SAI_OBJECT_TYPE_NULL,0,0,0)); -} - -TEST(libsaivs, sai_dbg_generate_dump) -{ - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai_dbg_generate_dump(nullptr)); -} - -TEST(libsaivs, sai_object_type_query) -{ - EXPECT_EQ(SAI_OBJECT_TYPE_NULL, sai_object_type_query(SAI_NULL_OBJECT_ID)); -} - -TEST(libsaivs, sai_switch_id_query) -{ - EXPECT_EQ(SAI_NULL_OBJECT_ID, sai_switch_id_query(SAI_NULL_OBJECT_ID)); -} - -TEST(libsaivs, 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(libsaivs, 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)); -} diff --git a/unittest/vslib/test_sai_vs_ipmc.cpp b/unittest/vslib/test_sai_vs_ipmc.cpp deleted file mode 100644 index 0ddb064e9..000000000 --- a/unittest/vslib/test_sai_vs_ipmc.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_ipmc_group.cpp b/unittest/vslib/test_sai_vs_ipmc_group.cpp deleted file mode 100644 index cce63e401..000000000 --- a/unittest/vslib/test_sai_vs_ipmc_group.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_isolation_group.cpp b/unittest/vslib/test_sai_vs_isolation_group.cpp deleted file mode 100644 index c7c14701d..000000000 --- a/unittest/vslib/test_sai_vs_isolation_group.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_l2mc.cpp b/unittest/vslib/test_sai_vs_l2mc.cpp deleted file mode 100644 index 9e629c46e..000000000 --- a/unittest/vslib/test_sai_vs_l2mc.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_l2mcgroup.cpp b/unittest/vslib/test_sai_vs_l2mcgroup.cpp deleted file mode 100644 index a96c72211..000000000 --- a/unittest/vslib/test_sai_vs_l2mcgroup.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_lag.cpp b/unittest/vslib/test_sai_vs_lag.cpp deleted file mode 100644 index a185f8897..000000000 --- a/unittest/vslib/test_sai_vs_lag.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_macsec.cpp b/unittest/vslib/test_sai_vs_macsec.cpp deleted file mode 100644 index d285df279..000000000 --- a/unittest/vslib/test_sai_vs_macsec.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_mcastfdb.cpp b/unittest/vslib/test_sai_vs_mcastfdb.cpp deleted file mode 100644 index 19d9e3ab9..000000000 --- a/unittest/vslib/test_sai_vs_mcastfdb.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_mirror.cpp b/unittest/vslib/test_sai_vs_mirror.cpp deleted file mode 100644 index cc8056a1b..000000000 --- a/unittest/vslib/test_sai_vs_mirror.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_mpls.cpp b/unittest/vslib/test_sai_vs_mpls.cpp deleted file mode 100644 index efab94955..000000000 --- a/unittest/vslib/test_sai_vs_mpls.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_nat.cpp b/unittest/vslib/test_sai_vs_nat.cpp deleted file mode 100644 index 9bf1dacac..000000000 --- a/unittest/vslib/test_sai_vs_nat.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_neighbor.cpp b/unittest/vslib/test_sai_vs_neighbor.cpp deleted file mode 100644 index f5398762a..000000000 --- a/unittest/vslib/test_sai_vs_neighbor.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_nexthop.cpp b/unittest/vslib/test_sai_vs_nexthop.cpp deleted file mode 100644 index a6f9f3c65..000000000 --- a/unittest/vslib/test_sai_vs_nexthop.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_nexthopgroup.cpp b/unittest/vslib/test_sai_vs_nexthopgroup.cpp deleted file mode 100644 index 24b1cc136..000000000 --- a/unittest/vslib/test_sai_vs_nexthopgroup.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_policer.cpp b/unittest/vslib/test_sai_vs_policer.cpp deleted file mode 100644 index 3ad0bb3ef..000000000 --- a/unittest/vslib/test_sai_vs_policer.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_port.cpp b/unittest/vslib/test_sai_vs_port.cpp deleted file mode 100644 index 189661bb2..000000000 --- a/unittest/vslib/test_sai_vs_port.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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->create_ports(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0,0)); - EXPECT_NE(SAI_STATUS_SUCCESS, api->remove_ports(0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); - EXPECT_NE(SAI_STATUS_SUCCESS, api->set_ports_attribute(0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,0)); - EXPECT_NE(SAI_STATUS_SUCCESS, api->get_ports_attribute(0,0,0,0,SAI_BULK_OP_ERROR_MODE_IGNORE_ERROR,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/vslib/test_sai_vs_qosmap.cpp b/unittest/vslib/test_sai_vs_qosmap.cpp deleted file mode 100644 index 2944056ed..000000000 --- a/unittest/vslib/test_sai_vs_qosmap.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_queue.cpp b/unittest/vslib/test_sai_vs_queue.cpp deleted file mode 100644 index c9b22717e..000000000 --- a/unittest/vslib/test_sai_vs_queue.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_route.cpp b/unittest/vslib/test_sai_vs_route.cpp deleted file mode 100644 index 02bbb5043..000000000 --- a/unittest/vslib/test_sai_vs_route.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_router_interface.cpp b/unittest/vslib/test_sai_vs_router_interface.cpp deleted file mode 100644 index 29b591160..000000000 --- a/unittest/vslib/test_sai_vs_router_interface.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_router_rpfgroup.cpp b/unittest/vslib/test_sai_vs_router_rpfgroup.cpp deleted file mode 100644 index f7c9a4abf..000000000 --- a/unittest/vslib/test_sai_vs_router_rpfgroup.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_router_samplepacket.cpp b/unittest/vslib/test_sai_vs_router_samplepacket.cpp deleted file mode 100644 index 0747132ca..000000000 --- a/unittest/vslib/test_sai_vs_router_samplepacket.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_scheduler.cpp b/unittest/vslib/test_sai_vs_scheduler.cpp deleted file mode 100644 index abbda8905..000000000 --- a/unittest/vslib/test_sai_vs_scheduler.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_schedulergroup.cpp b/unittest/vslib/test_sai_vs_schedulergroup.cpp deleted file mode 100644 index 895388e66..000000000 --- a/unittest/vslib/test_sai_vs_schedulergroup.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_srv6.cpp b/unittest/vslib/test_sai_vs_srv6.cpp deleted file mode 100644 index 6c4bab9d3..000000000 --- a/unittest/vslib/test_sai_vs_srv6.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, srv6) -{ - sai_srv6_api_t *api = nullptr; - - sai_api_query(SAI_API_SRV6, (void**)&api); - - EXPECT_NE(api, nullptr); - - sai_my_sid_entry_t id; - sai_object_id_t obj_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/vslib/test_sai_vs_stp.cpp b/unittest/vslib/test_sai_vs_stp.cpp deleted file mode 100644 index 2bbf90d7e..000000000 --- a/unittest/vslib/test_sai_vs_stp.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_switch.cpp b/unittest/vslib/test_sai_vs_switch.cpp deleted file mode 100644 index 6335a9a4d..000000000 --- a/unittest/vslib/test_sai_vs_switch.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_system_port.cpp b/unittest/vslib/test_sai_vs_system_port.cpp deleted file mode 100644 index b668e6f18..000000000 --- a/unittest/vslib/test_sai_vs_system_port.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_tam.cpp b/unittest/vslib/test_sai_vs_tam.cpp deleted file mode 100644 index b67b068b9..000000000 --- a/unittest/vslib/test_sai_vs_tam.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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)); -} - -TEST(libsairedis, 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/vslib/test_sai_vs_tunnel.cpp b/unittest/vslib/test_sai_vs_tunnel.cpp deleted file mode 100644 index 5e9136fc8..000000000 --- a/unittest/vslib/test_sai_vs_tunnel.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_udf.cpp b/unittest/vslib/test_sai_vs_udf.cpp deleted file mode 100644 index 8b6f6e87f..000000000 --- a/unittest/vslib/test_sai_vs_udf.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_virtual_router.cpp b/unittest/vslib/test_sai_vs_virtual_router.cpp deleted file mode 100644 index 88506311b..000000000 --- a/unittest/vslib/test_sai_vs_virtual_router.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_vlan.cpp b/unittest/vslib/test_sai_vs_vlan.cpp deleted file mode 100644 index 5d41558a4..000000000 --- a/unittest/vslib/test_sai_vs_vlan.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/test_sai_vs_wred.cpp b/unittest/vslib/test_sai_vs_wred.cpp deleted file mode 100644 index cdf11847a..000000000 --- a/unittest/vslib/test_sai_vs_wred.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -extern "C" { -#include "sai.h" -} - -#include "swss/logger.h" - -TEST(libsaivs, 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/vslib/LaneMapFileParser.cpp b/vslib/LaneMapFileParser.cpp index 1d32719e9..6c9d03576 100644 --- a/vslib/LaneMapFileParser.cpp +++ b/vslib/LaneMapFileParser.cpp @@ -64,7 +64,7 @@ void LaneMapFileParser::parse( size_t n = tokens.size(); - if (n != 1 && n != 2 && n != 4) + if (n != 1 && n != 2 && n != 4 && n != 8) { SWSS_LOG_ERROR("invalid number of lanes (%zu) assigned to interface %s", n, ifname.c_str()); return; diff --git a/vslib/MACsecAttr.h b/vslib/MACsecAttr.h index 37f6493c9..106b7b07b 100644 --- a/vslib/MACsecAttr.h +++ b/vslib/MACsecAttr.h @@ -7,10 +7,8 @@ namespace saivs { - using macsec_sci_t = std::string; using macsec_an_t = std::uint16_t; using macsec_pn_t = std::uint64_t; - using macsec_ssci_t = std::uint32_t; struct MACsecAttr { @@ -52,11 +50,11 @@ namespace saivs std::string m_authKey; std::string m_sak; std::string m_sci; + std::string m_ssci; std::string m_salt; macsec_an_t m_an; macsec_pn_t m_pn; - macsec_ssci_t m_ssci; bool m_sendSci; bool m_encryptionEnable; diff --git a/vslib/MACsecManager.cpp b/vslib/MACsecManager.cpp index d6ff15637..6688bad41 100644 --- a/vslib/MACsecManager.cpp +++ b/vslib/MACsecManager.cpp @@ -319,7 +319,7 @@ bool MACsecManager::update_macsec_sa_pn( ostream << " ssci " << attr.m_ssci; } - ostream << " pn " << pn; + ostream << ( attr.is_xpn() ? " xpn " : " pn " ) << pn; SWSS_LOG_NOTICE("%s", ostream.str().c_str()); @@ -447,10 +447,10 @@ bool MACsecManager::create_macsec_egress_sa( << shellquote(attr.m_macsecName) << " tx sa " << attr.m_an - << " pn " + << ( attr.is_xpn() ? " xpn " : " pn ") << attr.m_pn << ( attr.is_xpn() ? " ssci " : "" ) - << ( attr.is_xpn() ? std::to_string(attr.m_ssci) : "" ) + << ( attr.is_xpn() ? attr.m_ssci : "" ) << ( attr.is_xpn() ? " salt " : "" ) << ( attr.is_xpn() ? attr.m_salt : "" ) << " on key " @@ -484,10 +484,10 @@ bool MACsecManager::create_macsec_ingress_sa( << attr.m_sci << " sa " << attr.m_an - << " pn " + << ( attr.is_xpn() ? " xpn " : " pn " ) << attr.m_pn << ( attr.is_xpn() ? " ssci " : "" ) - << ( attr.is_xpn() ? std::to_string(attr.m_ssci) : "" ) + << ( attr.is_xpn() ? attr.m_ssci : "" ) << ( attr.is_xpn() ? " salt " : "" ) << ( attr.is_xpn() ? attr.m_salt : "" ) << " on key " diff --git a/vslib/Makefile.am b/vslib/Makefile.am index c498acad2..ab6b68a31 100644 --- a/vslib/Makefile.am +++ b/vslib/Makefile.am @@ -61,69 +61,15 @@ libSaiVS_a_SOURCES = \ VirtualSwitchSaiInterfaceFdb.cpp \ VirtualSwitchSaiInterfacePort.cpp -libsaivs_la_SOURCES = \ - sai_vs_acl.cpp \ - sai_vs_bfd.cpp \ - sai_vs_bmtor.cpp \ - sai_vs_bridge.cpp \ - sai_vs_buffer.cpp \ - sai_vs_counter.cpp \ - sai_vs_dash_vip.cpp \ - sai_vs_dash_pa_validation.cpp \ - sai_vs_dash_vnet.cpp \ - sai_vs_dash_outbound_routing.cpp \ - sai_vs_dash_outbound_ca_to_pa.cpp \ - sai_vs_dash_inbound_routing.cpp \ - sai_vs_dash_eni.cpp \ - sai_vs_dash_direction_lookup.cpp \ - sai_vs_dash_acl.cpp \ - sai_vs_debug_counter.cpp\ - sai_vs_dtel.cpp \ - sai_vs_fdb.cpp \ - sai_vs_genericprogrammable.cpp \ - sai_vs_hash.cpp \ - sai_vs_hostif.cpp \ - sai_vs_interfacequery.cpp \ - sai_vs_ipmc.cpp \ - sai_vs_ipmc_group.cpp \ - sai_vs_isolation_group.cpp \ - sai_vs_l2mc.cpp \ - sai_vs_l2mcgroup.cpp \ - sai_vs_lag.cpp \ - sai_vs_macsec.cpp \ - sai_vs_mcastfdb.cpp \ - sai_vs_mirror.cpp \ - sai_vs_mpls.cpp \ - sai_vs_nat.cpp \ - sai_vs_neighbor.cpp \ - sai_vs_nexthop.cpp \ - sai_vs_nexthopgroup.cpp \ - sai_vs_policer.cpp \ - sai_vs_port.cpp \ - sai_vs_qosmap.cpp \ - sai_vs_queue.cpp \ - sai_vs_route.cpp \ - sai_vs_router_interface.cpp \ - sai_vs_rpfgroup.cpp \ - sai_vs_samplepacket.cpp \ - sai_vs_scheduler.cpp \ - sai_vs_schedulergroup.cpp \ - sai_vs_srv6.cpp \ - sai_vs_stp.cpp \ - sai_vs_switch.cpp \ - sai_vs_system_port.cpp \ - sai_vs_tam.cpp \ - sai_vs_tunnel.cpp \ - sai_vs_udf.cpp \ - sai_vs_virtual_router.cpp \ - sai_vs_vlan.cpp \ - sai_vs_wred.cpp \ - sai_vs_my_mac.cpp \ - sai_vs_ipsec.cpp \ - sai_vs_ars.cpp \ - sai_vs_ars_profile.cpp \ - sai_vs_twamp.cpp \ - sai_vs_dash_meter.cpp +BUILT_SOURCES = sai_vs.cpp + +sai_vs.cpp: ../stub.pl $(top_srcdir)/SAI/meta/saimetadata.c + ../stub.pl -d ../SAI/ -c Sai -n saivs -f sai_vs.cpp -s stub + +clean-local: + rm -f sai_vs.cpp + +libsaivs_la_SOURCES = sai_vs.cpp libSaiVS_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) libSaiVS_a_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) $(CODE_COVERAGE_CXXFLAGS) diff --git a/vslib/Sai.cpp b/vslib/Sai.cpp index 98d0ed476..97238f9de 100644 --- a/vslib/Sai.cpp +++ b/vslib/Sai.cpp @@ -51,13 +51,13 @@ Sai::~Sai() if (m_apiInitialized) { - uninitialize(); + apiUninitialize(); } } // INITIALIZE UNINITIALIZE -sai_status_t Sai::initialize( +sai_status_t Sai::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -274,7 +274,7 @@ sai_status_t Sai::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t Sai::uninitialize(void) +sai_status_t Sai::apiUninitialize(void) { SWSS_LOG_ENTER(); VS_CHECK_API_INITIALIZED(); @@ -621,6 +621,22 @@ sai_status_t Sai::bulkSet( object_statuses); } +sai_status_t Sai::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + // BULK QUAD ENTRY #define DECLARE_BULK_CREATE_ENTRY(OT,ot) \ @@ -690,6 +706,26 @@ sai_status_t Sai::bulkSet( \ SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t Sai::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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(); \ + MUTEX(); \ + VS_CHECK_API_INITIALIZED(); \ + SWSS_LOG_ERROR("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + // NON QUAD API sai_status_t Sai::flushFdbEntries( @@ -745,7 +781,7 @@ sai_status_t Sai::queryAttributeCapability( capability); } -sai_status_t Sai::queryAattributeEnumValuesCapability( +sai_status_t Sai::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -755,7 +791,7 @@ sai_status_t Sai::queryAattributeEnumValuesCapability( SWSS_LOG_ENTER(); VS_CHECK_API_INITIALIZED(); - return m_meta->queryAattributeEnumValuesCapability( + return m_meta->queryAttributeEnumValuesCapability( switch_id, object_type, attr_id, @@ -807,6 +843,16 @@ sai_status_t Sai::logSet( return m_meta->logSet(api, log_level); } +sai_status_t Sai::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + MUTEX(); + SWSS_LOG_ENTER(); + VS_CHECK_API_INITIALIZED(); + + return m_meta->queryApiVersion(version); +} + std::shared_ptr Sai::getContext( _In_ uint32_t globalContext) const { diff --git a/vslib/Sai.h b/vslib/Sai.h index 11075b6ae..191746155 100644 --- a/vslib/Sai.h +++ b/vslib/Sai.h @@ -32,11 +32,11 @@ namespace saivs public: - sai_status_t initialize( + sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - sai_status_t uninitialize(void) override; + sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -94,6 +94,15 @@ namespace saivs _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -165,7 +174,7 @@ namespace saivs _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -181,6 +190,9 @@ namespace saivs _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: // QUAD pre sai_status_t preSet( diff --git a/vslib/Switch.cpp b/vslib/Switch.cpp index 4c24bc015..dc5165902 100644 --- a/vslib/Switch.cpp +++ b/vslib/Switch.cpp @@ -80,6 +80,11 @@ void Switch::updateNotifications( (sai_switch_state_change_notification_fn)attr.value.ptr; break; + case SAI_SWITCH_ATTR_SWITCH_ASIC_SDK_HEALTH_EVENT_NOTIFY: + m_switchNotifications.on_switch_asic_sdk_health_event = + (sai_switch_asic_sdk_health_event_notification_fn)attr.value.ptr; + break; + case SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY: m_switchNotifications.on_switch_shutdown_request = (sai_switch_shutdown_request_notification_fn)attr.value.ptr; diff --git a/vslib/SwitchStateBaseMACsec.cpp b/vslib/SwitchStateBaseMACsec.cpp index bdc433951..e08f3f30a 100644 --- a/vslib/SwitchStateBaseMACsec.cpp +++ b/vslib/SwitchStateBaseMACsec.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using namespace saivs; @@ -554,12 +555,7 @@ sai_status_t SwitchStateBase::loadMACsecAttrFromMACsecSC( std::stringstream sciHexStr; sciHexStr << std::setw(MACSEC_SCI_LENGTH) << std::setfill('0'); - -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - sciHexStr << std::hex << bswap_64(sci); -#else - sciHexStr << std::hex << sci; -#endif + sciHexStr << std::hex << htobe64(sci); macsecAttr.m_sci = sciHexStr.str(); @@ -708,7 +704,15 @@ sai_status_t SwitchStateBase::loadMACsecAttrFromMACsecSA( // The Linux kernel directly uses ssci to XOR with the salt that is network order, // So, this conversion is useful to convert SSCI from the host order to network order. - macsecAttr.m_ssci = htonl(attr->value.u32); + // + // Starting with Debian Bookworm (iproute2 6.1), ssci is interpreted as a hex string, + // so this needs to convert the ssci integer to a hex string, and doesn't need to change + // the encoding at this point. + std::stringstream ssciHexStr; + + ssciHexStr << std::hex << attr->value.u32; + + macsecAttr.m_ssci = ssciHexStr.str(); SAI_METADATA_GET_ATTR_BY_ID(attr, SAI_MACSEC_SA_ATTR_SALT, attrCount, attrList); diff --git a/vslib/VirtualSwitchSaiInterface.cpp b/vslib/VirtualSwitchSaiInterface.cpp index 050cb106e..d866f5ac1 100644 --- a/vslib/VirtualSwitchSaiInterface.cpp +++ b/vslib/VirtualSwitchSaiInterface.cpp @@ -47,7 +47,7 @@ VirtualSwitchSaiInterface::~VirtualSwitchSaiInterface() // empty } -sai_status_t VirtualSwitchSaiInterface::initialize( +sai_status_t VirtualSwitchSaiInterface::apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) { @@ -56,7 +56,7 @@ sai_status_t VirtualSwitchSaiInterface::initialize( return SAI_STATUS_SUCCESS; } -sai_status_t VirtualSwitchSaiInterface::uninitialize(void) +sai_status_t VirtualSwitchSaiInterface::apiUninitialize(void) { SWSS_LOG_ENTER(); @@ -533,6 +533,24 @@ sai_status_t VirtualSwitchSaiInterface::bulkSet( \ SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_SET_ENTRY); +// BULK GET + +#define DECLARE_BULK_GET_ENTRY(OT,ot) \ +sai_status_t VirtualSwitchSaiInterface::bulkGet( \ + _In_ uint32_t object_count, \ + _In_ const sai_ ## ot ## _t *ot, \ + _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("FIXME not implemented"); \ + return SAI_STATUS_NOT_IMPLEMENTED; \ +} + +SAIREDIS_DECLARE_EVERY_BULK_ENTRY(DECLARE_BULK_GET_ENTRY); + std::shared_ptr VirtualSwitchSaiInterface::init_switch( _In_ sai_object_id_t switch_id, _In_ std::shared_ptr config, @@ -876,7 +894,7 @@ sai_status_t VirtualSwitchSaiInterface::queryAttributeCapability( return ss->queryAttributeCapability(switch_id, object_type, attr_id, capability); } -sai_status_t VirtualSwitchSaiInterface::queryAattributeEnumValuesCapability( +sai_status_t VirtualSwitchSaiInterface::queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -1151,6 +1169,22 @@ sai_status_t VirtualSwitchSaiInterface::bulkSet( return ss->bulkSet(object_type, serialized_object_ids, attr_list, mode, object_statuses); } +sai_status_t VirtualSwitchSaiInterface::bulkGet( + _In_ sai_object_type_t object_type, + _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, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; +} + sai_status_t VirtualSwitchSaiInterface::bulkCreate( _In_ sai_object_type_t object_type, _In_ sai_object_id_t switch_id, @@ -1230,6 +1264,23 @@ sai_status_t VirtualSwitchSaiInterface::logSet( return SAI_STATUS_SUCCESS; } +sai_status_t VirtualSwitchSaiInterface::queryApiVersion( + _Out_ sai_api_version_t *version) +{ + SWSS_LOG_ENTER(); + + if (version) + { + *version = SAI_API_VERSION; + + return SAI_STATUS_SUCCESS; + } + + SWSS_LOG_ERROR("version parameter is NULL"); + + return SAI_STATUS_INVALID_PARAMETER; +} + bool VirtualSwitchSaiInterface::writeWarmBootFile( _In_ const char* warmBootFile) const { diff --git a/vslib/VirtualSwitchSaiInterface.h b/vslib/VirtualSwitchSaiInterface.h index d868ee59d..25855fdec 100644 --- a/vslib/VirtualSwitchSaiInterface.h +++ b/vslib/VirtualSwitchSaiInterface.h @@ -31,11 +31,11 @@ namespace saivs public: - virtual sai_status_t initialize( + virtual sai_status_t apiInitialize( _In_ uint64_t flags, _In_ const sai_service_method_table_t *service_method_table) override; - virtual sai_status_t uninitialize(void) override; + virtual sai_status_t apiUninitialize(void) override; public: // SAI interface overrides @@ -93,6 +93,15 @@ namespace saivs _In_ sai_bulk_op_error_mode_t mode, _Out_ sai_status_t *object_statuses) override; + virtual sai_status_t bulkGet( + _In_ sai_object_type_t object_type, + _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) override; + public: // stats API virtual sai_status_t getStats( @@ -164,7 +173,7 @@ namespace saivs _In_ sai_attr_id_t attr_id, _Out_ sai_attr_capability_t *capability) override; - virtual sai_status_t queryAattributeEnumValuesCapability( + virtual sai_status_t queryAttributeEnumValuesCapability( _In_ sai_object_id_t switch_id, _In_ sai_object_type_t object_type, _In_ sai_attr_id_t attr_id, @@ -180,6 +189,9 @@ namespace saivs _In_ sai_api_t api, _In_ sai_log_level_t log_level) override; + virtual sai_status_t queryApiVersion( + _Out_ sai_api_version_t *version) override; + private: // QUAD API helpers sai_status_t create( diff --git a/vslib/sai_vs.h b/vslib/sai_vs.h deleted file mode 100644 index 485f9a559..000000000 --- a/vslib/sai_vs.h +++ /dev/null @@ -1,449 +0,0 @@ -#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 vs_acl_api; -PRIVATE extern const sai_ars_api_t vs_ars_api; -PRIVATE extern const sai_ars_profile_api_t vs_ars_profile_api; -PRIVATE extern const sai_bfd_api_t vs_bfd_api; -PRIVATE extern const sai_bmtor_api_t vs_bmtor_api; -PRIVATE extern const sai_generic_programmable_api_t vs_generic_programmable_api; -PRIVATE extern const sai_bridge_api_t vs_bridge_api; -PRIVATE extern const sai_buffer_api_t vs_buffer_api; -PRIVATE extern const sai_counter_api_t vs_counter_api; -PRIVATE extern const sai_dash_vip_api_t vs_dash_vip_api; -PRIVATE extern const sai_dash_pa_validation_api_t vs_dash_pa_validation_api; -PRIVATE extern const sai_dash_vnet_api_t vs_dash_vnet_api; -PRIVATE extern const sai_dash_outbound_routing_api_t vs_dash_outbound_routing_api; -PRIVATE extern const sai_dash_outbound_ca_to_pa_api_t vs_dash_outbound_ca_to_pa_api; -PRIVATE extern const sai_dash_inbound_routing_api_t vs_dash_inbound_routing_api; -PRIVATE extern const sai_dash_eni_api_t vs_dash_eni_api; -PRIVATE extern const sai_dash_direction_lookup_api_t vs_dash_direction_lookup_api; -PRIVATE extern const sai_dash_acl_api_t vs_dash_acl_api; -PRIVATE extern const sai_debug_counter_api_t vs_debug_counter_api; -PRIVATE extern const sai_dtel_api_t vs_dtel_api; -PRIVATE extern const sai_fdb_api_t vs_fdb_api; -PRIVATE extern const sai_hash_api_t vs_hash_api; -PRIVATE extern const sai_hostif_api_t vs_hostif_api; -PRIVATE extern const sai_ipmc_api_t vs_ipmc_api; -PRIVATE extern const sai_ipmc_group_api_t vs_ipmc_group_api; -PRIVATE extern const sai_isolation_group_api_t vs_isolation_group_api; -PRIVATE extern const sai_l2mc_api_t vs_l2mc_api; -PRIVATE extern const sai_l2mc_group_api_t vs_l2mc_group_api; -PRIVATE extern const sai_lag_api_t vs_lag_api; -PRIVATE extern const sai_macsec_api_t vs_macsec_api; -PRIVATE extern const sai_mcast_fdb_api_t vs_mcast_fdb_api; -PRIVATE extern const sai_mirror_api_t vs_mirror_api; -PRIVATE extern const sai_mpls_api_t vs_mpls_api; -PRIVATE extern const sai_nat_api_t vs_nat_api; -PRIVATE extern const sai_neighbor_api_t vs_neighbor_api; -PRIVATE extern const sai_next_hop_api_t vs_next_hop_api; -PRIVATE extern const sai_next_hop_group_api_t vs_next_hop_group_api; -PRIVATE extern const sai_policer_api_t vs_policer_api; -PRIVATE extern const sai_port_api_t vs_port_api; -PRIVATE extern const sai_qos_map_api_t vs_qos_map_api; -PRIVATE extern const sai_queue_api_t vs_queue_api; -PRIVATE extern const sai_route_api_t vs_route_api; -PRIVATE extern const sai_router_interface_api_t vs_router_interface_api; -PRIVATE extern const sai_rpf_group_api_t vs_rpf_group_api; -PRIVATE extern const sai_samplepacket_api_t vs_samplepacket_api; -PRIVATE extern const sai_scheduler_api_t vs_scheduler_api; -PRIVATE extern const sai_scheduler_group_api_t vs_scheduler_group_api; -PRIVATE extern const sai_srv6_api_t vs_srv6_api; -PRIVATE extern const sai_stp_api_t vs_stp_api; -PRIVATE extern const sai_switch_api_t vs_switch_api; -PRIVATE extern const sai_system_port_api_t vs_system_port_api; -PRIVATE extern const sai_tam_api_t vs_tam_api; -PRIVATE extern const sai_tunnel_api_t vs_tunnel_api; -PRIVATE extern const sai_udf_api_t vs_udf_api; -PRIVATE extern const sai_virtual_router_api_t vs_virtual_router_api; -PRIVATE extern const sai_vlan_api_t vs_vlan_api; -PRIVATE extern const sai_wred_api_t vs_wred_api; -PRIVATE extern const sai_my_mac_api_t vs_my_mac_api; -PRIVATE extern const sai_ipsec_api_t vs_ipsec_api; -PRIVATE extern const sai_twamp_api_t vs_twamp_api; -PRIVATE extern const sai_dash_meter_api_t vs_dash_meter_api; - -PRIVATE extern std::shared_ptr vs_sai; - -// QUAD OID - -#define VS_CREATE(OT,ot) \ - static sai_status_t vs_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 vs_sai->create( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - switch_id, \ - attr_count, \ - attr_list); \ -} - -#define VS_REMOVE(OT,ot) \ - static sai_status_t vs_remove_ ## ot( \ - _In_ sai_object_id_t object_id) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->remove( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id); \ -} - -#define VS_SET(OT,ot) \ - static sai_status_t vs_set_ ## ot ## _attribute( \ - _In_ sai_object_id_t object_id, \ - _In_ const sai_attribute_t *attr) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->set( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - attr); \ -} - -#define VS_GET(OT,ot) \ - static sai_status_t vs_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 vs_sai->get( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - attr_count, \ - attr_list); \ -} - -// QUAD DECLARE - -#define VS_GENERIC_QUAD(OT,ot) \ - VS_CREATE(OT,ot); \ - VS_REMOVE(OT,ot); \ - VS_SET(OT,ot); \ - VS_GET(OT,ot); - -// QUAD ENTRY - -#define VS_CREATE_ENTRY(OT,ot) \ - static sai_status_t vs_create_ ## ot( \ - _In_ const sai_ ## ot ##_t *entry, \ - _In_ uint32_t attr_count, \ - _In_ const sai_attribute_t *attr_list) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->create( \ - entry, \ - attr_count, \ - attr_list); \ -} - -#define VS_REMOVE_ENTRY(OT,ot) \ - static sai_status_t vs_remove_ ## ot( \ - _In_ const sai_ ## ot ## _t *entry) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->remove( \ - entry); \ -} - -#define VS_SET_ENTRY(OT,ot) \ - static sai_status_t vs_set_ ## ot ## _attribute( \ - _In_ const sai_ ## ot ## _t *entry, \ - _In_ const sai_attribute_t *attr) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->set( \ - entry, \ - attr); \ -} - -#define VS_GET_ENTRY(OT,ot) \ - static sai_status_t vs_get_ ## ot ## _attribute( \ - _In_ const sai_ ## ot ## _t *entry, \ - _In_ uint32_t attr_count, \ - _Inout_ sai_attribute_t *attr_list) \ -{ \ - SWSS_LOG_ENTER(); \ - return vs_sai->get( \ - entry, \ - attr_count, \ - attr_list); \ -} - -// QUAD ENTRY DECLARE - -#define VS_GENERIC_QUAD_ENTRY(OT,ot) \ - VS_CREATE_ENTRY(OT,ot); \ - VS_REMOVE_ENTRY(OT,ot); \ - VS_SET_ENTRY(OT,ot); \ - VS_GET_ENTRY(OT,ot); - -// QUAD API - -#define VS_GENERIC_QUAD_API(ot) \ - vs_create_ ## ot, \ - vs_remove_ ## ot, \ - vs_set_ ## ot ##_attribute, \ - vs_get_ ## ot ##_attribute, - -// STATS - -#define VS_GET_STATS(OT,ot) \ - static sai_status_t vs_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 vs_sai->getStats( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids, \ - counters); \ -} - -#define VS_GET_STATS_EXT(OT,ot) \ - static sai_status_t vs_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 vs_sai->getStatsExt( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids, \ - mode, \ - counters); \ -} - -#define VS_CLEAR_STATS(OT,ot) \ - static sai_status_t vs_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 vs_sai->clearStats( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_id, \ - number_of_counters, \ - counter_ids); \ -} - -// STATS DECLARE - -#define VS_GENERIC_STATS(OT, ot) \ - VS_GET_STATS(OT,ot); \ - VS_GET_STATS_EXT(OT,ot); \ - VS_CLEAR_STATS(OT,ot); - -// STATS API - -#define VS_GENERIC_STATS_API(ot) \ - vs_get_ ## ot ## _stats, \ - vs_get_ ## ot ## _stats_ext, \ - vs_clear_ ## ot ## _stats, - -// BULK QUAD - -#define VS_BULK_CREATE(OT,fname) \ - static sai_status_t vs_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 vs_sai->bulkCreate( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - switch_id, \ - object_count, \ - attr_count, \ - attr_list, \ - mode, \ - object_id, \ - object_statuses); \ -} - -#define VS_BULK_REMOVE(OT,fname) \ - static sai_status_t vs_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 vs_sai->bulkRemove( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_count, \ - object_id, \ - mode, \ - object_statuses); \ -} - -#define VS_BULK_SET(OT,fname) \ - static sai_status_t vs_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 vs_sai->bulkSet( \ - (sai_object_type_t)SAI_OBJECT_TYPE_ ## OT, \ - object_count, \ - object_id, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define VS_BULK_GET(OT,fname) \ - static sai_status_t vs_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 VS_BULK_QUAD(OT,ot) \ - VS_BULK_CREATE(OT,ot); \ - VS_BULK_REMOVE(OT,ot); \ - VS_BULK_SET(OT,ot); \ - VS_BULK_GET(OT,ot); - -// BULK QUAD ENTRY - -#define VS_BULK_CREATE_ENTRY(OT,ot) \ - VS_BULK_CREATE_ENTRY_EX(OT,ot,ot) - -#define VS_BULK_CREATE_ENTRY_EX(OT,ot,fname) \ - static sai_status_t vs_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 vs_sai->bulkCreate( \ - object_count, \ - entry, \ - attr_count, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define VS_BULK_REMOVE_ENTRY(OT,ot) \ - VS_BULK_REMOVE_ENTRY_EX(OT, ot, ot) - -#define VS_BULK_REMOVE_ENTRY_EX(OT,ot,fname) \ - static sai_status_t vs_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 vs_sai->bulkRemove( \ - object_count, \ - entry, \ - mode, \ - object_statuses); \ -} - -#define VS_BULK_SET_ENTRY(OT,ot) \ - static sai_status_t vs_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 vs_sai->bulkSet( \ - object_count, \ - entry, \ - attr_list, \ - mode, \ - object_statuses); \ -} - -#define VS_BULK_GET_ENTRY(OT,ot) \ - static sai_status_t vs_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 VS_BULK_QUAD_ENTRY(OT,ot) \ - VS_BULK_CREATE_ENTRY(OT,ot); \ - VS_BULK_REMOVE_ENTRY(OT,ot); \ - VS_BULK_SET_ENTRY(OT,ot); \ - VS_BULK_GET_ENTRY(OT,ot); - -// BULK QUAD API - -#define VS_BULK_QUAD_API(ot) \ - vs_bulk_create_ ## ot, \ - vs_bulk_remove_ ## ot, \ - vs_bulk_set_ ## ot, \ - vs_bulk_get_ ## ot, - -// BULK get/set DECLARE for vs - -#define VS_BULK_GET_SET(OT,ot) \ - VS_BULK_GET(OT,ot); \ - VS_BULK_SET(OT,ot); - -// BULK get/set API for vs - -#define VS_BULK_GET_SET_API(ot) \ - vs_bulk_get_ ## ot, \ - vs_bulk_set_ ## ot, diff --git a/vslib/sai_vs_acl.cpp b/vslib/sai_vs_acl.cpp deleted file mode 100644 index 2fea15e0b..000000000 --- a/vslib/sai_vs_acl.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(ACL_TABLE,acl_table); -VS_GENERIC_QUAD(ACL_ENTRY,acl_entry); -VS_GENERIC_QUAD(ACL_COUNTER,acl_counter); -VS_GENERIC_QUAD(ACL_RANGE,acl_range); -VS_GENERIC_QUAD(ACL_TABLE_GROUP,acl_table_group); -VS_GENERIC_QUAD(ACL_TABLE_GROUP_MEMBER,acl_table_group_member); -VS_GENERIC_QUAD(ACL_TABLE_CHAIN_GROUP,acl_table_chain_group) - -const sai_acl_api_t vs_acl_api = { - - VS_GENERIC_QUAD_API(acl_table) - VS_GENERIC_QUAD_API(acl_entry) - VS_GENERIC_QUAD_API(acl_counter) - VS_GENERIC_QUAD_API(acl_range) - VS_GENERIC_QUAD_API(acl_table_group) - VS_GENERIC_QUAD_API(acl_table_group_member) - VS_GENERIC_QUAD_API(acl_table_chain_group) -}; diff --git a/vslib/sai_vs_ars.cpp b/vslib/sai_vs_ars.cpp deleted file mode 100644 index 961f7a508..000000000 --- a/vslib/sai_vs_ars.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(ARS, ars); - -const sai_ars_api_t vs_ars_api = { - VS_GENERIC_QUAD_API(ars) -}; diff --git a/vslib/sai_vs_ars_profile.cpp b/vslib/sai_vs_ars_profile.cpp deleted file mode 100644 index 4adf53b90..000000000 --- a/vslib/sai_vs_ars_profile.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(ARS_PROFILE, ars_profile); - -const sai_ars_profile_api_t vs_ars_profile_api = { - VS_GENERIC_QUAD_API(ars_profile) -}; diff --git a/vslib/sai_vs_bfd.cpp b/vslib/sai_vs_bfd.cpp deleted file mode 100644 index f444b5118..000000000 --- a/vslib/sai_vs_bfd.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(BFD_SESSION,bfd_session); -VS_GENERIC_STATS(BFD_SESSION,bfd_session); - -const sai_bfd_api_t vs_bfd_api = { - - VS_GENERIC_QUAD_API(bfd_session) - VS_GENERIC_STATS_API(bfd_session) -}; diff --git a/vslib/sai_vs_bmtor.cpp b/vslib/sai_vs_bmtor.cpp deleted file mode 100644 index cec20a576..000000000 --- a/vslib/sai_vs_bmtor.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); -VS_GENERIC_STATS(TABLE_BITMAP_CLASSIFICATION_ENTRY,table_bitmap_classification_entry); -VS_GENERIC_QUAD(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); -VS_GENERIC_STATS(TABLE_BITMAP_ROUTER_ENTRY,table_bitmap_router_entry); -VS_GENERIC_QUAD(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); -VS_GENERIC_STATS(TABLE_META_TUNNEL_ENTRY,table_meta_tunnel_entry); - -const sai_bmtor_api_t vs_bmtor_api = { - VS_GENERIC_QUAD_API(table_bitmap_classification_entry) - VS_GENERIC_STATS_API(table_bitmap_classification_entry) - VS_GENERIC_QUAD_API(table_bitmap_router_entry) - VS_GENERIC_STATS_API(table_bitmap_router_entry) - VS_GENERIC_QUAD_API(table_meta_tunnel_entry) - VS_GENERIC_STATS_API(table_meta_tunnel_entry) -}; diff --git a/vslib/sai_vs_bridge.cpp b/vslib/sai_vs_bridge.cpp deleted file mode 100644 index 1d1227a37..000000000 --- a/vslib/sai_vs_bridge.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(BRIDGE,bridge); -VS_GENERIC_QUAD(BRIDGE_PORT,bridge_port); -VS_GENERIC_STATS(BRIDGE,bridge); -VS_GENERIC_STATS(BRIDGE_PORT,bridge_port); - -const sai_bridge_api_t vs_bridge_api = { - - VS_GENERIC_QUAD_API(bridge) - VS_GENERIC_STATS_API(bridge) - VS_GENERIC_QUAD_API(bridge_port) - VS_GENERIC_STATS_API(bridge_port) -}; diff --git a/vslib/sai_vs_buffer.cpp b/vslib/sai_vs_buffer.cpp deleted file mode 100644 index 32e1fa4a4..000000000 --- a/vslib/sai_vs_buffer.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(BUFFER_POOL,buffer_pool); -VS_GENERIC_QUAD(INGRESS_PRIORITY_GROUP,ingress_priority_group); -VS_GENERIC_QUAD(BUFFER_PROFILE,buffer_profile); -VS_GENERIC_STATS(BUFFER_POOL,buffer_pool); -VS_GENERIC_STATS(INGRESS_PRIORITY_GROUP,ingress_priority_group); - -const sai_buffer_api_t vs_buffer_api = { - - VS_GENERIC_QUAD_API(buffer_pool) - VS_GENERIC_STATS_API(buffer_pool) - VS_GENERIC_QUAD_API(ingress_priority_group) - VS_GENERIC_STATS_API(ingress_priority_group) - VS_GENERIC_QUAD_API(buffer_profile) -}; diff --git a/vslib/sai_vs_counter.cpp b/vslib/sai_vs_counter.cpp deleted file mode 100644 index 105eef7b1..000000000 --- a/vslib/sai_vs_counter.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(COUNTER,counter); -VS_GENERIC_STATS(COUNTER,counter); - -const sai_counter_api_t vs_counter_api = { - - VS_GENERIC_QUAD_API(counter) - VS_GENERIC_STATS_API(counter) -}; - diff --git a/vslib/sai_vs_dash_acl.cpp b/vslib/sai_vs_dash_acl.cpp deleted file mode 100644 index f054d1d15..000000000 --- a/vslib/sai_vs_dash_acl.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(DASH_ACL_GROUP, dash_acl_group); -VS_BULK_CREATE(DASH_ACL_GROUP, dash_acl_groups); -VS_BULK_REMOVE(DASH_ACL_GROUP, dash_acl_groups); - -VS_GENERIC_QUAD(DASH_ACL_RULE, dash_acl_rule); -VS_BULK_CREATE(DASH_ACL_RULE, dash_acl_rules); -VS_BULK_REMOVE(DASH_ACL_RULE, dash_acl_rules); - -const sai_dash_acl_api_t vs_dash_acl_api = { - VS_GENERIC_QUAD_API(dash_acl_group) - vs_bulk_create_dash_acl_groups, - vs_bulk_remove_dash_acl_groups, - - VS_GENERIC_QUAD_API(dash_acl_rule) - vs_bulk_create_dash_acl_rules, - vs_bulk_remove_dash_acl_rules, -}; diff --git a/vslib/sai_vs_dash_direction_lookup.cpp b/vslib/sai_vs_dash_direction_lookup.cpp deleted file mode 100644 index 1bb96c84b..000000000 --- a/vslib/sai_vs_dash_direction_lookup.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry); -VS_BULK_CREATE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); -VS_BULK_REMOVE_ENTRY_EX(DIRECTION_LOOKUP_ENTRY, direction_lookup_entry, direction_lookup_entries); - -const sai_dash_direction_lookup_api_t vs_dash_direction_lookup_api = { - VS_GENERIC_QUAD_API(direction_lookup_entry) - vs_bulk_create_direction_lookup_entries, - vs_bulk_remove_direction_lookup_entries, -}; diff --git a/vslib/sai_vs_dash_eni.cpp b/vslib/sai_vs_dash_eni.cpp deleted file mode 100644 index e79dad959..000000000 --- a/vslib/sai_vs_dash_eni.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry); -VS_BULK_CREATE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); -VS_BULK_REMOVE_ENTRY_EX(ENI_ETHER_ADDRESS_MAP_ENTRY, eni_ether_address_map_entry, eni_ether_address_map_entries); - -VS_GENERIC_QUAD(ENI, eni); -VS_BULK_CREATE(ENI, enis); -VS_BULK_REMOVE(ENI, enis); - -const sai_dash_eni_api_t vs_dash_eni_api = { - VS_GENERIC_QUAD_API(eni_ether_address_map_entry) - vs_bulk_create_eni_ether_address_map_entries, - vs_bulk_remove_eni_ether_address_map_entries, - - VS_GENERIC_QUAD_API(eni) - vs_bulk_create_enis, - vs_bulk_remove_enis, -}; diff --git a/vslib/sai_vs_dash_inbound_routing.cpp b/vslib/sai_vs_dash_inbound_routing.cpp deleted file mode 100644 index a017505df..000000000 --- a/vslib/sai_vs_dash_inbound_routing.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(INBOUND_ROUTING_ENTRY, inbound_routing_entry); -VS_BULK_CREATE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); -VS_BULK_REMOVE_ENTRY_EX(INBOUND_ROUTING_ENTRY, inbound_routing_entry, inbound_routing_entries); - -const sai_dash_inbound_routing_api_t vs_dash_inbound_routing_api = { - VS_GENERIC_QUAD_API(inbound_routing_entry) - vs_bulk_create_inbound_routing_entries, - vs_bulk_remove_inbound_routing_entries, -}; diff --git a/vslib/sai_vs_dash_meter.cpp b/vslib/sai_vs_dash_meter.cpp deleted file mode 100644 index 2773e1f5a..000000000 --- a/vslib/sai_vs_dash_meter.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(METER_BUCKET, meter_bucket); -VS_BULK_CREATE(METER_BUCKET, meter_buckets); -VS_BULK_REMOVE(METER_BUCKET, meter_buckets); - -VS_GENERIC_QUAD(METER_BUCKET, meter_policy); -VS_BULK_CREATE(METER_BUCKET, meter_policys); -VS_BULK_REMOVE(METER_BUCKET, meter_policys); - -VS_GENERIC_QUAD(METER_BUCKET, meter_rule); -VS_BULK_CREATE(METER_BUCKET, meter_rules); -VS_BULK_REMOVE(METER_BUCKET, meter_rules); - -const sai_dash_meter_api_t vs_dash_meter_api = { - - VS_GENERIC_QUAD_API(meter_bucket) - vs_bulk_create_meter_buckets, - vs_bulk_remove_meter_buckets, - - VS_GENERIC_QUAD_API(meter_policy) - vs_bulk_create_meter_policys, - vs_bulk_remove_meter_policys, - - VS_GENERIC_QUAD_API(meter_rule) - vs_bulk_create_meter_rules, - vs_bulk_remove_meter_rules, -}; diff --git a/vslib/sai_vs_dash_outbound_ca_to_pa.cpp b/vslib/sai_vs_dash_outbound_ca_to_pa.cpp deleted file mode 100644 index 5cac21579..000000000 --- a/vslib/sai_vs_dash_outbound_ca_to_pa.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry); -VS_BULK_CREATE_ENTRY_EX(OUTBOUND_CA_TO_PA_ENTRY, outbound_ca_to_pa_entry, outbound_ca_to_pa_entries); -VS_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 vs_dash_outbound_ca_to_pa_api = { - VS_GENERIC_QUAD_API(outbound_ca_to_pa_entry) - vs_bulk_create_outbound_ca_to_pa_entries, - vs_bulk_remove_outbound_ca_to_pa_entries, -}; diff --git a/vslib/sai_vs_dash_outbound_routing.cpp b/vslib/sai_vs_dash_outbound_routing.cpp deleted file mode 100644 index 0582dc767..000000000 --- a/vslib/sai_vs_dash_outbound_routing.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry); -VS_BULK_CREATE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); -VS_BULK_REMOVE_ENTRY_EX(OUTBOUND_ROUTING_ENTRY, outbound_routing_entry, outbound_routing_entries); - -const sai_dash_outbound_routing_api_t vs_dash_outbound_routing_api = { - VS_GENERIC_QUAD_API(outbound_routing_entry) - vs_bulk_create_outbound_routing_entries, - vs_bulk_remove_outbound_routing_entries, -}; diff --git a/vslib/sai_vs_dash_pa_validation.cpp b/vslib/sai_vs_dash_pa_validation.cpp deleted file mode 100644 index 1b66811f1..000000000 --- a/vslib/sai_vs_dash_pa_validation.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(PA_VALIDATION_ENTRY, pa_validation_entry); -VS_BULK_CREATE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); -VS_BULK_REMOVE_ENTRY_EX(PA_VALIDATION_ENTRY, pa_validation_entry, pa_validation_entries); - -const sai_dash_pa_validation_api_t vs_dash_pa_validation_api = { - VS_GENERIC_QUAD_API(pa_validation_entry) - vs_bulk_create_pa_validation_entries, - vs_bulk_remove_pa_validation_entries, -}; diff --git a/vslib/sai_vs_dash_vip.cpp b/vslib/sai_vs_dash_vip.cpp deleted file mode 100644 index f3d4f46b1..000000000 --- a/vslib/sai_vs_dash_vip.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(VIP_ENTRY, vip_entry); -VS_BULK_CREATE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); -VS_BULK_REMOVE_ENTRY_EX(VIP_ENTRY, vip_entry, vip_entries); - -const sai_dash_vip_api_t vs_dash_vip_api = { - VS_GENERIC_QUAD_API(vip_entry) - vs_bulk_create_vip_entries, - vs_bulk_remove_vip_entries, -}; diff --git a/vslib/sai_vs_dash_vnet.cpp b/vslib/sai_vs_dash_vnet.cpp deleted file mode 100644 index 83cd9973d..000000000 --- a/vslib/sai_vs_dash_vnet.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(VNET, vnet); -VS_BULK_CREATE(VNET, vnets); -VS_BULK_REMOVE(VNET, vnets); - -const sai_dash_vnet_api_t vs_dash_vnet_api = { - VS_GENERIC_QUAD_API(vnet) - vs_bulk_create_vnets, - vs_bulk_remove_vnets, -}; diff --git a/vslib/sai_vs_debug_counter.cpp b/vslib/sai_vs_debug_counter.cpp deleted file mode 100644 index 3dbd346f5..000000000 --- a/vslib/sai_vs_debug_counter.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(DEBUG_COUNTER,debug_counter); - -const sai_debug_counter_api_t vs_debug_counter_api = { - VS_GENERIC_QUAD_API(debug_counter) -}; diff --git a/vslib/sai_vs_dtel.cpp b/vslib/sai_vs_dtel.cpp deleted file mode 100644 index b1919d9be..000000000 --- a/vslib/sai_vs_dtel.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(DTEL,dtel); -VS_GENERIC_QUAD(DTEL_QUEUE_REPORT,dtel_queue_report); -VS_GENERIC_QUAD(DTEL_INT_SESSION,dtel_int_session); -VS_GENERIC_QUAD(DTEL_REPORT_SESSION,dtel_report_session); -VS_GENERIC_QUAD(DTEL_EVENT,dtel_event); - -const sai_dtel_api_t vs_dtel_api = { - - VS_GENERIC_QUAD_API(dtel) - VS_GENERIC_QUAD_API(dtel_queue_report) - VS_GENERIC_QUAD_API(dtel_int_session) - VS_GENERIC_QUAD_API(dtel_report_session) - VS_GENERIC_QUAD_API(dtel_event) -}; diff --git a/vslib/sai_vs_fdb.cpp b/vslib/sai_vs_fdb.cpp deleted file mode 100644 index 58a2cf8b9..000000000 --- a/vslib/sai_vs_fdb.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "sai_vs.h" - -static sai_status_t vs_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 vs_sai->flushFdbEntries( - switch_id, - attr_count, - attr_list); -} - -VS_GENERIC_QUAD_ENTRY(FDB_ENTRY,fdb_entry); -VS_BULK_QUAD_ENTRY(FDB_ENTRY, fdb_entry); - -const sai_fdb_api_t vs_fdb_api = { - - VS_GENERIC_QUAD_API(fdb_entry) - - vs_flush_fdb_entries, - - VS_BULK_QUAD_API(fdb_entry) -}; diff --git a/vslib/sai_vs_genericprogrammable.cpp b/vslib/sai_vs_genericprogrammable.cpp deleted file mode 100644 index 958d927a8..000000000 --- a/vslib/sai_vs_genericprogrammable.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(GENERIC_PROGRAMMABLE,generic_programmable); - -const sai_generic_programmable_api_t vs_generic_programmable_api = { - VS_GENERIC_QUAD_API(generic_programmable) -}; diff --git a/vslib/sai_vs_hash.cpp b/vslib/sai_vs_hash.cpp deleted file mode 100644 index d7f6e1c89..000000000 --- a/vslib/sai_vs_hash.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(HASH,hash); -VS_GENERIC_QUAD(FINE_GRAINED_HASH_FIELD,fine_grained_hash_field); - -const sai_hash_api_t vs_hash_api = { - VS_GENERIC_QUAD_API(hash) - VS_GENERIC_QUAD_API(fine_grained_hash_field) -}; diff --git a/vslib/sai_vs_hostif.cpp b/vslib/sai_vs_hostif.cpp deleted file mode 100644 index 2a35c2bef..000000000 --- a/vslib/sai_vs_hostif.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "sai_vs.h" - -static sai_status_t vs_recv_hostif_packet( - _In_ sai_object_id_t hif_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 vs_send_hostif_packet( - _In_ sai_object_id_t hif_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 vs_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 vs_free_hostif_packet( - _In_ sai_object_id_t hostif_id, - _Inout_ void *buffer) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_GENERIC_QUAD(HOSTIF,hostif); -VS_GENERIC_QUAD(HOSTIF_TABLE_ENTRY,hostif_table_entry); -VS_GENERIC_QUAD(HOSTIF_TRAP_GROUP,hostif_trap_group); -VS_GENERIC_QUAD(HOSTIF_TRAP,hostif_trap); -VS_GENERIC_QUAD(HOSTIF_USER_DEFINED_TRAP,hostif_user_defined_trap); - -const sai_hostif_api_t vs_hostif_api = { - - VS_GENERIC_QUAD_API(hostif) - VS_GENERIC_QUAD_API(hostif_table_entry) - VS_GENERIC_QUAD_API(hostif_trap_group) - VS_GENERIC_QUAD_API(hostif_trap) - VS_GENERIC_QUAD_API(hostif_user_defined_trap) - - vs_recv_hostif_packet, - vs_send_hostif_packet, - vs_allocate_hostif_packet, - vs_free_hostif_packet, -}; diff --git a/vslib/sai_vs_interfacequery.cpp b/vslib/sai_vs_interfacequery.cpp deleted file mode 100644 index 338e0298c..000000000 --- a/vslib/sai_vs_interfacequery.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "sai_vs.h" -#include "Sai.h" - -std::shared_ptr vs_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 vs_sai->initialize(flags, service_method_table); -} - -sai_status_t sai_api_uninitialize(void) -{ - SWSS_LOG_ENTER(); - - return vs_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(&vs_ ## api ## _api) - -static sai_apis_t vs_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(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**)&vs_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 vs_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 vs_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 vs_sai->objectTypeGetAvailability( - switch_id, - object_type, - attr_count, - attr_list, - count); -} - -sai_status_t sai_dbg_generate_dump( - _In_ const char *dump_file_name) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -sai_object_type_t sai_object_type_query( - _In_ sai_object_id_t objectId) -{ - SWSS_LOG_ENTER(); - - return vs_sai->objectTypeQuery(objectId); -} - -sai_object_id_t sai_switch_id_query( - _In_ sai_object_id_t objectId) -{ - SWSS_LOG_ENTER(); - - return vs_sai->switchIdQuery(objectId); -} - -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(); - - return vs_sai->queryStatsCapability(switch_id, object_type, stats_capability); -} - -sai_status_t sai_query_api_version( - _Out_ sai_api_version_t *version) -{ - SWSS_LOG_ENTER(); - - *version = SAI_API_VERSION; - return SAI_STATUS_SUCCESS; -} - -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(); - - 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(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} diff --git a/vslib/sai_vs_ipmc.cpp b/vslib/sai_vs_ipmc.cpp deleted file mode 100644 index 9d7adf152..000000000 --- a/vslib/sai_vs_ipmc.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(IPMC_ENTRY,ipmc_entry); - -const sai_ipmc_api_t vs_ipmc_api = { - - VS_GENERIC_QUAD_API(ipmc_entry) -}; diff --git a/vslib/sai_vs_ipmc_group.cpp b/vslib/sai_vs_ipmc_group.cpp deleted file mode 100644 index c8bfc3b74..000000000 --- a/vslib/sai_vs_ipmc_group.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(IPMC_GROUP,ipmc_group); -VS_GENERIC_QUAD(IPMC_GROUP_MEMBER,ipmc_group_member); - -const sai_ipmc_group_api_t vs_ipmc_group_api = { - - VS_GENERIC_QUAD_API(ipmc_group) - VS_GENERIC_QUAD_API(ipmc_group_member) -}; diff --git a/vslib/sai_vs_ipsec.cpp b/vslib/sai_vs_ipsec.cpp deleted file mode 100644 index fe4255a0e..000000000 --- a/vslib/sai_vs_ipsec.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(IPSEC,ipsec); -VS_GENERIC_QUAD(IPSEC_PORT,ipsec_port); -VS_GENERIC_QUAD(IPSEC_SA,ipsec_sa); -VS_GENERIC_STATS(IPSEC_PORT,ipsec_port); -VS_GENERIC_STATS(IPSEC_SA,ipsec_sa); - -const sai_ipsec_api_t vs_ipsec_api = { - - VS_GENERIC_QUAD_API(ipsec) - VS_GENERIC_QUAD_API(ipsec_port) - VS_GENERIC_STATS_API(ipsec_port) - VS_GENERIC_QUAD_API(ipsec_sa) - VS_GENERIC_STATS_API(ipsec_sa) -}; diff --git a/vslib/sai_vs_isolation_group.cpp b/vslib/sai_vs_isolation_group.cpp deleted file mode 100644 index 8b6347a53..000000000 --- a/vslib/sai_vs_isolation_group.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(ISOLATION_GROUP,isolation_group); -VS_GENERIC_QUAD(ISOLATION_GROUP_MEMBER,isolation_group_member); - -const sai_isolation_group_api_t vs_isolation_group_api = { - - VS_GENERIC_QUAD_API(isolation_group) - VS_GENERIC_QUAD_API(isolation_group_member) -}; - diff --git a/vslib/sai_vs_l2mc.cpp b/vslib/sai_vs_l2mc.cpp deleted file mode 100644 index 4446913a3..000000000 --- a/vslib/sai_vs_l2mc.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(L2MC_ENTRY,l2mc_entry); - -const sai_l2mc_api_t vs_l2mc_api = { - - VS_GENERIC_QUAD_API(l2mc_entry) -}; diff --git a/vslib/sai_vs_l2mcgroup.cpp b/vslib/sai_vs_l2mcgroup.cpp deleted file mode 100644 index f91527395..000000000 --- a/vslib/sai_vs_l2mcgroup.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(L2MC_GROUP,l2mc_group); -VS_GENERIC_QUAD(L2MC_GROUP_MEMBER,l2mc_group_member); - -const sai_l2mc_group_api_t vs_l2mc_group_api = { - - VS_GENERIC_QUAD_API(l2mc_group) - VS_GENERIC_QUAD_API(l2mc_group_member) -}; diff --git a/vslib/sai_vs_lag.cpp b/vslib/sai_vs_lag.cpp deleted file mode 100644 index ee8c540a3..000000000 --- a/vslib/sai_vs_lag.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_CREATE(LAG_MEMBER,lag_members); -VS_BULK_REMOVE(LAG_MEMBER,lag_members); - -VS_GENERIC_QUAD(LAG,lag); -VS_GENERIC_QUAD(LAG_MEMBER,lag_member); - -const sai_lag_api_t vs_lag_api = { - - VS_GENERIC_QUAD_API(lag) - VS_GENERIC_QUAD_API(lag_member) - - vs_bulk_create_lag_members, - vs_bulk_remove_lag_members, -}; diff --git a/vslib/sai_vs_macsec.cpp b/vslib/sai_vs_macsec.cpp deleted file mode 100644 index 690eba30e..000000000 --- a/vslib/sai_vs_macsec.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(MACSEC,macsec); - -VS_GENERIC_QUAD(MACSEC_PORT,macsec_port); -VS_GENERIC_STATS(MACSEC_PORT,macsec_port); - -VS_GENERIC_QUAD(MACSEC_FLOW,macsec_flow); -VS_GENERIC_STATS(MACSEC_FLOW,macsec_flow); - -VS_GENERIC_QUAD(MACSEC_SC,macsec_sc); -VS_GENERIC_STATS(MACSEC_SC,macsec_sc); - -VS_GENERIC_QUAD(MACSEC_SA,macsec_sa); -VS_GENERIC_STATS(MACSEC_SA,macsec_sa); - -const sai_macsec_api_t vs_macsec_api = { - - VS_GENERIC_QUAD_API(macsec) - - VS_GENERIC_QUAD_API(macsec_port) - VS_GENERIC_STATS_API(macsec_port) - - VS_GENERIC_QUAD_API(macsec_flow) - VS_GENERIC_STATS_API(macsec_flow) - - VS_GENERIC_QUAD_API(macsec_sc) - VS_GENERIC_STATS_API(macsec_sc) - - VS_GENERIC_QUAD_API(macsec_sa) - VS_GENERIC_STATS_API(macsec_sa) -}; diff --git a/vslib/sai_vs_mcastfdb.cpp b/vslib/sai_vs_mcastfdb.cpp deleted file mode 100644 index d400287e9..000000000 --- a/vslib/sai_vs_mcastfdb.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(MCAST_FDB_ENTRY,mcast_fdb_entry); - -const sai_mcast_fdb_api_t vs_mcast_fdb_api = { - - VS_GENERIC_QUAD_API(mcast_fdb_entry) -}; diff --git a/vslib/sai_vs_mirror.cpp b/vslib/sai_vs_mirror.cpp deleted file mode 100644 index 757c8c430..000000000 --- a/vslib/sai_vs_mirror.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(MIRROR_SESSION,mirror_session); - -const sai_mirror_api_t vs_mirror_api = { - - VS_GENERIC_QUAD_API(mirror_session) -}; diff --git a/vslib/sai_vs_mpls.cpp b/vslib/sai_vs_mpls.cpp deleted file mode 100644 index 2058c4e48..000000000 --- a/vslib/sai_vs_mpls.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); -VS_BULK_QUAD_ENTRY(INSEG_ENTRY,inseg_entry); - -const sai_mpls_api_t vs_mpls_api = { - - VS_GENERIC_QUAD_API(inseg_entry) - VS_BULK_QUAD_API(inseg_entry) -}; diff --git a/vslib/sai_vs_my_mac.cpp b/vslib/sai_vs_my_mac.cpp deleted file mode 100644 index a159602e1..000000000 --- a/vslib/sai_vs_my_mac.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(IPSEC,my_mac); - -const sai_my_mac_api_t vs_my_mac_api = { - - VS_GENERIC_QUAD_API(my_mac) -}; diff --git a/vslib/sai_vs_nat.cpp b/vslib/sai_vs_nat.cpp deleted file mode 100644 index 68eb708aa..000000000 --- a/vslib/sai_vs_nat.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_QUAD_ENTRY(NAT_ENTRY,nat_entry); - -VS_GENERIC_QUAD_ENTRY(NAT_ENTRY,nat_entry); -VS_GENERIC_QUAD(NAT_ZONE_COUNTER,nat_zone_counter); - -const sai_nat_api_t vs_nat_api = { - - VS_GENERIC_QUAD_API(nat_entry) - - VS_BULK_QUAD_API(nat_entry) - - VS_GENERIC_QUAD_API(nat_zone_counter) -}; diff --git a/vslib/sai_vs_neighbor.cpp b/vslib/sai_vs_neighbor.cpp deleted file mode 100644 index 7049967c8..000000000 --- a/vslib/sai_vs_neighbor.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "sai_vs.h" - -static sai_status_t vs_remove_all_neighbor_entries( - _In_ sai_object_id_t switch_id) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_BULK_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); -VS_GENERIC_QUAD_ENTRY(NEIGHBOR_ENTRY,neighbor_entry); - -const sai_neighbor_api_t vs_neighbor_api = { - - VS_GENERIC_QUAD_API(neighbor_entry) - - vs_remove_all_neighbor_entries, - - VS_BULK_QUAD_API(neighbor_entry) -}; diff --git a/vslib/sai_vs_nexthop.cpp b/vslib/sai_vs_nexthop.cpp deleted file mode 100644 index fdab7ab0e..000000000 --- a/vslib/sai_vs_nexthop.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(NEXT_HOP,next_hop); -VS_BULK_QUAD(NEXT_HOP,next_hop); - -const sai_next_hop_api_t vs_next_hop_api = { - - VS_GENERIC_QUAD_API(next_hop) - VS_BULK_QUAD_API(next_hop) -}; diff --git a/vslib/sai_vs_nexthopgroup.cpp b/vslib/sai_vs_nexthopgroup.cpp deleted file mode 100644 index f3881f825..000000000 --- a/vslib/sai_vs_nexthopgroup.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_CREATE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -VS_BULK_REMOVE(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -VS_BULK_GET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); -VS_BULK_SET(NEXT_HOP_GROUP_MEMBER,next_hop_group_members); - -VS_GENERIC_QUAD(NEXT_HOP_GROUP,next_hop_group); -VS_GENERIC_QUAD(NEXT_HOP_GROUP_MEMBER,next_hop_group_member); -VS_GENERIC_QUAD(NEXT_HOP_GROUP_MAP,next_hop_group_map); - -const sai_next_hop_group_api_t vs_next_hop_group_api = { - - VS_GENERIC_QUAD_API(next_hop_group) - VS_GENERIC_QUAD_API(next_hop_group_member) - - vs_bulk_create_next_hop_group_members, - vs_bulk_remove_next_hop_group_members, - VS_GENERIC_QUAD_API(next_hop_group_map) - vs_bulk_set_next_hop_group_members, - vs_bulk_get_next_hop_group_members -}; diff --git a/vslib/sai_vs_policer.cpp b/vslib/sai_vs_policer.cpp deleted file mode 100644 index a4ce3d3e8..000000000 --- a/vslib/sai_vs_policer.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(POLICER,policer); -VS_GENERIC_STATS(POLICER,policer); - -const sai_policer_api_t vs_policer_api = { - - VS_GENERIC_QUAD_API(policer) - VS_GENERIC_STATS_API(policer) -}; diff --git a/vslib/sai_vs_port.cpp b/vslib/sai_vs_port.cpp deleted file mode 100644 index 54e4a7116..000000000 --- a/vslib/sai_vs_port.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "sai_vs.h" - -static sai_status_t vs_clear_port_all_stats( - _In_ sai_object_id_t port_id) -{ - SWSS_LOG_ENTER(); - - return SAI_STATUS_NOT_IMPLEMENTED; -} - -VS_GENERIC_QUAD(PORT,port); -VS_GENERIC_QUAD(PORT_POOL,port_pool); -VS_GENERIC_QUAD(PORT_CONNECTOR,port_connector); -VS_GENERIC_QUAD(PORT_SERDES,port_serdes); -VS_GENERIC_STATS(PORT,port); -VS_GENERIC_STATS(PORT_POOL,port_pool); -VS_BULK_QUAD(PORT,ports); -VS_BULK_QUAD(PORT_SERDES, port_serdeses); - -const sai_port_api_t vs_port_api = { - - VS_GENERIC_QUAD_API(port) - VS_GENERIC_STATS_API(port) - - vs_clear_port_all_stats, - - VS_GENERIC_QUAD_API(port_pool) - VS_GENERIC_STATS_API(port_pool) - - VS_GENERIC_QUAD_API(port_connector) - - VS_GENERIC_QUAD_API(port_serdes) - VS_BULK_QUAD_API(ports) - VS_BULK_QUAD_API(port_serdeses) -}; diff --git a/vslib/sai_vs_qosmap.cpp b/vslib/sai_vs_qosmap.cpp deleted file mode 100644 index 802c3b82d..000000000 --- a/vslib/sai_vs_qosmap.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(QOS_MAP,qos_map); - -const sai_qos_map_api_t vs_qos_map_api = { - - VS_GENERIC_QUAD_API(qos_map) -}; diff --git a/vslib/sai_vs_queue.cpp b/vslib/sai_vs_queue.cpp deleted file mode 100644 index 75ab91ada..000000000 --- a/vslib/sai_vs_queue.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(QUEUE,queue); -VS_GENERIC_STATS(QUEUE,queue); - -const sai_queue_api_t vs_queue_api = { - - VS_GENERIC_QUAD_API(queue) - VS_GENERIC_STATS_API(queue) -}; diff --git a/vslib/sai_vs_route.cpp b/vslib/sai_vs_route.cpp deleted file mode 100644 index 0f5698020..000000000 --- a/vslib/sai_vs_route.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD_ENTRY(ROUTE_ENTRY,route_entry); - -VS_BULK_QUAD_ENTRY(ROUTE_ENTRY,route_entry); - -const sai_route_api_t vs_route_api = { - - VS_GENERIC_QUAD_API(route_entry) - VS_BULK_QUAD_API(route_entry) -}; diff --git a/vslib/sai_vs_router_interface.cpp b/vslib/sai_vs_router_interface.cpp deleted file mode 100644 index df8bfeaa2..000000000 --- a/vslib/sai_vs_router_interface.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(ROUTER_INTERFACE,router_interface); -VS_GENERIC_STATS(ROUTER_INTERFACE,router_interface); -VS_BULK_QUAD(ROUTER_INTERFACE,router_interfaces); - -const sai_router_interface_api_t vs_router_interface_api = { - - VS_GENERIC_QUAD_API(router_interface) - VS_GENERIC_STATS_API(router_interface) - VS_BULK_QUAD_API(router_interfaces) -}; diff --git a/vslib/sai_vs_rpfgroup.cpp b/vslib/sai_vs_rpfgroup.cpp deleted file mode 100644 index 7096c19de..000000000 --- a/vslib/sai_vs_rpfgroup.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(RPF_GROUP,rpf_group); -VS_GENERIC_QUAD(RPF_GROUP_MEMBER,rpf_group_member); - -const sai_rpf_group_api_t vs_rpf_group_api = { - - VS_GENERIC_QUAD_API(rpf_group) - VS_GENERIC_QUAD_API(rpf_group_member) -}; diff --git a/vslib/sai_vs_samplepacket.cpp b/vslib/sai_vs_samplepacket.cpp deleted file mode 100644 index 36d944b82..000000000 --- a/vslib/sai_vs_samplepacket.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(SAMPLEPACKET,samplepacket); - -const sai_samplepacket_api_t vs_samplepacket_api = { - - VS_GENERIC_QUAD_API(samplepacket) -}; diff --git a/vslib/sai_vs_scheduler.cpp b/vslib/sai_vs_scheduler.cpp deleted file mode 100644 index 54f3ce5eb..000000000 --- a/vslib/sai_vs_scheduler.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(SCHEDULER,scheduler); - -const sai_scheduler_api_t vs_scheduler_api = { - - VS_GENERIC_QUAD_API(scheduler) -}; diff --git a/vslib/sai_vs_schedulergroup.cpp b/vslib/sai_vs_schedulergroup.cpp deleted file mode 100644 index ad7e12ec8..000000000 --- a/vslib/sai_vs_schedulergroup.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(SCHEDULER_GROUP,scheduler_group); - -const sai_scheduler_group_api_t vs_scheduler_group_api = { - - VS_GENERIC_QUAD_API(scheduler_group) -}; diff --git a/vslib/sai_vs_srv6.cpp b/vslib/sai_vs_srv6.cpp deleted file mode 100644 index 8d669251f..000000000 --- a/vslib/sai_vs_srv6.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_CREATE(SRV6_SIDLIST,srv6_sidlists); -VS_BULK_REMOVE(SRV6_SIDLIST,srv6_sidlists); - -VS_GENERIC_QUAD(SRV6_SIDLIST,srv6_sidlist); - -VS_GENERIC_QUAD_ENTRY(MY_SID_ENTRY, my_sid_entry); -VS_BULK_QUAD_ENTRY(MY_SID_ENTRY, my_sid_entry); - -const sai_srv6_api_t vs_srv6_api = { - - VS_GENERIC_QUAD_API(srv6_sidlist) - - vs_bulk_create_srv6_sidlists, - vs_bulk_remove_srv6_sidlists, - - NULL, - NULL, - NULL, - - VS_GENERIC_QUAD_API(my_sid_entry) - VS_BULK_QUAD_API(my_sid_entry) -}; diff --git a/vslib/sai_vs_stp.cpp b/vslib/sai_vs_stp.cpp deleted file mode 100644 index 5a478e81c..000000000 --- a/vslib/sai_vs_stp.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_CREATE(STP_PORT,stp_ports); -VS_BULK_REMOVE(STP_PORT,stp_ports); - -VS_GENERIC_QUAD(STP,stp); -VS_GENERIC_QUAD(STP_PORT,stp_port); - -const sai_stp_api_t vs_stp_api = { - - VS_GENERIC_QUAD_API(stp) - VS_GENERIC_QUAD_API(stp_port) - - vs_bulk_create_stp_ports, - vs_bulk_remove_stp_ports, -}; diff --git a/vslib/sai_vs_switch.cpp b/vslib/sai_vs_switch.cpp deleted file mode 100644 index 3ef226426..000000000 --- a/vslib/sai_vs_switch.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(SWITCH,switch); -VS_GENERIC_STATS(SWITCH,switch); -VS_GENERIC_QUAD(SWITCH_TUNNEL,switch_tunnel); - -static sai_status_t vs_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 vs_create_switch( - switch_id, - SAI_NULL_OBJECT_ID, // no switch id since we create switch - attr_count, - attr_list); -} - -static sai_status_t vs_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 vs_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 vs_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 vs_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; -} - -const sai_switch_api_t vs_switch_api = { - - vs_create_switch_uniq, - vs_remove_switch, - vs_set_switch_attribute, - vs_get_switch_attribute, - - VS_GENERIC_STATS_API(switch) - - vs_switch_mdio_read, - vs_switch_mdio_write, - - VS_GENERIC_QUAD_API(switch_tunnel) - vs_switch_mdio_cl22_read, - vs_switch_mdio_cl22_write -}; diff --git a/vslib/sai_vs_system_port.cpp b/vslib/sai_vs_system_port.cpp deleted file mode 100644 index 20b0243f4..000000000 --- a/vslib/sai_vs_system_port.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(SYSTEM_PORT,system_port); - -const sai_system_port_api_t vs_system_port_api = { - - VS_GENERIC_QUAD_API(system_port) -}; diff --git a/vslib/sai_vs_tam.cpp b/vslib/sai_vs_tam.cpp deleted file mode 100644 index 3376cda91..000000000 --- a/vslib/sai_vs_tam.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "sai_vs.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; -} - -VS_GENERIC_QUAD(TAM,tam); -VS_GENERIC_QUAD(TAM_MATH_FUNC,tam_math_func); -VS_GENERIC_QUAD(TAM_REPORT,tam_report); -VS_GENERIC_QUAD(TAM_EVENT_THRESHOLD,tam_event_threshold); -VS_GENERIC_QUAD(TAM_INT,tam_int); -VS_GENERIC_QUAD(TAM_TEL_TYPE,tam_tel_type); -VS_GENERIC_QUAD(TAM_TRANSPORT,tam_transport); -VS_GENERIC_QUAD(TAM_TELEMETRY,tam_telemetry); -VS_GENERIC_QUAD(TAM_COLLECTOR,tam_collector); -VS_GENERIC_QUAD(TAM_EVENT_ACTION,tam_event_action); -VS_GENERIC_QUAD(TAM_EVENT,tam_event); - -const sai_tam_api_t vs_tam_api = { - - VS_GENERIC_QUAD_API(tam) - VS_GENERIC_QUAD_API(tam_math_func) - VS_GENERIC_QUAD_API(tam_report) - VS_GENERIC_QUAD_API(tam_event_threshold) - VS_GENERIC_QUAD_API(tam_int) - VS_GENERIC_QUAD_API(tam_tel_type) - VS_GENERIC_QUAD_API(tam_transport) - VS_GENERIC_QUAD_API(tam_telemetry) - VS_GENERIC_QUAD_API(tam_collector) - VS_GENERIC_QUAD_API(tam_event_action) - VS_GENERIC_QUAD_API(tam_event) - -}; diff --git a/vslib/sai_vs_tunnel.cpp b/vslib/sai_vs_tunnel.cpp deleted file mode 100644 index e7b522a08..000000000 --- a/vslib/sai_vs_tunnel.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(TUNNEL_MAP,tunnel_map); -VS_GENERIC_QUAD(TUNNEL,tunnel); -VS_GENERIC_QUAD(TUNNEL_TERM_TABLE_ENTRY,tunnel_term_table_entry); -VS_GENERIC_QUAD(TUNNEL_MAP_ENTRY,tunnel_map_entry); -VS_GENERIC_STATS(TUNNEL,tunnel); -VS_BULK_QUAD(TUNNEL,tunnels); - -const sai_tunnel_api_t vs_tunnel_api = { - - VS_GENERIC_QUAD_API(tunnel_map) - VS_GENERIC_QUAD_API(tunnel) - VS_GENERIC_STATS_API(tunnel) - VS_GENERIC_QUAD_API(tunnel_term_table_entry) - VS_GENERIC_QUAD_API(tunnel_map_entry) - VS_BULK_QUAD_API(tunnels) -}; diff --git a/vslib/sai_vs_twamp.cpp b/vslib/sai_vs_twamp.cpp deleted file mode 100644 index 5a62b790a..000000000 --- a/vslib/sai_vs_twamp.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(TWAMP_SESSION,twamp_session); -VS_GENERIC_STATS(TWAMP_SESSION,twamp_session); - -const sai_twamp_api_t vs_twamp_api = { - VS_GENERIC_QUAD_API(twamp_session) - VS_GENERIC_STATS_API(twamp_session) -}; diff --git a/vslib/sai_vs_udf.cpp b/vslib/sai_vs_udf.cpp deleted file mode 100644 index 0f4f108d9..000000000 --- a/vslib/sai_vs_udf.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(UDF,udf) -VS_GENERIC_QUAD(UDF_MATCH,udf_match) -VS_GENERIC_QUAD(UDF_GROUP,udf_group) - -const sai_udf_api_t vs_udf_api = { - - VS_GENERIC_QUAD_API(udf) - VS_GENERIC_QUAD_API(udf_match) - VS_GENERIC_QUAD_API(udf_group) -}; diff --git a/vslib/sai_vs_virtual_router.cpp b/vslib/sai_vs_virtual_router.cpp deleted file mode 100644 index cb3c05e9c..000000000 --- a/vslib/sai_vs_virtual_router.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(VIRTUAL_ROUTER,virtual_router); - -const sai_virtual_router_api_t vs_virtual_router_api = { - - VS_GENERIC_QUAD_API(virtual_router) -}; diff --git a/vslib/sai_vs_vlan.cpp b/vslib/sai_vs_vlan.cpp deleted file mode 100644 index 8395f4027..000000000 --- a/vslib/sai_vs_vlan.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sai_vs.h" - -VS_BULK_CREATE(VLAN_MEMBER,vlan_members); -VS_BULK_REMOVE(VLAN_MEMBER,vlan_members); - -VS_GENERIC_QUAD(VLAN,vlan); -VS_GENERIC_QUAD(VLAN_MEMBER,vlan_member); -VS_GENERIC_STATS(VLAN,vlan); - -const sai_vlan_api_t vs_vlan_api = { - - VS_GENERIC_QUAD_API(vlan) - VS_GENERIC_QUAD_API(vlan_member) - - vs_bulk_create_vlan_members, - vs_bulk_remove_vlan_members, - - VS_GENERIC_STATS_API(vlan) -}; diff --git a/vslib/sai_vs_wred.cpp b/vslib/sai_vs_wred.cpp deleted file mode 100644 index d02b0bb2d..000000000 --- a/vslib/sai_vs_wred.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "sai_vs.h" - -VS_GENERIC_QUAD(WRED,wred); - -const sai_wred_api_t vs_wred_api = { - - VS_GENERIC_QUAD_API(wred) -};