Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

202311 host_tx_ready fix #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ void PortsOrch::initHostTxReadyState(Port &port)

if (hostTxReady.empty())
{
setHostTxReady(port.m_port_id, "false");
setHostTxReady(port, "false");
SWSS_LOG_NOTICE("initialize host_tx_ready as false for port %s",
port.m_alias.c_str());
}
Expand All @@ -1489,7 +1489,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
/* Update the host_tx_ready to false before setting admin_state, when admin state is false */
if (!state && !m_cmisModuleAsicSyncSupported)
{
setHostTxReady(port.m_port_id, "false");
setHostTxReady(port, "false");
SWSS_LOG_NOTICE("Set admin status DOWN host_tx_ready to false for port %s",
port.m_alias.c_str());
}
Expand All @@ -1503,7 +1503,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)

if (!m_cmisModuleAsicSyncSupported)
{
setHostTxReady(port.m_port_id, "false");
setHostTxReady(port, "false");
}
task_process_status handle_status = handleSaiSetStatus(SAI_API_PORT, status);
if (handle_status != task_success)
Expand All @@ -1515,34 +1515,26 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
bool gbstatus = setGearboxPortsAttr(port, SAI_PORT_ATTR_ADMIN_STATE, &state);
if (gbstatus != true && !m_cmisModuleAsicSyncSupported)
{
setHostTxReady(port.m_port_id, "false");
setHostTxReady(port, "false");
SWSS_LOG_NOTICE("Set host_tx_ready to false as gbstatus is false "
"for port %s", port.m_alias.c_str());
}

/* Update the state table for host_tx_ready*/
if (state && (gbstatus == true) && (status == SAI_STATUS_SUCCESS) && !m_cmisModuleAsicSyncSupported)
{
setHostTxReady(port.m_port_id, "true");
setHostTxReady(port, "true");
SWSS_LOG_NOTICE("Set admin status UP host_tx_ready to true for port %s",
port.m_alias.c_str());
}

return true;
}

void PortsOrch::setHostTxReady(sai_object_id_t portId, const std::string &status)
void PortsOrch::setHostTxReady(Port port, const std::string &status)
{
Port p;

if (!getPort(portId, p))
{
SWSS_LOG_ERROR("Failed to get port object for port id 0x%" PRIx64, portId);
return;
}

SWSS_LOG_NOTICE("Setting host_tx_ready status = %s, alias = %s, port_id = 0x%" PRIx64, status.c_str(), p.m_alias.c_str(), portId);
m_portStateTable.hset(p.m_alias, "host_tx_ready", status);
SWSS_LOG_NOTICE("Setting host_tx_ready status = %s, alias = %s, port_id = 0x%" PRIx64, status.c_str(), port.m_alias.c_str(), port.m_port_id);
m_portStateTable.hset(port.m_alias, "host_tx_ready", status);
}

bool PortsOrch::getPortAdminStatus(sai_object_id_t id, bool &up)
Expand Down Expand Up @@ -5380,7 +5372,7 @@ bool PortsOrch::initializePort(Port &port)
string hostTxReadyStr = hostTxReadyVal ? "true" : "false";

SWSS_LOG_DEBUG("Received host_tx_ready current status: port_id: 0x%" PRIx64 " status: %s", port.m_port_id, hostTxReadyStr.c_str());
setHostTxReady(port.m_port_id, hostTxReadyStr);
setHostTxReady(port, hostTxReadyStr);
}

/*
Expand Down Expand Up @@ -7562,7 +7554,13 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
sai_deserialize_port_host_tx_ready_ntf(data, switch_id, port_id, host_tx_ready_status);
SWSS_LOG_DEBUG("Recieved host_tx_ready notification for port 0x%" PRIx64, port_id);

setHostTxReady(port_id, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? "true" : "false");
Port p;
if (!getPort(port_id, p))
{
SWSS_LOG_ERROR("Failed to get port object for port id 0x%" PRIx64, port_id);
return;
}
setHostTxReady(p, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? "true" : "false");
}

}
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class PortsOrch : public Orch, public Subject

bool setSaiHostTxSignal(const Port &port, bool enable);

void setHostTxReady(sai_object_id_t portId, const std::string &status);
void setHostTxReady(Port port, const std::string &status);
// Get supported speeds on system side
bool isSpeedSupported(const std::string& alias, sai_object_id_t port_id, sai_uint32_t speed);
void getPortSupportedSpeeds(const std::string& alias, sai_object_id_t port_id, PortSupportedSpeeds &supported_speeds);
Expand Down
Loading