Skip to content

Commit

Permalink
Update setHostTxReady() to receive Port instead of portId
Browse files Browse the repository at this point in the history
  • Loading branch information
noaOrMlnx committed May 6, 2024
1 parent 8fd34c1 commit cb43a66
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
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

0 comments on commit cb43a66

Please sign in to comment.