@@ -328,7 +328,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
328328 port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false ),
329329 port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, false ),
330330 queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false ),
331- m_timer (new SelectableTimer(timespec { .tv_sec = PORT_STATE_POLLING_SEC, .tv_nsec = 0 }))
331+ m_port_state_poller (new SelectableTimer(timespec { .tv_sec = PORT_STATE_POLLING_SEC, .tv_nsec = 0 }))
332332{
333333 SWSS_LOG_ENTER ();
334334
@@ -594,7 +594,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
594594 m_lagIdAllocator = unique_ptr<LagIdAllocator> (new LagIdAllocator (chassisAppDb));
595595 }
596596
597- auto executor = new ExecutableTimer (m_timer , this , " PORT_STATE_POLL " );
597+ auto executor = new ExecutableTimer (m_port_state_poller , this , " PORT_STATE_POLLER " );
598598 Orch::addExecutor (executor);
599599}
600600
@@ -1945,7 +1945,7 @@ void PortsOrch::initPortCapLinkTraining(Port &port)
19451945 */
19461946 attr.id = SAI_PORT_ATTR_SUPPORTED_AUTO_NEG_MODE;
19471947#endif
1948- status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
1948+ status = sai_port_api->get_port_attribute (port.m_port_id , 1 , &attr);
19491949 if (status == SAI_STATUS_SUCCESS)
19501950 {
19511951 port.m_cap_lt = attr.value .booldata ? 1 : 0 ;
@@ -2242,12 +2242,11 @@ task_process_status PortsOrch::setPortLinkTraining(const Port &port, bool state)
22422242 sai_status_t status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
22432243 if (status != SAI_STATUS_SUCCESS)
22442244 {
2245- SWSS_LOG_ERROR (" Failed to set LT %s to port pid:%" PRIx64,
2246- op.c_str (), port.m_port_id );
2245+ SWSS_LOG_ERROR (" Failed to set LT %s to port %s" , op.c_str (), port.m_alias .c_str ());
22472246 return handleSaiSetStatus (SAI_API_PORT, status);
22482247 }
22492248
2250- SWSS_LOG_INFO (" Set LT %s to port pid:% " PRIx64 , op.c_str (), port.m_port_id );
2249+ SWSS_LOG_INFO (" Set LT %s to port %s " , op.c_str (), port.m_alias . c_str () );
22512250
22522251 return task_success;
22532252}
@@ -6153,8 +6152,6 @@ bool PortsOrch::getPortLinkTrainingFailure(const Port &port, sai_port_link_train
61536152
61546153 sai_attribute_t attr;
61556154 attr.id = SAI_PORT_ATTR_LINK_TRAINING_FAILURE_STATUS;
6156- attr.value .u32 = 0 ;
6157-
61586155 sai_status_t ret = sai_port_api->get_port_attribute (port.m_port_id , 1 , &attr);
61596156 if (ret != SAI_STATUS_SUCCESS)
61606157 {
@@ -7202,7 +7199,7 @@ void PortsOrch::updatePortStatePoll(const Port &port, port_state_poll_t type, bo
72027199 if (active)
72037200 {
72047201 m_port_state_poll[port.m_alias ] |= type;
7205- m_timer ->start ();
7202+ m_port_state_poller ->start ();
72067203 }
72077204 else
72087205 {
@@ -7214,24 +7211,26 @@ void PortsOrch::doTask(swss::SelectableTimer &timer)
72147211{
72157212 Port port;
72167213
7217- for (auto it = m_port_state_poll.begin (); it != m_port_state_poll.end (); ++it )
7214+ for (auto it = m_port_state_poll.begin (); it != m_port_state_poll.end (); )
72187215 {
72197216 if ((it->second == 0 ) || !getPort (it->first , port))
72207217 {
7221- m_port_state_poll.erase (it);
7218+ it = m_port_state_poll.erase (it);
72227219 continue ;
72237220 }
72247221 if (!port.m_admin_state_up )
72257222 {
7223+ ++it;
72267224 continue ;
72277225 }
72287226 if (it->second & PORT_STATE_POLL_LT)
72297227 {
72307228 updatePortStateLinkTraining (port);
72317229 }
7230+ ++it;
72327231 }
72337232 if (m_port_state_poll.size () == 0 )
72347233 {
7235- m_timer ->stop ();
7234+ m_port_state_poller ->stop ();
72367235 }
72377236}
0 commit comments