@@ -1641,7 +1641,7 @@ void PortsOrch::initHostTxReadyState(Port &port)
1641
1641
1642
1642
if (hostTxReady.empty ())
1643
1643
{
1644
- setHostTxReady (port. m_port_id , " false" );
1644
+ setHostTxReady (port, " false" );
1645
1645
SWSS_LOG_NOTICE (" initialize host_tx_ready as false for port %s" ,
1646
1646
port.m_alias .c_str ());
1647
1647
}
@@ -1661,7 +1661,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
1661
1661
/* Update the host_tx_ready to false before setting admin_state, when admin state is false */
1662
1662
if (!state && !m_cmisModuleAsicSyncSupported)
1663
1663
{
1664
- setHostTxReady (port. m_port_id , " false" );
1664
+ setHostTxReady (port, " false" );
1665
1665
SWSS_LOG_NOTICE (" Set admin status DOWN host_tx_ready to false for port %s" ,
1666
1666
port.m_alias .c_str ());
1667
1667
}
@@ -1675,7 +1675,7 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
1675
1675
1676
1676
if (!m_cmisModuleAsicSyncSupported)
1677
1677
{
1678
- setHostTxReady (port. m_port_id , " false" );
1678
+ setHostTxReady (port, " false" );
1679
1679
}
1680
1680
task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
1681
1681
if (handle_status != task_success)
@@ -1687,34 +1687,26 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
1687
1687
bool gbstatus = setGearboxPortsAttr (port, SAI_PORT_ATTR_ADMIN_STATE, &state);
1688
1688
if (gbstatus != true && !m_cmisModuleAsicSyncSupported)
1689
1689
{
1690
- setHostTxReady (port. m_port_id , " false" );
1690
+ setHostTxReady (port, " false" );
1691
1691
SWSS_LOG_NOTICE (" Set host_tx_ready to false as gbstatus is false "
1692
1692
" for port %s" , port.m_alias .c_str ());
1693
1693
}
1694
1694
1695
1695
/* Update the state table for host_tx_ready*/
1696
1696
if (state && (gbstatus == true ) && (status == SAI_STATUS_SUCCESS) && !m_cmisModuleAsicSyncSupported)
1697
1697
{
1698
- setHostTxReady (port. m_port_id , " true" );
1698
+ setHostTxReady (port, " true" );
1699
1699
SWSS_LOG_NOTICE (" Set admin status UP host_tx_ready to true for port %s" ,
1700
1700
port.m_alias .c_str ());
1701
1701
}
1702
1702
1703
1703
return true ;
1704
1704
}
1705
1705
1706
- void PortsOrch::setHostTxReady (sai_object_id_t portId , const std::string &status)
1706
+ void PortsOrch::setHostTxReady (Port port , const std::string &status)
1707
1707
{
1708
- Port p;
1709
-
1710
- if (!getPort (portId, p))
1711
- {
1712
- SWSS_LOG_ERROR (" Failed to get port object for port id 0x%" PRIx64, portId);
1713
- return ;
1714
- }
1715
-
1716
- SWSS_LOG_NOTICE (" Setting host_tx_ready status = %s, alias = %s, port_id = 0x%" PRIx64, status.c_str (), p.m_alias .c_str (), portId);
1717
- m_portStateTable.hset (p.m_alias , " host_tx_ready" , status);
1708
+ 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 );
1709
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , status);
1718
1710
}
1719
1711
1720
1712
bool PortsOrch::getPortAdminStatus (sai_object_id_t id, bool &up)
@@ -3287,7 +3279,7 @@ void PortsOrch::updateDbPortFlapCount(Port& port, sai_port_oper_status_t pstatus
3287
3279
vector<FieldValueTuple> tuples;
3288
3280
FieldValueTuple tuple (" flap_count" , std::to_string (port.m_flap_count ));
3289
3281
tuples.push_back (tuple);
3290
-
3282
+
3291
3283
auto now = std::chrono::system_clock::now ();
3292
3284
std::time_t now_c = std::chrono::system_clock::to_time_t (now);
3293
3285
if (pstatus == SAI_PORT_OPER_STATUS_DOWN)
@@ -3297,8 +3289,8 @@ void PortsOrch::updateDbPortFlapCount(Port& port, sai_port_oper_status_t pstatus
3297
3289
std::strftime (buffer, sizeof (buffer), " %a %b %d %H:%M:%S %Y" , std::gmtime (&now_c));
3298
3290
FieldValueTuple tuple (" last_down_time" , buffer);
3299
3291
tuples.push_back (tuple);
3300
- }
3301
- else if (pstatus == SAI_PORT_OPER_STATUS_UP)
3292
+ }
3293
+ else if (pstatus == SAI_PORT_OPER_STATUS_UP)
3302
3294
{
3303
3295
char buffer[32 ];
3304
3296
// Format: Www Mmm dd hh:mm:ss yyyy
@@ -5765,7 +5757,7 @@ bool PortsOrch::initializePort(Port &port)
5765
5757
string hostTxReadyStr = hostTxReadyVal ? " true" : " false" ;
5766
5758
5767
5759
SWSS_LOG_DEBUG (" Received host_tx_ready current status: port_id: 0x%" PRIx64 " status: %s" , port.m_port_id , hostTxReadyStr.c_str ());
5768
- setHostTxReady (port. m_port_id , hostTxReadyStr);
5760
+ setHostTxReady (port, hostTxReadyStr);
5769
5761
}
5770
5762
5771
5763
/*
@@ -7944,7 +7936,13 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
7944
7936
sai_deserialize_port_host_tx_ready_ntf (data, switch_id, port_id, host_tx_ready_status);
7945
7937
SWSS_LOG_DEBUG (" Recieved host_tx_ready notification for port 0x%" PRIx64, port_id);
7946
7938
7947
- setHostTxReady (port_id, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? " true" : " false" );
7939
+ Port p;
7940
+ if (!getPort (port_id, p))
7941
+ {
7942
+ SWSS_LOG_ERROR (" Failed to get port object for port id 0x%" PRIx64, port_id);
7943
+ return ;
7944
+ }
7945
+ setHostTxReady (p, host_tx_ready_status == SAI_PORT_HOST_TX_READY_STATUS_READY ? " true" : " false" );
7948
7946
}
7949
7947
7950
7948
}
0 commit comments