From f521da377ba8dbc888fdc9cb7156450079339824 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Wed, 22 Sep 2021 15:36:28 +0000 Subject: [PATCH 1/7] Skip create port if the lane set isn't available in ASIC Signed-off-by: Ze Gan --- orchagent/portsorch.cpp | 15 +++++++++++++++ orchagent/portsorch.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 68028e2c21..ce6f117f7d 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -468,6 +468,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vectorfirst) == m_availablePortSet.end()) + { + string tmp_lane_str = ""; + for (auto s : it->first) + { + tmp_lane_str += to_string(s) + " "; + } + tmp_lane_str = tmp_lane_str.substr(0, tmp_lane_str.size() - 1); + + SWSS_LOG_WARN("The lane set %s isn't available in ASIC", tmp_lane_str.c_str()); + it++; + continue; + } + if (m_portListLaneMap.find(it->first) == m_portListLaneMap.end()) { if (!addPort(it->first, get<1>(it->second), get<2>(it->second), get<3>(it->second))) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 9ae26242ce..60dbc381a8 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -213,8 +213,11 @@ class PortsOrch : public Orch, public Subject port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; + // m_portListLaneMap is the current enabled port list map, sai_object_id_t> m_portListLaneMap; map, tuple> m_lanesAliasSpeedMap; + // m_availablePortSet is the available port list read from ASIC by SAI + set> m_availablePortSet; map m_portList; unordered_map m_portOidToIndex; map m_port_ref_count; From b6c62b9a9cf4c4b4ccc5ab82ddb9732c899f8dea Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Thu, 23 Sep 2021 08:33:27 +0000 Subject: [PATCH 2/7] Fix port breakout Signed-off-by: Ze Gan --- orchagent/portsorch.cpp | 13 +++++++++++-- orchagent/portsorch.h | 4 +--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ce6f117f7d..694644e94e 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -457,6 +457,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vectorfirst) == m_availablePortSet.end()) + bool lane_set_is_available = true; + for (auto lane: it->first) + { + if (m_availableLanes.find(lane) == m_availableLanes.end()) + { + lane_set_is_available = false; + break; + } + } + if (!lane_set_is_available) { string tmp_lane_str = ""; for (auto s : it->first) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 60dbc381a8..f0eb64953f 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -213,11 +213,9 @@ class PortsOrch : public Orch, public Subject port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; - // m_portListLaneMap is the current enabled port list map, sai_object_id_t> m_portListLaneMap; map, tuple> m_lanesAliasSpeedMap; - // m_availablePortSet is the available port list read from ASIC by SAI - set> m_availablePortSet; + set m_availableLanes; map m_portList; unordered_map m_portOidToIndex; map m_port_ref_count; From d105639959376176c2650d407f75b3ae9151f352 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Wed, 29 Sep 2021 07:32:37 +0000 Subject: [PATCH 3/7] Revert "Fix port breakout" This reverts commit b6c62b9a9cf4c4b4ccc5ab82ddb9732c899f8dea. --- orchagent/portsorch.cpp | 13 ++----------- orchagent/portsorch.h | 4 +++- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 694644e94e..ce6f117f7d 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -457,7 +457,6 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vectorfirst) - { - if (m_availableLanes.find(lane) == m_availableLanes.end()) - { - lane_set_is_available = false; - break; - } - } - if (!lane_set_is_available) + if (m_availablePortSet.find(it->first) == m_availablePortSet.end()) { string tmp_lane_str = ""; for (auto s : it->first) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index f0eb64953f..60dbc381a8 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -213,9 +213,11 @@ class PortsOrch : public Orch, public Subject port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; + // m_portListLaneMap is the current enabled port list map, sai_object_id_t> m_portListLaneMap; map, tuple> m_lanesAliasSpeedMap; - set m_availableLanes; + // m_availablePortSet is the available port list read from ASIC by SAI + set> m_availablePortSet; map m_portList; unordered_map m_portOidToIndex; map m_port_ref_count; From f7df9a1091b0a2e3f20ecaf077e908360b478d83 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Wed, 29 Sep 2021 07:32:42 +0000 Subject: [PATCH 4/7] Revert "Skip create port if the lane set isn't available in ASIC" This reverts commit f521da377ba8dbc888fdc9cb7156450079339824. --- orchagent/portsorch.cpp | 15 --------------- orchagent/portsorch.h | 3 --- 2 files changed, 18 deletions(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index ce6f117f7d..68028e2c21 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -468,7 +468,6 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vectorfirst) == m_availablePortSet.end()) - { - string tmp_lane_str = ""; - for (auto s : it->first) - { - tmp_lane_str += to_string(s) + " "; - } - tmp_lane_str = tmp_lane_str.substr(0, tmp_lane_str.size() - 1); - - SWSS_LOG_WARN("The lane set %s isn't available in ASIC", tmp_lane_str.c_str()); - it++; - continue; - } - if (m_portListLaneMap.find(it->first) == m_portListLaneMap.end()) { if (!addPort(it->first, get<1>(it->second), get<2>(it->second), get<3>(it->second))) diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h index 60dbc381a8..9ae26242ce 100755 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -213,11 +213,8 @@ class PortsOrch : public Orch, public Subject port_config_state_t m_portConfigState = PORT_CONFIG_MISSING; sai_uint32_t m_portCount; - // m_portListLaneMap is the current enabled port list map, sai_object_id_t> m_portListLaneMap; map, tuple> m_lanesAliasSpeedMap; - // m_availablePortSet is the available port list read from ASIC by SAI - set> m_availablePortSet; map m_portList; unordered_map m_portOidToIndex; map m_port_ref_count; From 48ab96c36f3901098d5e0b09aeaad5714bbeae20 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Wed, 29 Sep 2021 07:43:02 +0000 Subject: [PATCH 5/7] Skip if add port failure Signed-off-by: Ze Gan --- orchagent/portsorch.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 68028e2c21..249e507a93 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2747,7 +2747,10 @@ void PortsOrch::doPortTask(Consumer &consumer) if (!initPort(get<0>(it->second), get<5>(it->second), get<4>(it->second), it->first)) { - throw runtime_error("PortsOrch initialization failure."); + SWSS_LOG_ERROR("Initialize port %s failure", get<0>(it->second).c_str()); + + it++; + continue; } initPortSupportedSpeeds(get<0>(it->second), m_portListLaneMap[it->first]); From 0c19a24758979508ac4da5230d09c84c4cefeac4 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Sat, 2 Oct 2021 02:45:59 +0000 Subject: [PATCH 6/7] Fix bug Signed-off-by: Ze Gan --- orchagent/orch.cpp | 17 +++++++++++++++++ orchagent/portsorch.cpp | 5 +---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/orchagent/orch.cpp b/orchagent/orch.cpp index 5cc9ac0335..5f000400df 100644 --- a/orchagent/orch.cpp +++ b/orchagent/orch.cpp @@ -720,6 +720,23 @@ task_process_status Orch::handleSaiCreateStatus(sai_api_t api, sai_status_t stat exit(EXIT_FAILURE); } break; + case SAI_API_HOSTIF: + switch (status) + { + case SAI_STATUS_SUCCESS: + return task_success; + case SAI_STATUS_FAILURE: + /* + * Host interface maybe failed due to lane not available. + * In some scenarios, like SONiC virtual machine, the invalid lane may be not enabled by VM configuration, + * So just ignore the failure and report an error log. + */ + return task_ignore; + default: + SWSS_LOG_ERROR("Encountered failure in create operation, exiting orchagent, SAI API: %s, status: %s", + sai_serialize_api(api).c_str(), sai_serialize_status(status).c_str()); + exit(EXIT_FAILURE); + } default: switch (status) { diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 249e507a93..68028e2c21 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2747,10 +2747,7 @@ void PortsOrch::doPortTask(Consumer &consumer) if (!initPort(get<0>(it->second), get<5>(it->second), get<4>(it->second), it->first)) { - SWSS_LOG_ERROR("Initialize port %s failure", get<0>(it->second).c_str()); - - it++; - continue; + throw runtime_error("PortsOrch initialization failure."); } initPortSupportedSpeeds(get<0>(it->second), m_portListLaneMap[it->first]); From beafab2df4f2927c0edec0b68ce03b481ddd8847 Mon Sep 17 00:00:00 2001 From: Ze Gan Date: Sat, 2 Oct 2021 07:03:22 +0000 Subject: [PATCH 7/7] Skip if init port failure Signed-off-by: Ze Gan --- orchagent/portsorch.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 68028e2c21..a8bcef67c7 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -2747,7 +2747,9 @@ void PortsOrch::doPortTask(Consumer &consumer) if (!initPort(get<0>(it->second), get<5>(it->second), get<4>(it->second), it->first)) { - throw runtime_error("PortsOrch initialization failure."); + // Failure has been recorded in initPort + it++; + continue; } initPortSupportedSpeeds(get<0>(it->second), m_portListLaneMap[it->first]);