@@ -1032,6 +1032,38 @@ void PortsOrch::getCpuPort(Port &port)
1032
1032
port = m_cpuPort;
1033
1033
}
1034
1034
1035
+ /*
1036
+ * Create host_tx_ready field in PORT_TABLE of STATE-DB
1037
+ * and set the field to false by default for the
1038
+ * front<Ethernet> port.
1039
+ */
1040
+ void PortsOrch::initHostTxReadyState (Port &port)
1041
+ {
1042
+ SWSS_LOG_ENTER ();
1043
+
1044
+ vector<FieldValueTuple> tuples;
1045
+ bool exist = m_portStateTable.get (port.m_alias , tuples);
1046
+ string hostTxReady;
1047
+
1048
+ if (exist)
1049
+ {
1050
+ for (auto i : tuples)
1051
+ {
1052
+ if (fvField (i) == " host_tx_ready" )
1053
+ {
1054
+ hostTxReady = fvValue (i);
1055
+ }
1056
+ }
1057
+ }
1058
+
1059
+ if (hostTxReady.empty ())
1060
+ {
1061
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , " false" );
1062
+ SWSS_LOG_INFO (" initalize hostTxReady %s with status %s" ,
1063
+ port.m_alias .c_str (), hostTxReady.c_str ());
1064
+ }
1065
+ }
1066
+
1035
1067
bool PortsOrch::setPortAdminStatus (Port &port, bool state)
1036
1068
{
1037
1069
SWSS_LOG_ENTER ();
@@ -1040,22 +1072,40 @@ bool PortsOrch::setPortAdminStatus(Port &port, bool state)
1040
1072
attr.id = SAI_PORT_ATTR_ADMIN_STATE;
1041
1073
attr.value .booldata = state;
1042
1074
1075
+ /* Update the host_tx_ready to false before setting admin_state, when admin state is false */
1076
+ if (!state)
1077
+ {
1078
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , " false" );
1079
+ SWSS_LOG_INFO (" Set admin status DOWN host_tx_ready to false to port pid:%" PRIx64,
1080
+ port.m_port_id );
1081
+ }
1082
+
1043
1083
sai_status_t status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
1044
1084
if (status != SAI_STATUS_SUCCESS)
1045
1085
{
1046
1086
SWSS_LOG_ERROR (" Failed to set admin status %s to port pid:%" PRIx64,
1047
1087
state ? " UP" : " DOWN" , port.m_port_id );
1088
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , " false" );
1048
1089
task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
1049
1090
if (handle_status != task_success)
1050
1091
{
1051
1092
return parseHandleSaiStatusFailure (handle_status);
1052
1093
}
1053
1094
}
1054
1095
1055
- SWSS_LOG_INFO (" Set admin status %s to port pid:%" PRIx64,
1056
- state ? " UP" : " DOWN" , port.m_port_id );
1057
-
1058
- setGearboxPortsAttr (port, SAI_PORT_ATTR_ADMIN_STATE, &state);
1096
+ bool gbstatus = setGearboxPortsAttr (port, SAI_PORT_ATTR_ADMIN_STATE, &state);
1097
+ if (gbstatus != true )
1098
+ {
1099
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , " false" );
1100
+ }
1101
+
1102
+ /* Update the state table for host_tx_ready*/
1103
+ if (state && (gbstatus == true ) && (status == SAI_STATUS_SUCCESS) )
1104
+ {
1105
+ m_portStateTable.hset (port.m_alias , " host_tx_ready" , " true" );
1106
+ SWSS_LOG_INFO (" Set admin status UP host_tx_ready to true to port pid:%" PRIx64,
1107
+ port.m_port_id );
1108
+ }
1059
1109
1060
1110
return true ;
1061
1111
}
@@ -1940,7 +1990,7 @@ void PortsOrch::initPortSupportedSpeeds(const std::string& alias, sai_object_id_
1940
1990
*/
1941
1991
bool PortsOrch::setGearboxPortsAttr (Port &port, sai_port_attr_t id, void *value)
1942
1992
{
1943
- bool status;
1993
+ bool status = false ;
1944
1994
1945
1995
status = setGearboxPortAttr (port, PHY_PORT_TYPE, id, value);
1946
1996
@@ -3367,7 +3417,10 @@ void PortsOrch::doPortTask(Consumer &consumer)
3367
3417
}
3368
3418
3369
3419
}
3370
-
3420
+
3421
+ /* create host_tx_ready field in state-db */
3422
+ initHostTxReadyState (p);
3423
+
3371
3424
/* Last step set port admin status */
3372
3425
if (!admin_status.empty () && (p.m_admin_state_up != (admin_status == " up" )))
3373
3426
{
0 commit comments