@@ -61,7 +61,7 @@ extern string gMyAsicName;
61
61
#define DEFAULT_VLAN_ID 1
62
62
#define MAX_VALID_VLAN_ID 4094
63
63
64
- #define PORT_STAT_POLLING_SEC 3
64
+ #define PORT_STATE_POLLING_SEC 5
65
65
#define PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 1000
66
66
#define PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS 60000
67
67
#define QUEUE_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS 10000
@@ -328,7 +328,7 @@ PortsOrch::PortsOrch(DBConnector *db, DBConnector *stateDb, vector<table_name_wi
328
328
port_stat_manager(PORT_STAT_COUNTER_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_STAT_FLEX_COUNTER_POLLING_INTERVAL_MS, false ),
329
329
port_buffer_drop_stat_manager(PORT_BUFFER_DROP_STAT_FLEX_COUNTER_GROUP, StatsMode::READ, PORT_BUFFER_DROP_STAT_POLLING_INTERVAL_MS, false ),
330
330
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_STAT_POLLING_SEC , .tv_nsec = 0 }))
331
+ m_timer(new SelectableTimer(timespec { .tv_sec = PORT_STATE_POLLING_SEC , .tv_nsec = 0 }))
332
332
{
333
333
SWSS_LOG_ENTER ();
334
334
@@ -1939,16 +1939,21 @@ void PortsOrch::initPortCapLinkTraining(Port &port)
1939
1939
#ifdef SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE
1940
1940
attr.id = SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE;
1941
1941
#else
1942
+ /*
1943
+ * Fallback to autoneg upon legacy SAI implementation
1944
+ * In the case of SFP/QSFP ports, link-training is most likely available
1945
+ * if autoneg is supported.
1946
+ */
1942
1947
attr.id = SAI_PORT_ATTR_SUPPORTED_AUTO_NEG_MODE;
1943
1948
#endif
1944
1949
status = sai_port_api->set_port_attribute (port.m_port_id , &attr);
1945
1950
if (status == SAI_STATUS_SUCCESS)
1946
1951
{
1947
- port.m_port_cap_lt = attr.value .booldata ;
1952
+ port.m_cap_lt = attr.value .booldata ? 1 : 0 ;
1948
1953
}
1949
1954
else
1950
1955
{
1951
- port.m_port_cap_lt = true ; /* This is for vstest */
1956
+ port.m_cap_lt = 1 ; /* Default to 1 for vstest */
1952
1957
SWSS_LOG_NOTICE (" Unable to get %s LT capability" , port.m_alias .c_str ());
1953
1958
}
1954
1959
}
@@ -2471,9 +2476,6 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
2471
2476
/* Create associated Gearbox lane mapping */
2472
2477
initGearboxPort (p);
2473
2478
2474
- /* Initialize port capabilities */
2475
- initPortCapLinkTraining (p);
2476
-
2477
2479
/* Add port to port list */
2478
2480
m_portList[alias] = p;
2479
2481
saiOidToAlias[id] = alias;
@@ -3073,7 +3075,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
3073
3075
lt = link_training_mode_map[lt_str];
3074
3076
if (lt != p.m_link_training )
3075
3077
{
3076
- if (!p.m_port_cap_lt )
3078
+ if (p.m_cap_lt < 0 )
3079
+ {
3080
+ initPortCapLinkTraining (p);
3081
+ m_portList[alias] = p;
3082
+ }
3083
+ if (p.m_cap_lt < 1 )
3077
3084
{
3078
3085
SWSS_LOG_ERROR (" %s: LT is not supported by the ASIC" , alias.c_str ());
3079
3086
// Don't retry
@@ -7157,7 +7164,7 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
7157
7164
7158
7165
string status = " off" ;
7159
7166
7160
- if ((port.m_link_training > 0 ) && port.m_port_cap_lt )
7167
+ if ((port.m_link_training > 0 ) && ( port.m_cap_lt > 0 ) )
7161
7168
{
7162
7169
sai_port_link_training_rx_status_t rx_status;
7163
7170
sai_port_link_training_failure_status_t failure;
@@ -7187,13 +7194,13 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
7187
7194
m_portStateTable.hset (port.m_alias , " link_training_status" , status);
7188
7195
}
7189
7196
7190
- void PortsOrch::updatePortStatePoll (const Port &port, port_state_poll_t type, bool set )
7197
+ void PortsOrch::updatePortStatePoll (const Port &port, port_state_poll_t type, bool active )
7191
7198
{
7192
7199
if (type == PORT_STATE_POLL_NONE)
7193
7200
{
7194
7201
return ;
7195
7202
}
7196
- if (set )
7203
+ if (active )
7197
7204
{
7198
7205
m_port_state_poll[port.m_alias ] |= type;
7199
7206
m_timer->start ();
@@ -7215,7 +7222,11 @@ void PortsOrch::doTask(swss::SelectableTimer &timer)
7215
7222
m_port_state_poll.erase (it);
7216
7223
continue ;
7217
7224
}
7218
- if (port.m_admin_state_up && (it->second & PORT_STATE_POLL_LT))
7225
+ if (!port.m_admin_state_up )
7226
+ {
7227
+ continue ;
7228
+ }
7229
+ if (it->second & PORT_STATE_POLL_LT)
7219
7230
{
7220
7231
updatePortStateLinkTraining (port);
7221
7232
}
0 commit comments