diff --git a/orchagent/aclorch.cpp b/orchagent/aclorch.cpp index b818f33b8582..18593c21327e 100644 --- a/orchagent/aclorch.cpp +++ b/orchagent/aclorch.cpp @@ -879,7 +879,7 @@ AclRange *AclRange::create(sai_acl_range_type_t type, int min, int max) // work around to avoid syncd termination on SAI error due to max count of ranges reached // can be removed when syncd start passing errors to the SAI callers - char *platform = getenv("onie_platform"); + char *platform = getenv("platform"); if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) { if (m_ranges.size() >= MLNX_MAX_RANGES_COUNT) diff --git a/orchagent/aclorch.h b/orchagent/aclorch.h index 73111f0477b0..171c42e7aa48 100644 --- a/orchagent/aclorch.h +++ b/orchagent/aclorch.h @@ -57,7 +57,6 @@ #define IP_TYPE_ARP_REQUEST "ARP_REQUEST" #define IP_TYPE_ARP_REPLY "ARP_REPLY" -#define MLNX_PLATFORM_SUBSTRING "mlnx" #define MLNX_MAX_RANGES_COUNT 16 typedef enum diff --git a/orchagent/copporch.cpp b/orchagent/copporch.cpp index 7dc20fbc7cd7..95f419464b01 100644 --- a/orchagent/copporch.cpp +++ b/orchagent/copporch.cpp @@ -14,8 +14,6 @@ extern sai_policer_api_t* sai_policer_api; extern sai_switch_api_t* sai_switch_api; extern sai_object_id_t gSwitchId; -#define MLNX_PLATFORM_SUBSTRING "mlnx" - map policer_meter_map = { {"packets", SAI_METER_TYPE_PACKETS}, {"bytes", SAI_METER_TYPE_BYTES} diff --git a/orchagent/orch.h b/orchagent/orch.h index 2869c3d1720b..169a8ee15514 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -24,6 +24,8 @@ const char ref_end = ']'; const char comma = ','; const char range_specifier = '-'; +#define MLNX_PLATFORM_SUBSTRING "mlnx" + typedef enum { task_success, diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 72bc8b7cb3b2..ea99b9222d38 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -679,10 +679,19 @@ void PortsOrch::doPortTask(Consumer &consumer) { if (m_lanesAliasSpeedMap.find(it->first) == m_lanesAliasSpeedMap.end()) { - if (!removePort(it->second)) + char *platform = getenv("platform"); + if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) { - throw runtime_error("PortsOrch initialization failure."); + if (!removePort(it->second)) + { + throw runtime_error("PortsOrch initialization failure."); + } } + else + { + SWSS_LOG_NOTICE("Failed to remove Port %lx due to missing SAI remove_port API.", it->second); + } + it = m_portListLaneMap.erase(it); } else @@ -693,23 +702,50 @@ void PortsOrch::doPortTask(Consumer &consumer) for (auto it = m_lanesAliasSpeedMap.begin(); it != m_lanesAliasSpeedMap.end();) { + bool port_created = false; + if (m_portListLaneMap.find(it->first) == m_portListLaneMap.end()) { - if (!addPort(it->first, get<1>(it->second))) + // work around to avoid syncd termination on SAI error due missing create_port SAI API + // can be removed when SAI redis return NotImplemented error + char *platform = getenv("platform"); + if (platform && strstr(platform, MLNX_PLATFORM_SUBSTRING)) { - throw runtime_error("PortsOrch initialization failure."); + if (!addPort(it->first, get<1>(it->second))) + { + throw runtime_error("PortsOrch initialization failure."); + } + + port_created = true; + } + else + { + SWSS_LOG_NOTICE("Failed to create Port %s due to missing SAI create_port API.", get<0>(it->second).c_str()); } } + else + { + port_created = true; + } - if (!initPort(get<0>(it->second), it->first)) + if (port_created) { - throw runtime_error("PortsOrch initialization failure."); + if (!initPort(get<0>(it->second), it->first)) + { + throw runtime_error("PortsOrch initialization failure."); + } } it = m_lanesAliasSpeedMap.erase(it); } } + if (!m_portConfigDone) + { + it = consumer.m_toSync.erase(it); + continue; + } + Port p; if (!getPort(alias, p)) { diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 6da093309459..486a86212c12 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -610,7 +610,7 @@ QosOrch::QosOrch(DBConnector *db, vector &tableNames) : Orch(db, tableNa // understand the underlying rationale. // Do not create color ACL on p4 platform as it does not support match dscp and ecn - char *platform = getenv("onie_platform"); + char *platform = getenv("platform"); if (!platform || (platform && strcmp(platform, "x86_64-barefoot_p4-r0") != 0)) { diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 41d6e7b4aa8b..36c4c72cd0e9 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -15,7 +15,6 @@ extern PortsOrch *gPortsOrch; /* Default maximum number of next hop groups */ #define DEFAULT_NUMBER_OF_ECMP_GROUPS 128 #define DEFAULT_MAX_ECMP_GROUP_SIZE 32 -#define MLNX_PLATFORM_SUBSTRING "mlnx" RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch) : Orch(db, tableName),