Skip to content

Commit a3d3929

Browse files
lguohanShuotian Cheng
authored and
Shuotian Cheng
committed
[portsorch]: Limit FlexPort feature to only Mellanox Platform (sonic-net#338)
For other platforms that do not support SAI create/remove_port API, generate a log message instead of crash.
1 parent 1d99b96 commit a3d3929

File tree

7 files changed

+46
-12
lines changed

7 files changed

+46
-12
lines changed

orchagent/aclorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max)
879879

880880
// work around to avoid syncd termination on SAI error due to max count of ranges reached
881881
// can be removed when syncd start passing errors to the SAI callers
882-
char *platform = getenv("onie_platform");
882+
char *platform = getenv("platform");
883883
if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING))
884884
{
885885
if (m_ranges.size() >= MLNX_MAX_RANGES_COUNT)

orchagent/aclorch.h

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#define IP_TYPE_ARP_REQUEST "ARP_REQUEST"
5858
#define IP_TYPE_ARP_REPLY "ARP_REPLY"
5959

60-
#define MLNX_PLATFORM_SUBSTRING "mlnx"
6160
#define MLNX_MAX_RANGES_COUNT 16
6261

6362
typedef enum

orchagent/copporch.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ extern sai_policer_api_t* sai_policer_api;
1414
extern sai_switch_api_t* sai_switch_api;
1515
extern sai_object_id_t gSwitchId;
1616

17-
#define MLNX_PLATFORM_SUBSTRING "mlnx"
18-
1917
map<string, sai_meter_type_t> policer_meter_map = {
2018
{"packets", SAI_METER_TYPE_PACKETS},
2119
{"bytes", SAI_METER_TYPE_BYTES}

orchagent/orch.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const char ref_end = ']';
2424
const char comma = ',';
2525
const char range_specifier = '-';
2626

27+
#define MLNX_PLATFORM_SUBSTRING "mlnx"
28+
2729
typedef enum
2830
{
2931
task_success,

orchagent/portsorch.cpp

+42-6
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,19 @@ void PortsOrch::doPortTask(Consumer &consumer)
679679
{
680680
if (m_lanesAliasSpeedMap.find(it->first) == m_lanesAliasSpeedMap.end())
681681
{
682-
if (!removePort(it->second))
682+
char *platform = getenv("platform");
683+
if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING))
683684
{
684-
throw runtime_error("PortsOrch initialization failure.");
685+
if (!removePort(it->second))
686+
{
687+
throw runtime_error("PortsOrch initialization failure.");
688+
}
685689
}
690+
else
691+
{
692+
SWSS_LOG_NOTICE("Failed to remove Port %lx due to missing SAI remove_port API.", it->second);
693+
}
694+
686695
it = m_portListLaneMap.erase(it);
687696
}
688697
else
@@ -693,23 +702,50 @@ void PortsOrch::doPortTask(Consumer &consumer)
693702

694703
for (auto it = m_lanesAliasSpeedMap.begin(); it != m_lanesAliasSpeedMap.end();)
695704
{
705+
bool port_created = false;
706+
696707
if (m_portListLaneMap.find(it->first) == m_portListLaneMap.end())
697708
{
698-
if (!addPort(it->first, get<1>(it->second)))
709+
// work around to avoid syncd termination on SAI error due missing create_port SAI API
710+
// can be removed when SAI redis return NotImplemented error
711+
char *platform = getenv("platform");
712+
if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING))
699713
{
700-
throw runtime_error("PortsOrch initialization failure.");
714+
if (!addPort(it->first, get<1>(it->second)))
715+
{
716+
throw runtime_error("PortsOrch initialization failure.");
717+
}
718+
719+
port_created = true;
720+
}
721+
else
722+
{
723+
SWSS_LOG_NOTICE("Failed to create Port %s due to missing SAI create_port API.", get<0>(it->second).c_str());
701724
}
702725
}
726+
else
727+
{
728+
port_created = true;
729+
}
703730

704-
if (!initPort(get<0>(it->second), it->first))
731+
if (port_created)
705732
{
706-
throw runtime_error("PortsOrch initialization failure.");
733+
if (!initPort(get<0>(it->second), it->first))
734+
{
735+
throw runtime_error("PortsOrch initialization failure.");
736+
}
707737
}
708738

709739
it = m_lanesAliasSpeedMap.erase(it);
710740
}
711741
}
712742

743+
if (!m_portConfigDone)
744+
{
745+
it = consumer.m_toSync.erase(it);
746+
continue;
747+
}
748+
713749
Port p;
714750
if (!getPort(alias, p))
715751
{

orchagent/qosorch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ QosOrch::QosOrch(DBConnector *db, vector<string> &tableNames) : Orch(db, tableNa
610610
// understand the underlying rationale.
611611

612612
// Do not create color ACL on p4 platform as it does not support match dscp and ecn
613-
char *platform = getenv("onie_platform");
613+
char *platform = getenv("platform");
614614
if (!platform ||
615615
(platform && strcmp(platform, "x86_64-barefoot_p4-r0") != 0))
616616
{

orchagent/routeorch.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ extern PortsOrch *gPortsOrch;
1515
/* Default maximum number of next hop groups */
1616
#define DEFAULT_NUMBER_OF_ECMP_GROUPS 128
1717
#define DEFAULT_MAX_ECMP_GROUP_SIZE 32
18-
#define MLNX_PLATFORM_SUBSTRING "mlnx"
1918

2019
RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) :
2120
Orch(db, tableName),

0 commit comments

Comments
 (0)