Skip to content

Commit

Permalink
[vs] VoQ Switch objects initialization - Local Port OID mapping to Sy…
Browse files Browse the repository at this point in the history
…stem Ports (sonic-net#703)

SAI emulation support added for VOQ system ports. The changes include
association of local port id to sytems ports that correspond ot the
local ports. In real SAI, mapping between system port and local port is done
by matching the system ports's <switch_id, core index, core port index> tuple.
In VOQ switches, each port blongs to a switch core and is assigned an index.
This mapping is done in hardware configurations. For VS, the mapping is emulated
via a new file coreportindexmap.ini. This file is made available in /usr/share/sonic/hwsku
in the same way how lanemap.ini is made avaialble. The loading and and parsing of
coreportindexmap.ini is done in similar way as it is done for lanemap.ini.
While emulating configuration system ports, if a system port is found to be a
local port (determined using its switch_id), the local port oid corresponding
system port is retrieved from m_port_list and local port atribute is set in the
system port object. This is used by orchagent (portsorch) for system port initialization.
  • Loading branch information
vganesan-nokia authored Nov 14, 2020
1 parent 6ace7d3 commit 9fb6fe9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 2 deletions.
3 changes: 3 additions & 0 deletions vslib/inc/Sai.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "EventQueue.h"
#include "EventPayloadNotification.h"
#include "ResourceLimiterContainer.h"
#include "CorePortIndexMapContainer.h"

#include "meta/Meta.h"

Expand Down Expand Up @@ -416,5 +417,7 @@ namespace saivs
std::shared_ptr<LaneMapContainer> m_laneMapContainer;

std::shared_ptr<ResourceLimiterContainer> m_resourceLimiterContainer;

std::shared_ptr<CorePortIndexMapContainer> m_corePortIndexMapContainer;
};
}
3 changes: 3 additions & 0 deletions vslib/inc/SwitchConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "LaneMap.h"
#include "EventQueue.h"
#include "ResourceLimiter.h"
#include "CorePortIndexMap.h"

#include <string>
#include <memory>
Expand Down Expand Up @@ -79,5 +80,7 @@ namespace saivs
std::shared_ptr<EventQueue> m_eventQueue;

std::shared_ptr<ResourceLimiter> m_resourceLimiter;

std::shared_ptr<CorePortIndexMap> m_corePortIndexMap;
};
}
13 changes: 13 additions & 0 deletions vslib/inc/saivs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ extern "C" {
*/
#define SAI_KEY_VS_HOSTIF_USE_TAP_DEVICE "SAI_VS_HOSTIF_USE_TAP_DEVICE"

/**
* @def SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE
*
* For VOQ systems if specified in profile.ini it should point to eth interface to
* core and core port index map as port name:core_index,core_port_index
*
* Example:
* eth1:0,1
* eth17:1,1
*
*/
#define SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE "SAI_VS_CORE_PORT_INDEX_MAP_FILE"

#define SAI_VALUE_VS_SWITCH_TYPE_BCM56850 "SAI_VS_SWITCH_TYPE_BCM56850"
#define SAI_VALUE_VS_SWITCH_TYPE_BCM81724 "SAI_VS_SWITCH_TYPE_BCM81724"
#define SAI_VALUE_VS_SWITCH_TYPE_MLNX2700 "SAI_VS_SWITCH_TYPE_MLNX2700"
Expand Down
5 changes: 4 additions & 1 deletion vslib/src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ libSaiVS_a_SOURCES = \
SwitchState.cpp \
SwitchBCM56850.cpp \
SwitchBCM81724.cpp \
SwitchMLNX2700.cpp
SwitchMLNX2700.cpp \
CorePortIndexMap.cpp \
CorePortIndexMapContainer.cpp \
CorePortIndexMapFileParser.cpp

libsaivs_la_SOURCES = \
sai_vs_fdb.cpp \
Expand Down
6 changes: 6 additions & 0 deletions vslib/src/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "HostInterfaceInfo.h"
#include "SwitchConfigContainer.h"
#include "ResourceLimiterParser.h"
#include "CorePortIndexMapFileParser.h"

#include "swss/logger.h"

Expand Down Expand Up @@ -112,6 +113,10 @@ sai_status_t Sai::initialize(

m_laneMapContainer = LaneMapFileParser::parseLaneMapFile(laneMapFile);

auto *corePortIndexMapFile = service_method_table->profile_get_value(0, SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE);

m_corePortIndexMapContainer = CorePortIndexMapFileParser::parseCorePortIndexMapFile(corePortIndexMapFile);

auto *resourceLimiterFile = service_method_table->profile_get_value(0, SAI_KEY_VS_RESOURCE_LIMITER_FILE);

m_resourceLimiterContainer = ResourceLimiterParser::parseFromFile(resourceLimiterFile);
Expand Down Expand Up @@ -154,6 +159,7 @@ sai_status_t Sai::initialize(
sc->m_laneMap = m_laneMapContainer->getLaneMap(sc->m_switchIndex);
sc->m_eventQueue = m_eventQueue;
sc->m_resourceLimiter = m_resourceLimiterContainer->getResourceLimiter(sc->m_switchIndex);
sc->m_corePortIndexMap = m_corePortIndexMapContainer->getCorePortIndexMap(sc->m_switchIndex);

auto scc = std::make_shared<SwitchConfigContainer>();

Expand Down
45 changes: 44 additions & 1 deletion vslib/src/SwitchStateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2574,7 +2574,50 @@ sai_status_t SwitchStateBase::create_system_ports(
{
attr.value.s32 = SAI_SYSTEM_PORT_TYPE_LOCAL;

// TODO Need to set local port oid attribute
// This is system port of local port. Set the oid of the local port corresponding to this system port

auto map = m_switchConfig->m_corePortIndexMap;

if (map)
{
auto& corePortIndexVector = map->getCorePortIndexVector();
size_t n_map = corePortIndexVector.size();
size_t idx;

for (idx = 0; idx < n_map; idx++)
{
if (corePortIndexVector[idx][0] == sys_port_cfg_list[i].attached_core_index &&
corePortIndexVector[idx][1] == sys_port_cfg_list[i].attached_core_port_index &&
idx < m_port_list.size())
{
// m_port_list entries are in the same order as lane maps. The core port index maps are in the
// same order as the lane maps. So m_port_list at the index corresponding to the core port index map
// will be the port corresponding to the system port with core port index matching core port index map

sai_attribute_t lp_attr;

lp_attr.id = SAI_SYSTEM_PORT_ATTR_PORT;
lp_attr.value.oid = m_port_list.at(idx);

CHECK_STATUS(set(SAI_OBJECT_TYPE_SYSTEM_PORT, system_port_id, &lp_attr));

break;
}
}

if (idx >= n_map)
{
SWSS_LOG_ERROR("Core port index not found for system port %d for switch %s. Local port oid is not set!",
sys_port_cfg_list[i].port_id,
sai_serialize_object_id(m_switch_id).c_str());
}
}
else
{
SWSS_LOG_ERROR("Core port index map for switch %s is NULL. Local port oid is not set for system port %d!",
sai_serialize_object_id(m_switch_id).c_str(),
sys_port_cfg_list[i].port_id);
}
}

CHECK_STATUS(set(SAI_OBJECT_TYPE_SYSTEM_PORT, system_port_id, &attr));
Expand Down

0 comments on commit 9fb6fe9

Please sign in to comment.