Skip to content

Commit 9fb6fe9

Browse files
[vs] VoQ Switch objects initialization - Local Port OID mapping to System 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.
1 parent 6ace7d3 commit 9fb6fe9

File tree

6 files changed

+73
-2
lines changed

6 files changed

+73
-2
lines changed

vslib/inc/Sai.h

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "EventQueue.h"
66
#include "EventPayloadNotification.h"
77
#include "ResourceLimiterContainer.h"
8+
#include "CorePortIndexMapContainer.h"
89

910
#include "meta/Meta.h"
1011

@@ -416,5 +417,7 @@ namespace saivs
416417
std::shared_ptr<LaneMapContainer> m_laneMapContainer;
417418

418419
std::shared_ptr<ResourceLimiterContainer> m_resourceLimiterContainer;
420+
421+
std::shared_ptr<CorePortIndexMapContainer> m_corePortIndexMapContainer;
419422
};
420423
}

vslib/inc/SwitchConfig.h

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "LaneMap.h"
44
#include "EventQueue.h"
55
#include "ResourceLimiter.h"
6+
#include "CorePortIndexMap.h"
67

78
#include <string>
89
#include <memory>
@@ -79,5 +80,7 @@ namespace saivs
7980
std::shared_ptr<EventQueue> m_eventQueue;
8081

8182
std::shared_ptr<ResourceLimiter> m_resourceLimiter;
83+
84+
std::shared_ptr<CorePortIndexMap> m_corePortIndexMap;
8285
};
8386
}

vslib/inc/saivs.h

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ extern "C" {
4444
*/
4545
#define SAI_KEY_VS_HOSTIF_USE_TAP_DEVICE "SAI_VS_HOSTIF_USE_TAP_DEVICE"
4646

47+
/**
48+
* @def SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE
49+
*
50+
* For VOQ systems if specified in profile.ini it should point to eth interface to
51+
* core and core port index map as port name:core_index,core_port_index
52+
*
53+
* Example:
54+
* eth1:0,1
55+
* eth17:1,1
56+
*
57+
*/
58+
#define SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE "SAI_VS_CORE_PORT_INDEX_MAP_FILE"
59+
4760
#define SAI_VALUE_VS_SWITCH_TYPE_BCM56850 "SAI_VS_SWITCH_TYPE_BCM56850"
4861
#define SAI_VALUE_VS_SWITCH_TYPE_BCM81724 "SAI_VS_SWITCH_TYPE_BCM81724"
4962
#define SAI_VALUE_VS_SWITCH_TYPE_MLNX2700 "SAI_VS_SWITCH_TYPE_MLNX2700"

vslib/src/Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ libSaiVS_a_SOURCES = \
5050
SwitchState.cpp \
5151
SwitchBCM56850.cpp \
5252
SwitchBCM81724.cpp \
53-
SwitchMLNX2700.cpp
53+
SwitchMLNX2700.cpp \
54+
CorePortIndexMap.cpp \
55+
CorePortIndexMapContainer.cpp \
56+
CorePortIndexMapFileParser.cpp
5457

5558
libsaivs_la_SOURCES = \
5659
sai_vs_fdb.cpp \

vslib/src/Sai.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "HostInterfaceInfo.h"
88
#include "SwitchConfigContainer.h"
99
#include "ResourceLimiterParser.h"
10+
#include "CorePortIndexMapFileParser.h"
1011

1112
#include "swss/logger.h"
1213

@@ -112,6 +113,10 @@ sai_status_t Sai::initialize(
112113

113114
m_laneMapContainer = LaneMapFileParser::parseLaneMapFile(laneMapFile);
114115

116+
auto *corePortIndexMapFile = service_method_table->profile_get_value(0, SAI_KEY_VS_CORE_PORT_INDEX_MAP_FILE);
117+
118+
m_corePortIndexMapContainer = CorePortIndexMapFileParser::parseCorePortIndexMapFile(corePortIndexMapFile);
119+
115120
auto *resourceLimiterFile = service_method_table->profile_get_value(0, SAI_KEY_VS_RESOURCE_LIMITER_FILE);
116121

117122
m_resourceLimiterContainer = ResourceLimiterParser::parseFromFile(resourceLimiterFile);
@@ -154,6 +159,7 @@ sai_status_t Sai::initialize(
154159
sc->m_laneMap = m_laneMapContainer->getLaneMap(sc->m_switchIndex);
155160
sc->m_eventQueue = m_eventQueue;
156161
sc->m_resourceLimiter = m_resourceLimiterContainer->getResourceLimiter(sc->m_switchIndex);
162+
sc->m_corePortIndexMap = m_corePortIndexMapContainer->getCorePortIndexMap(sc->m_switchIndex);
157163

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

vslib/src/SwitchStateBase.cpp

+44-1
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,50 @@ sai_status_t SwitchStateBase::create_system_ports(
25742574
{
25752575
attr.value.s32 = SAI_SYSTEM_PORT_TYPE_LOCAL;
25762576

2577-
// TODO Need to set local port oid attribute
2577+
// This is system port of local port. Set the oid of the local port corresponding to this system port
2578+
2579+
auto map = m_switchConfig->m_corePortIndexMap;
2580+
2581+
if (map)
2582+
{
2583+
auto& corePortIndexVector = map->getCorePortIndexVector();
2584+
size_t n_map = corePortIndexVector.size();
2585+
size_t idx;
2586+
2587+
for (idx = 0; idx < n_map; idx++)
2588+
{
2589+
if (corePortIndexVector[idx][0] == sys_port_cfg_list[i].attached_core_index &&
2590+
corePortIndexVector[idx][1] == sys_port_cfg_list[i].attached_core_port_index &&
2591+
idx < m_port_list.size())
2592+
{
2593+
// m_port_list entries are in the same order as lane maps. The core port index maps are in the
2594+
// same order as the lane maps. So m_port_list at the index corresponding to the core port index map
2595+
// will be the port corresponding to the system port with core port index matching core port index map
2596+
2597+
sai_attribute_t lp_attr;
2598+
2599+
lp_attr.id = SAI_SYSTEM_PORT_ATTR_PORT;
2600+
lp_attr.value.oid = m_port_list.at(idx);
2601+
2602+
CHECK_STATUS(set(SAI_OBJECT_TYPE_SYSTEM_PORT, system_port_id, &lp_attr));
2603+
2604+
break;
2605+
}
2606+
}
2607+
2608+
if (idx >= n_map)
2609+
{
2610+
SWSS_LOG_ERROR("Core port index not found for system port %d for switch %s. Local port oid is not set!",
2611+
sys_port_cfg_list[i].port_id,
2612+
sai_serialize_object_id(m_switch_id).c_str());
2613+
}
2614+
}
2615+
else
2616+
{
2617+
SWSS_LOG_ERROR("Core port index map for switch %s is NULL. Local port oid is not set for system port %d!",
2618+
sai_serialize_object_id(m_switch_id).c_str(),
2619+
sys_port_cfg_list[i].port_id);
2620+
}
25782621
}
25792622

25802623
CHECK_STATUS(set(SAI_OBJECT_TYPE_SYSTEM_PORT, system_port_id, &attr));

0 commit comments

Comments
 (0)