Skip to content

Commit

Permalink
[syncd] Create base class SaiSwitchInterface (#786)
Browse files Browse the repository at this point in the history
This class will be needed for future asic compare.
  • Loading branch information
kcudnik committed Feb 6, 2021
1 parent 3360b0f commit 3663e30
Show file tree
Hide file tree
Showing 9 changed files with 217 additions and 118 deletions.
4 changes: 2 additions & 2 deletions syncd/BestCandidateFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using namespace syncd;
BestCandidateFinder::BestCandidateFinder(
_In_ const AsicView& currentView,
_In_ const AsicView& temporaryView,
_In_ std::shared_ptr<const SaiSwitch> sw):
_In_ std::shared_ptr<const SaiSwitchInterface> sw):
m_currentView(currentView),
m_temporaryView(temporaryView),
m_switch(sw)
Expand Down Expand Up @@ -2792,7 +2792,7 @@ bool BestCandidateFinder::hasEqualAttribute(

std::shared_ptr<SaiAttr> BestCandidateFinder::getSaiAttrFromDefaultValue(
_In_ const AsicView &currentView,
_In_ std::shared_ptr<const SaiSwitch> sw,
_In_ std::shared_ptr<const SaiSwitchInterface> sw,
_In_ const sai_attr_metadata_t &meta)
{
SWSS_LOG_ENTER();
Expand Down
8 changes: 4 additions & 4 deletions syncd/BestCandidateFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "SaiObj.h"
#include "AsicView.h"
#include "SaiSwitch.h"
#include "SaiSwitchInterface.h"

#include <memory>

Expand All @@ -25,7 +25,7 @@ namespace syncd
BestCandidateFinder(
_In_ const AsicView &currentView,
_In_ const AsicView &temporaryView,
_In_ std::shared_ptr<const SaiSwitch> sw);
_In_ std::shared_ptr<const SaiSwitchInterface> sw);


virtual ~BestCandidateFinder() = default;
Expand Down Expand Up @@ -176,7 +176,7 @@ namespace syncd

static std::shared_ptr<SaiAttr> getSaiAttrFromDefaultValue(
_In_ const AsicView &currentView,
_In_ std::shared_ptr<const SaiSwitch> sw,
_In_ std::shared_ptr<const SaiSwitchInterface> sw,
_In_ const sai_attr_metadata_t &meta);

static bool hasEqualQosMapList(
Expand All @@ -188,7 +188,7 @@ namespace syncd

const AsicView& m_temporaryView;

std::shared_ptr<const SaiSwitch> m_switch;
std::shared_ptr<const SaiSwitchInterface> m_switch;

std::shared_ptr<const SaiObj> m_temporaryObj;

Expand Down
2 changes: 1 addition & 1 deletion syncd/ComparisonLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace saimeta;

ComparisonLogic::ComparisonLogic(
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ std::shared_ptr<SaiSwitch> sw,
_In_ std::shared_ptr<SaiSwitchInterface> sw,
_In_ std::shared_ptr<NotificationHandler> handler,
_In_ std::set<sai_object_id_t> initViewRemovedVids,
_In_ std::shared_ptr<AsicView> current,
Expand Down
6 changes: 3 additions & 3 deletions syncd/ComparisonLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern "C"{

#include "AsicView.h"
#include "VendorSai.h"
#include "SaiSwitch.h"
#include "SaiSwitchInterface.h"
#include "VirtualOidTranslator.h"
#include "NotificationHandler.h"
#include "BreakConfig.h"
Expand All @@ -21,7 +21,7 @@ namespace syncd

ComparisonLogic(
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ std::shared_ptr<SaiSwitch> sw,
_In_ std::shared_ptr<SaiSwitchInterface> sw,
_In_ std::shared_ptr<NotificationHandler> handler,
_In_ std::set<sai_object_id_t> initViewRemovedVids,
_In_ std::shared_ptr<AsicView> current,
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace syncd

std::shared_ptr<sairedis::SaiInterface> m_vendorSai;

std::shared_ptr<SaiSwitch> m_switch;
std::shared_ptr<SaiSwitchInterface> m_switch;

std::set<sai_object_id_t> m_initViewRemovedVids;

Expand Down
3 changes: 2 additions & 1 deletion syncd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ endif

noinst_LIBRARIES = libSyncd.a libSyncdRequestShutdown.a
libSyncd_a_SOURCES = \
SaiSwitchInterface.cpp \
ZeroMQSelectableChannel.cpp \
RedisSelectableChannel.cpp \
SelectableChannel.cpp \
ZeroMQNotificationProducer.cpp \
RedisNotificationProducer.cpp \
ComparisonLogic.cpp \
Syncd.cpp \
BreakConfig.cpp \
BreakConfigParser.cpp \
Expand All @@ -32,7 +34,6 @@ libSyncd_a_SOURCES = \
Workaround.cpp \
ServiceMethodTable.cpp \
SwitchNotifications.cpp \
ComparisonLogic.cpp \
VirtualOidTranslator.cpp \
NotificationProcessor.cpp \
NotificationHandler.cpp \
Expand Down
37 changes: 1 addition & 36 deletions syncd/SaiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SaiSwitch::SaiSwitch(
_In_ std::shared_ptr<VirtualOidTranslator> translator,
_In_ std::shared_ptr<sairedis::SaiInterface> vendorSai,
_In_ bool warmBoot):
SaiSwitchInterface(switch_vid, switch_rid),
m_vendorSai(vendorSai),
m_warmBoot(warmBoot),
m_translator(translator),
Expand All @@ -36,9 +37,6 @@ SaiSwitch::SaiSwitch(

SWSS_LOG_TIMER("constructor");

m_switch_rid = switch_rid;
m_switch_vid = switch_vid;

GlobalSwitchId::setSwitchId(m_switch_rid);

m_hardware_info = saiGetHardwareInfo();
Expand Down Expand Up @@ -341,20 +339,6 @@ void SaiSwitch::redisSetDummyAsicStateForRealObjectId(
m_client->setDummyAsicStateObject(vid);
}

sai_object_id_t SaiSwitch::getVid() const
{
SWSS_LOG_ENTER();

return m_switch_vid;
}

sai_object_id_t SaiSwitch::getRid() const
{
SWSS_LOG_ENTER();

return m_switch_rid;
}

std::string SaiSwitch::getHardwareInfo() const
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -550,25 +534,6 @@ sai_object_id_t SaiSwitch::helperGetSwitchAttrOid(
return rid;
}

sai_object_id_t SaiSwitch::getSwitchDefaultAttrOid(
_In_ sai_attr_id_t attr_id) const
{
SWSS_LOG_ENTER();

auto it = m_default_rid_map.find(attr_id);

if (it == m_default_rid_map.end())
{
auto meta = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_SWITCH, attr_id);

const char* name = (meta) ? meta->attridname : "UNKNOWN";

SWSS_LOG_THROW("attribute %s (%d) not found in default RID map", name, attr_id);
}

return it->second;
}

bool SaiSwitch::isColdBootDiscoveredRid(
_In_ sai_object_id_t rid) const
{
Expand Down
Loading

0 comments on commit 3663e30

Please sign in to comment.