Skip to content

Commit

Permalink
[portsorch]: Limit FlexPort feature to only Mellanox Platform (sonic-…
Browse files Browse the repository at this point in the history
…net#338)

For other platforms that do not support SAI create/remove_port API,
generate a log message instead of crash.
  • Loading branch information
lguohan authored and Shuotian Cheng committed Oct 11, 2017
1 parent 1d99b96 commit a3d3929
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion orchagent/aclorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion orchagent/aclorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions orchagent/copporch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, sai_meter_type_t> policer_meter_map = {
{"packets", SAI_METER_TYPE_PACKETS},
{"bytes", SAI_METER_TYPE_BYTES}
Expand Down
2 changes: 2 additions & 0 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const char ref_end = ']';
const char comma = ',';
const char range_specifier = '-';

#define MLNX_PLATFORM_SUBSTRING "mlnx"

typedef enum
{
task_success,
Expand Down
48 changes: 42 additions & 6 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion orchagent/qosorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ QosOrch::QosOrch(DBConnector *db, vector<string> &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))
{
Expand Down
1 change: 0 additions & 1 deletion orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit a3d3929

Please sign in to comment.