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 Apr 30, 2024
1 parent 9e183a6 commit 7e02d65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 19 additions & 21 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 @@ -3115,15 +3107,15 @@ void PortsOrch::updateDbPortFlapCount(Port& port, sai_port_oper_status_t pstatus
vector<FieldValueTuple> tuples;
FieldValueTuple tuple("flap_count", std::to_string(port.m_flap_count));
tuples.push_back(tuple);

auto now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
if (pstatus == SAI_PORT_OPER_STATUS_DOWN)
{
FieldValueTuple tuple("last_down_time", std::ctime(&now_c));
tuples.push_back(tuple);
}
else if (pstatus == SAI_PORT_OPER_STATUS_UP)
}
else if (pstatus == SAI_PORT_OPER_STATUS_UP)
{
FieldValueTuple tuple("last_up_time", std::ctime(&now_c));
tuples.push_back(tuple);
Expand Down Expand Up @@ -5465,7 +5457,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 @@ -7647,7 +7639,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, portId);
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 @@ -407,7 +407,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 7e02d65

Please sign in to comment.