From aac29693394efd1ab43f233097bff553dc3c7751 Mon Sep 17 00:00:00 2001 From: kcudnik Date: Sun, 24 Nov 2024 20:30:29 +0100 Subject: [PATCH] Propagate m_vpp over classes --- vslib/HostInterfaceInfo.cpp | 10 +++--- vslib/HostInterfaceInfo.h | 5 ++- vslib/MACsecForwarder.cpp | 5 +-- vslib/MACsecForwarder.h | 3 +- vslib/MACsecManager.cpp | 10 +++++- vslib/MACsecManager.h | 5 +++ vslib/Makefile.am | 14 ++++++--- vslib/Sai.cpp | 8 ++++- vslib/SwitchConfig.cpp | 28 ++++++++++++++++- vslib/SwitchConfig.h | 7 +++++ vslib/SwitchStateBase.cpp | 42 +++++++++++++++----------- vslib/SwitchStateBase.h | 8 +++-- vslib/SwitchStateBaseHostif.cpp | 31 ++++++++++--------- vslib/SwitchStateBaseMACsec.cpp | 4 +-- vslib/VirtualSwitchSaiInterface.cpp | 14 +++++---- vslib/VirtualSwitchSaiInterface.h | 5 ++- vslib/VirtualSwitchSaiInterfaceFdb.cpp | 6 ++-- vslib/saivs.h | 13 ++++++++ 18 files changed, 152 insertions(+), 66 deletions(-) diff --git a/vslib/HostInterfaceInfo.cpp b/vslib/HostInterfaceInfo.cpp index cbd7189af..3cf4fa7ca 100644 --- a/vslib/HostInterfaceInfo.cpp +++ b/vslib/HostInterfaceInfo.cpp @@ -22,8 +22,6 @@ #include #include -extern bool g_vpp; - using namespace saivs; HostInterfaceInfo::HostInterfaceInfo( @@ -32,19 +30,21 @@ HostInterfaceInfo::HostInterfaceInfo( _In_ int tapfd, _In_ const std::string& tapname, _In_ sai_object_id_t portId, - _In_ std::shared_ptr eventQueue): + _In_ std::shared_ptr eventQueue, + _In_ bool vpp): m_ifindex(ifindex), m_packet_socket(socket), m_name(tapname), m_portId(portId), m_eventQueue(eventQueue), - m_tapfd(tapfd) + m_tapfd(tapfd), + m_vpp(vpp) { SWSS_LOG_ENTER(); m_run_thread = true; - if (g_vpp) // VPP + if (m_vpp) // VPP { // threads are disabled for vpp return; diff --git a/vslib/HostInterfaceInfo.h b/vslib/HostInterfaceInfo.h index 9d6da9a3d..de47679b5 100644 --- a/vslib/HostInterfaceInfo.h +++ b/vslib/HostInterfaceInfo.h @@ -31,7 +31,8 @@ namespace saivs _In_ int tapfd, _In_ const std::string& tapname, _In_ sai_object_id_t portId, - _In_ std::shared_ptr eventQueue); + _In_ std::shared_ptr eventQueue, + _In_ bool vpp); virtual ~HostInterfaceInfo(); @@ -87,5 +88,7 @@ namespace saivs swss::SelectableEvent m_e2tEvent; swss::SelectableEvent m_t2eEvent; + + bool m_vpp; }; } diff --git a/vslib/MACsecForwarder.cpp b/vslib/MACsecForwarder.cpp index 6cfcce3b8..3995bbf29 100644 --- a/vslib/MACsecForwarder.cpp +++ b/vslib/MACsecForwarder.cpp @@ -16,7 +16,8 @@ using namespace saivs; MACsecForwarder::MACsecForwarder( _In_ const std::string &macsecInterfaceName, - _In_ std::shared_ptr info): + _In_ std::shared_ptr info, + _In_ bool vpp): m_macsecInterfaceName(macsecInterfaceName), m_runThread(true), m_info(info) @@ -53,7 +54,7 @@ MACsecForwarder::MACsecForwarder( m_macsecInterfaceName.c_str()); } - if (SwitchStateBase::promisc(m_macsecInterfaceName.c_str())) + if (SwitchStateBase::promisc(m_macsecInterfaceName.c_str(), vpp)) { close(m_macsecfd); SWSS_LOG_THROW( diff --git a/vslib/MACsecForwarder.h b/vslib/MACsecForwarder.h index 0ca3b1c7b..21d4f543f 100644 --- a/vslib/MACsecForwarder.h +++ b/vslib/MACsecForwarder.h @@ -19,7 +19,8 @@ namespace saivs MACsecForwarder( _In_ const std::string &macsecInterfaceName, - _In_ std::shared_ptr info); + _In_ std::shared_ptr info, + _In_ bool vpp); virtual ~MACsecForwarder(); diff --git a/vslib/MACsecManager.cpp b/vslib/MACsecManager.cpp index 0324c1b48..abee10975 100644 --- a/vslib/MACsecManager.cpp +++ b/vslib/MACsecManager.cpp @@ -621,7 +621,7 @@ bool MACsecManager::add_macsec_forwarder( auto &manager = itr->second; - manager.m_forwarder = std::make_shared(macsecInterface, manager.m_info); + manager.m_forwarder = std::make_shared(macsecInterface, manager.m_info, m_vpp); return true; } @@ -957,3 +957,11 @@ bool MACsecManager::exec( return exec(command, res); } + +void MACsecManager::setVpp( + _In_ bool vpp) +{ + SWSS_LOG_ENTER(); + + m_vpp = vpp; +} diff --git a/vslib/MACsecManager.h b/vslib/MACsecManager.h index 8305f21c4..8fba0b750 100644 --- a/vslib/MACsecManager.h +++ b/vslib/MACsecManager.h @@ -46,6 +46,9 @@ namespace saivs void cleanup_macsec_device() const; + void setVpp( + _In_ bool vpp); + protected: bool create_macsec_egress_sc( @@ -143,5 +146,7 @@ namespace saivs }; std::map m_macsecTrafficManagers; + + bool m_vpp = false; }; } diff --git a/vslib/Makefile.am b/vslib/Makefile.am index 36ccd1f4f..c21c244a3 100644 --- a/vslib/Makefile.am +++ b/vslib/Makefile.am @@ -1,14 +1,16 @@ AM_CXXFLAGS = $(SAIINC) -I$(top_srcdir)/lib -I/usr/include/libnl3 +AM_CFLAGS = -I/usr/include/vpp_plugins -fPIC -I. -I.. -I../../ -I../../../ lib_LTLIBRARIES = libsaivs.la noinst_LIBRARIES = libSaiVS.a +#vppxlate/SaiVppXlate.c \ +# vppxlate/SaiVppStats.c \ +# vppxlate/SaiAclStats.c \ +# vppxlate/SaiIntfStats.c + libSaiVS_a_SOURCES = \ - vppxlate/SaiAclStats.c \ - vppxlate/SaiIntfStats.c \ - vppxlate/SaiVppStats.c \ - vppxlate/SaiVppXlate.c \ Buffer.cpp \ ContextConfigContainer.cpp \ ContextConfig.cpp \ @@ -84,6 +86,8 @@ sai_vs.cpp: ../stub.pl $(top_srcdir)/SAI/meta/saimetadata.c clean-local: rm -f sai_vs.cpp +VPP_LIBS = -lvlibapi -lvapiclient -lvppapiclient -lvlibmemoryclient -lsvm -lvppinfra -lvlib -lvatplugin + libsaivs_la_SOURCES = sai_vs.cpp libSaiVS_a_CPPFLAGS = $(CODE_COVERAGE_CPPFLAGS) @@ -97,6 +101,6 @@ bin_PROGRAMS = tests tests_SOURCES = tests.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -tests_LDADD = -lhiredis -lswsscommon -lpthread libsaivs.la -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq +tests_LDADD = -lhiredis -lswsscommon -lpthread libsaivs.la -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(VPP_LIBS) TESTS = tests diff --git a/vslib/Sai.cpp b/vslib/Sai.cpp index 97238f9de..5b83ea6cc 100644 --- a/vslib/Sai.cpp +++ b/vslib/Sai.cpp @@ -241,7 +241,13 @@ sai_status_t Sai::apiInitialize( // TODO move to Context class - m_vsSai = std::make_shared(contextConfig); + sai_vs_packet_engine_t pe; + + SwitchConfig::parseSaiVsPacketEngine(service_method_table->profile_get_value(0, SAI_KEY_VS_PACKET_ENGINE), pe); + + bool vpp = (pe == SAI_VS_PACKET_ENGINE_VPP); + + m_vsSai = std::make_shared(contextConfig, vpp); m_meta = std::make_shared(m_vsSai); diff --git a/vslib/SwitchConfig.cpp b/vslib/SwitchConfig.cpp index 88eeebd52..c7eee2881 100644 --- a/vslib/SwitchConfig.cpp +++ b/vslib/SwitchConfig.cpp @@ -17,7 +17,8 @@ SwitchConfig::SwitchConfig( m_bootType(SAI_VS_BOOT_TYPE_COLD), m_switchIndex(switchIndex), m_hardwareInfo(hwinfo), - m_useTapDevice(false) + m_useTapDevice(false), + m_vpp(false) { SWSS_LOG_ENTER(); @@ -153,3 +154,28 @@ bool SwitchConfig::parseUseTapDevice( return false; } + +bool SwitchConfig::parseSaiVsPacketEngine( + _In_ const char* pe, + _Out_ sai_vs_packet_engine_t& vsPacketEngine) +{ + SWSS_LOG_ENTER(); + + std::string st = (pe == NULL) ? "unknown" : pe; + + if (st == SAI_VALUE_VS_PACKET_ENGINE_VS) + { + vsPacketEngine = SAI_VS_PACKET_ENGINE_VS; + } + else if (st == SAI_VALUE_VS_PACKET_ENGINE_VPP) + { + vsPacketEngine = SAI_VS_PACKET_ENGINE_VPP; + } + else + { + // default is VS + vsPacketEngine = SAI_VS_PACKET_ENGINE_VS; + } + + return true; +} diff --git a/vslib/SwitchConfig.h b/vslib/SwitchConfig.h index 8509eabf3..f9a1ff39e 100644 --- a/vslib/SwitchConfig.h +++ b/vslib/SwitchConfig.h @@ -10,6 +10,7 @@ extern "C" { #include "sai.h" +#include "saivs.h" } namespace saivs @@ -67,6 +68,10 @@ namespace saivs static bool parseUseTapDevice( _In_ const char* useTapDeviceStr); + static bool parseSaiVsPacketEngine( + _In_ const char* pe, + _Out_ sai_vs_packet_engine_t& vsPacketEngine); + public: sai_switch_type_t m_saiSwitchType; @@ -90,5 +95,7 @@ namespace saivs std::shared_ptr m_resourceLimiter; std::shared_ptr m_corePortIndexMap; + + bool m_vpp; }; } diff --git a/vslib/SwitchStateBase.cpp b/vslib/SwitchStateBase.cpp index 6d8e3c32b..9ead78d44 100644 --- a/vslib/SwitchStateBase.cpp +++ b/vslib/SwitchStateBase.cpp @@ -8,8 +8,6 @@ #include -extern bool g_vpp; - #define SAI_VS_MAX_PORTS 1024 using namespace saivs; @@ -25,6 +23,10 @@ SwitchStateBase::SwitchStateBase( { SWSS_LOG_ENTER(); + m_vpp = config->m_vpp; + + m_macsecManager.setVpp(m_vpp); + m_macsecManager.cleanup_macsec_device(); } @@ -40,9 +42,13 @@ SwitchStateBase::SwitchStateBase( { SWSS_LOG_ENTER(); + m_vpp = config->m_vpp; + + m_macsecManager.setVpp(m_vpp); + m_macsecManager.cleanup_macsec_device(); - if (g_vpp) + if (m_vpp) { vpp_dp_initialize(); } @@ -169,7 +175,7 @@ sai_status_t SwitchStateBase::create( return createHostif(object_id, switch_id, attr_count, attr_list); } - if (g_vpp) // VPP + if (m_vpp) // VPP { if (object_type == SAI_OBJECT_TYPE_ROUTER_INTERFACE) { @@ -247,7 +253,7 @@ sai_status_t SwitchStateBase::create( return createVoqSystemNeighborEntry(serializedObjectId, switch_id, attr_count, attr_list); } - if (g_vpp) // VPP + if (m_vpp) // VPP { if (object_type == SAI_OBJECT_TYPE_VLAN_MEMBER) { @@ -332,7 +338,7 @@ sai_status_t SwitchStateBase::create_internal( objectHash[serializedObjectId][a->getAttrMetadata()->attridname] = a; } - if (g_vpp) // VPP + if (m_vpp) // VPP { m_object_db.create_or_update(object_type, serializedObjectId, attr_count, attr_list, true /*is_create*/); } @@ -387,7 +393,7 @@ sai_status_t SwitchStateBase::createPort( { SWSS_LOG_ENTER(); - if (g_vpp) + if (m_vpp) { UpdatePort(object_id, attr_count, attr_list); } @@ -471,7 +477,7 @@ sai_status_t SwitchStateBase::remove( return removeHostif(objectId); } - if (g_vpp) // VPP + if (m_vpp) // VPP { if (object_type == SAI_OBJECT_TYPE_ROUTER_INTERFACE) { @@ -547,7 +553,7 @@ sai_status_t SwitchStateBase::remove( return removeMACsecSA(objectId); } - if (g_vpp) // VPP + if (m_vpp) // VPP { if (object_type == SAI_OBJECT_TYPE_VLAN_MEMBER) { @@ -576,7 +582,7 @@ sai_status_t SwitchStateBase::remove_internal( SWSS_LOG_INFO("removing object: %s", serializedObjectId.c_str()); - if (g_vpp) // VPP + if (m_vpp) // VPP { m_object_db.remove(object_type, serializedObjectId); } @@ -605,7 +611,7 @@ sai_status_t SwitchStateBase::setPort( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { UpdatePort(portId, 1, attr); @@ -679,7 +685,7 @@ sai_status_t SwitchStateBase::setAclEntry( auto sid = sai_serialize_object_id(entry_id); - if (g_vpp) // VPP + if (m_vpp) // VPP { set_internal(SAI_OBJECT_TYPE_ACL_ENTRY, sid, attr); @@ -717,7 +723,7 @@ sai_status_t SwitchStateBase::set( return setPort(objectId, attr); } - if (g_vpp) // VPP + if (m_vpp) // VPP { if (objectType == SAI_OBJECT_TYPE_ROUTER_INTERFACE) { @@ -780,7 +786,7 @@ sai_status_t SwitchStateBase::set_internal( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { //Update child-parent relationship before updating the attribute m_object_db.create_or_update(objectType, serializedObjectId, 1, attr, false /*is_create*/); @@ -840,7 +846,7 @@ sai_status_t SwitchStateBase::get( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { if (objectType == SAI_OBJECT_TYPE_ACL_COUNTER) { @@ -921,7 +927,7 @@ sai_status_t SwitchStateBase::get( if (ait == attrHash.end()) { - if (g_vpp) + if (m_vpp) { return SAI_STATUS_ITEM_NOT_FOUND; } @@ -997,7 +1003,7 @@ sai_status_t SwitchStateBase::bulkCreate( for (it = 0; it < object_count; it++) { - if (g_vpp) // VPP + if (m_vpp) // VPP { object_statuses[it] = create_internal(object_type, serialized_object_ids[it], switch_id, attr_count[it], attr_list[it]); } @@ -1048,7 +1054,7 @@ sai_status_t SwitchStateBase::bulkRemove( for (it = 0; it < object_count; it++) { - if (g_vpp) // VPP + if (m_vpp) // VPP { object_statuses[it] = remove_internal(object_type, serialized_object_ids[it]); } diff --git a/vslib/SwitchStateBase.h b/vslib/SwitchStateBase.h index 1b2df5c02..f3a3aa3b2 100644 --- a/vslib/SwitchStateBase.h +++ b/vslib/SwitchStateBase.h @@ -597,7 +597,8 @@ namespace saivs public: static int promisc( - _In_ const char *dev); + _In_ const char *dev, + _In_ bool vpp); protected: // custom hostif @@ -624,7 +625,8 @@ namespace saivs static int vs_create_tap_device( _In_ const char *dev, - _In_ int flags); + _In_ int flags, + _In_ bool vpp); static int vs_set_dev_mac_address( _In_ const char *dev, @@ -812,6 +814,8 @@ namespace saivs std::vector m_system_port_list; + bool m_vpp; + protected: constexpr static const int m_maxIPv4RouteEntries = 100000; diff --git a/vslib/SwitchStateBaseHostif.cpp b/vslib/SwitchStateBaseHostif.cpp index 686d3acc6..c52b43431 100644 --- a/vslib/SwitchStateBaseHostif.cpp +++ b/vslib/SwitchStateBaseHostif.cpp @@ -29,8 +29,6 @@ #include "vppxlate/SaiVppXlate.h" -extern bool g_vpp; - using namespace saivs; // XXX set must also be supported when we change operational status up/down and @@ -44,7 +42,8 @@ using namespace saivs; int SwitchStateBase::vs_create_tap_device( _In_ const char *dev, - _In_ int flags) + _In_ int flags, + _In_ bool vpp) { SWSS_LOG_ENTER(); @@ -59,7 +58,7 @@ int SwitchStateBase::vs_create_tap_device( return -1; } - if (g_vpp) // VPP + if (vpp) // VPP { return fd; } @@ -302,11 +301,12 @@ int SwitchStateBase::ifup( } int SwitchStateBase::promisc( - _In_ const char *dev) + _In_ const char *dev, + _In_ bool vpp) { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (vpp) // VPP { return 0; } @@ -495,7 +495,7 @@ bool SwitchStateBase::hostif_create_tap_veth_forwarding( SWSS_LOG_NOTICE("interface index = %d, %s\n", sock_address.sll_ifindex, vethname.c_str()); - if (promisc(vethname.c_str())) + if (promisc(vethname.c_str(), m_vpp)) { SWSS_LOG_ERROR("promisc failed on %s", vethname.c_str()); @@ -520,7 +520,8 @@ bool SwitchStateBase::hostif_create_tap_veth_forwarding( tapfd, tapname, port_id, - m_switchConfig->m_eventQueue); + m_switchConfig->m_eventQueue, + m_vpp); SWSS_LOG_NOTICE("setup forward rule for %s succeeded", tapname.c_str()); @@ -617,13 +618,13 @@ sai_status_t SwitchStateBase::vs_create_hostif_tap_interface( int tapfd; - if (g_vpp) // VPP + if (m_vpp) // VPP { - tapfd = vs_create_tap_device(name.c_str(), IFF_TAP | IFF_MULTI_QUEUE | IFF_NO_PI | IFF_VNET_HDR); + tapfd = vs_create_tap_device(name.c_str(), IFF_TAP | IFF_MULTI_QUEUE | IFF_NO_PI | IFF_VNET_HDR, m_vpp); } else { - tapfd = vs_create_tap_device(name.c_str(), IFF_TAP | IFF_MULTI_QUEUE | IFF_NO_PI); + tapfd = vs_create_tap_device(name.c_str(), IFF_TAP | IFF_MULTI_QUEUE | IFF_NO_PI, m_vpp); } if (tapfd < 0) @@ -635,7 +636,7 @@ sai_status_t SwitchStateBase::vs_create_hostif_tap_interface( SWSS_LOG_INFO("created TAP device for %s, fd: %d", name.c_str(), tapfd); - if (g_vpp) // VPP + if (m_vpp) // VPP { const char *dev = name.c_str(); const char *hwif_name = tap_to_hwif_name(dev); @@ -685,7 +686,7 @@ sai_status_t SwitchStateBase::vs_create_hostif_tap_interface( return SAI_STATUS_FAILURE; } - if (g_vpp) // VPP + if (m_vpp) // VPP { const char *dev = name.c_str(); const char *hwif_name = tap_to_hwif_name(dev); @@ -859,7 +860,7 @@ sai_status_t SwitchStateBase::vs_remove_hostif_tap_interface( // TODO this should be hosif_id or if index ? std::string name = std::string(attr.value.chardata); - if (g_vpp) // VPP + if (m_vpp) // VPP { /* auto it = m_hostif_info_map.find(name); @@ -968,7 +969,7 @@ bool SwitchStateBase::hasIfIndex( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { if (m_hostif_info_map.size() == 0) { diff --git a/vslib/SwitchStateBaseMACsec.cpp b/vslib/SwitchStateBaseMACsec.cpp index 6b6db3bf2..a2f10bfb8 100644 --- a/vslib/SwitchStateBaseMACsec.cpp +++ b/vslib/SwitchStateBaseMACsec.cpp @@ -17,8 +17,6 @@ using namespace saivs; -extern bool g_vpp; - #define SAI_VS_MACSEC_PREFIX "macsec_" #define MACSEC_SYSTEM_IDENTIFIER (12) #define MACSEC_PORT_IDENTIFIER (4) @@ -558,7 +556,7 @@ sai_status_t SwitchStateBase::loadMACsecAttrFromMACsecSC( sciHexStr << std::setw(MACSEC_SCI_LENGTH) << std::setfill('0'); - if (g_vpp) // VPP + if (m_vpp) // VPP { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ sciHexStr << std::hex << bswap_64(sci); diff --git a/vslib/VirtualSwitchSaiInterface.cpp b/vslib/VirtualSwitchSaiInterface.cpp index e49a63f80..d82c5b860 100644 --- a/vslib/VirtualSwitchSaiInterface.cpp +++ b/vslib/VirtualSwitchSaiInterface.cpp @@ -27,15 +27,15 @@ #define MAX_HARDWARE_INFO_LENGTH 0x1000 -extern bool g_vpp; - using namespace saivs; using namespace saimeta; using namespace sairediscommon; VirtualSwitchSaiInterface::VirtualSwitchSaiInterface( - _In_ std::shared_ptr contextConfig): - m_contextConfig(contextConfig) + _In_ std::shared_ptr contextConfig, + _In_ bool vpp): + m_contextConfig(contextConfig), + m_vpp(vpp) { SWSS_LOG_ENTER(); @@ -577,6 +577,8 @@ std::shared_ptr VirtualSwitchSaiInterface::init_switch( SWSS_LOG_THROW("switch already exists %s", sai_serialize_object_id(switch_id).c_str()); } + config->m_vpp = m_vpp; + switch (config->m_switchType) { case SAI_VS_SWITCH_TYPE_BCM56850: @@ -894,7 +896,7 @@ sai_status_t VirtualSwitchSaiInterface::queryAttributeCapability( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { // TODO move to SwitchState // @@ -982,7 +984,7 @@ sai_status_t VirtualSwitchSaiInterface::getStats( { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { if (object_type == SAI_OBJECT_TYPE_PORT) { diff --git a/vslib/VirtualSwitchSaiInterface.h b/vslib/VirtualSwitchSaiInterface.h index a4c38fbf5..a96fde4c9 100644 --- a/vslib/VirtualSwitchSaiInterface.h +++ b/vslib/VirtualSwitchSaiInterface.h @@ -25,7 +25,8 @@ namespace saivs public: VirtualSwitchSaiInterface( - _In_ std::shared_ptr contextConfig); + _In_ std::shared_ptr contextConfig, + _In_ bool vpp); virtual ~VirtualSwitchSaiInterface(); @@ -340,6 +341,8 @@ namespace saivs SwitchStateBase::SwitchStateMap m_switchStateMap; + bool m_vpp; + private: // VPP std::map m_phMap; diff --git a/vslib/VirtualSwitchSaiInterfaceFdb.cpp b/vslib/VirtualSwitchSaiInterfaceFdb.cpp index 53d7dc7f1..c1694313a 100644 --- a/vslib/VirtualSwitchSaiInterfaceFdb.cpp +++ b/vslib/VirtualSwitchSaiInterfaceFdb.cpp @@ -4,8 +4,6 @@ #include "swss/logger.h" #include "meta/sai_serialize.h" -extern bool g_vpp; - using namespace saivs; bool VirtualSwitchSaiInterface::doesFdbEntryNotMatchFlushAttr( @@ -281,7 +279,7 @@ sai_status_t VirtualSwitchSaiInterface::flushFdbEntries( data.fdb_entry.bv_id = vlanid->value.oid; } - if (g_vpp) // VPP + if (m_vpp) // VPP { /* Flushing the FDB Entrys based on Bridge port ID and VLAN ID sent to VS*/ ss->vpp_fdbentry_flush(switch_id, attr_count, attr_list); @@ -316,7 +314,7 @@ void VirtualSwitchSaiInterface::ageFdbs() { SWSS_LOG_ENTER(); - if (g_vpp) // VPP + if (m_vpp) // VPP { return; } diff --git a/vslib/saivs.h b/vslib/saivs.h index a68da6e84..04c5aefa3 100644 --- a/vslib/saivs.h +++ b/vslib/saivs.h @@ -153,3 +153,16 @@ typedef enum _sai_vs_switch_attr_t SAI_VS_SWITCH_ATTR_META_ALLOW_READ_ONLY_ONCE, } sau_vs_switch_attr_t; + +#define SAI_KEY_VS_PACKET_ENGINE "SAI_VS_PACKET_ENGINE" + +#define SAI_VALUE_VS_PACKET_ENGINE_VS "VS" +#define SAI_VALUE_VS_PACKET_ENGINE_VPP "VPP" + +typedef enum _sai_vs_packet_engine_t +{ + SAI_VS_PACKET_ENGINE_VS, + + SAI_VS_PACKET_ENGINE_VPP, + +} sai_vs_packet_engine_t;