@@ -61,7 +61,7 @@ extern string gMyAsicName;
6161#define DEFAULT_VLAN_ID 1
6262#define MAX_VALID_VLAN_ID 4094
6363
64- #define PORT_STAT_POLLING_SEC 3
64+ #define PORT_STATE_POLLING_SEC 5
6565#define PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 1000
6666#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS 60000
6767#define QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000
@@ -320,7 +320,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
320320 port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false ),
321321 port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, false ),
322322 queue_stat_manager(QUEUE_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false ),
323- m_timer(new SelectableTimer(timespec { .tv_sec = PORT_STAT_POLLING_SEC , .tv_nsec = 0 }))
323+ m_timer(new SelectableTimer(timespec { .tv_sec = PORT_STATE_POLLING_SEC , .tv_nsec = 0 }))
324324{
325325 SWSS_LOG_ENTER ();
326326
@@ -1894,16 +1894,21 @@ void PortsOrch::initPortCapLinkTraining(Port &port)
18941894#ifdef SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE
18951895 attr.id = SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE;
18961896#else
1897+ /*
1898+ * Fallback to autoneg upon legacy SAI implementation
1899+ * In the case of SFP/QSFP ports, link-training is most likely available
1900+ * if autoneg is supported.
1901+ */
18971902 attr.id = SAI_PORT_ATTR_SUPPORTED_AUTO_NEG_MODE;
18981903#endif
18991904 status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
19001905 if (status == SAI_STATUS_SUCCESS)
19011906 {
1902- port.m_port_cap_lt = attr.value .booldata ;
1907+ port.m_cap_lt = attr.value .booldata ? 1 : 0 ;
19031908 }
19041909 else
19051910 {
1906- port.m_port_cap_lt = true ; /* This is for vstest */
1911+ port.m_cap_lt = 1 ; /* Default to 1 for vstest */
19071912 SWSS_LOG_NOTICE (" Unable to get %s LT capability" , port.m_alias .c_str ());
19081913 }
19091914}
@@ -2426,9 +2431,6 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
24262431 /* Create associated Gearbox lane mapping */
24272432 initGearboxPort (p);
24282433
2429- /* Initialize port capabilities */
2430- initPortCapLinkTraining (p);
2431-
24322434 /* Add port to port list */
24332435 m_portList[alias] = p;
24342436 saiOidToAlias[id] = alias;
@@ -3028,7 +3030,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
30283030 lt = link_training_mode_map[lt_str];
30293031 if (lt != p.m_link_training )
30303032 {
3031- if (!p.m_port_cap_lt )
3033+ if (p.m_cap_lt < 0 )
3034+ {
3035+ initPortCapLinkTraining (p);
3036+ m_portList[alias] = p;
3037+ }
3038+ if (p.m_cap_lt < 1 )
30323039 {
30333040 SWSS_LOG_ERROR (" %s: LT is not supported by the ASIC" , alias.c_str ());
30343041 // Don't retry
@@ -7097,7 +7104,7 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
70977104
70987105 string status = " off" ;
70997106
7100- if ((port.m_link_training > 0 ) && port.m_port_cap_lt )
7107+ if ((port.m_link_training > 0 ) && ( port.m_cap_lt > 0 ) )
71017108 {
71027109 sai_port_link_training_rx_status_t rx_status;
71037110 sai_port_link_training_failure_status_t failure;
@@ -7127,13 +7134,13 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
71277134 m_portStateTable.hset (port.m_alias , " link_training_status" , status);
71287135}
71297136
7130- void PortsOrch::updatePortStatePoll (const Port &port, port_state_poll_t type, bool set )
7137+ void PortsOrch::updatePortStatePoll (const Port &port, port_state_poll_t type, bool active )
71317138{
71327139 if (type == PORT_STATE_POLL_NONE)
71337140 {
71347141 return ;
71357142 }
7136- if (set )
7143+ if (active )
71377144 {
71387145 m_port_state_poll[port.m_alias ] |= type;
71397146 m_timer->start ();
@@ -7155,7 +7162,11 @@ void PortsOrch::doTask(swss::SelectableTimer &timer)
71557162 m_port_state_poll.erase (it);
71567163 continue ;
71577164 }
7158- if (port.m_admin_state_up && (it->second & PORT_STATE_POLL_LT))
7165+ if (!port.m_admin_state_up )
7166+ {
7167+ continue ;
7168+ }
7169+ if (it->second & PORT_STATE_POLL_LT)
71597170 {
71607171 updatePortStateLinkTraining (port);
71617172 }
0 commit comments