Skip to content

Commit bdfb8d8

Browse files
committed
address review comments
Signed-off-by: Dante Su <[email protected]>
1 parent 1c6bda8 commit bdfb8d8

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

orchagent/port.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class Port
179179

180180
bool m_fec_cfg = false;
181181
bool m_an_cfg = false;
182-
bool m_port_cap_lt = false; /* Port Capability - LinkTraining */
182+
183+
int m_cap_lt = -1; /* Capability - LinkTraining, -1 means not set */
183184
};
184185

185186
}

orchagent/portsorch.cpp

+23-12
Original file line numberDiff line numberDiff line change
@@ -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
@@ -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_STAT_POLLING_SEC, .tv_nsec = 0 }))
331+
m_timer(new SelectableTimer(timespec { .tv_sec = PORT_STATE_POLLING_SEC, .tv_nsec = 0 }))
332332
{
333333
SWSS_LOG_ENTER();
334334

@@ -1939,16 +1939,21 @@ void PortsOrch::initPortCapLinkTraining(Port &port)
19391939
#ifdef SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE
19401940
attr.id = SAI_PORT_ATTR_SUPPORTED_LINK_TRAINING_MODE;
19411941
#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+
*/
19421947
attr.id = SAI_PORT_ATTR_SUPPORTED_AUTO_NEG_MODE;
19431948
#endif
19441949
status = sai_port_api->set_port_attribute(port.m_port_id, &attr);
19451950
if (status == SAI_STATUS_SUCCESS)
19461951
{
1947-
port.m_port_cap_lt = attr.value.booldata;
1952+
port.m_cap_lt = attr.value.booldata ? 1 : 0;
19481953
}
19491954
else
19501955
{
1951-
port.m_port_cap_lt = true; /* This is for vstest */
1956+
port.m_cap_lt = 1; /* Default to 1 for vstest */
19521957
SWSS_LOG_NOTICE("Unable to get %s LT capability", port.m_alias.c_str());
19531958
}
19541959
}
@@ -2471,9 +2476,6 @@ bool PortsOrch::initPort(const string &alias, const string &role, const int inde
24712476
/* Create associated Gearbox lane mapping */
24722477
initGearboxPort(p);
24732478

2474-
/* Initialize port capabilities */
2475-
initPortCapLinkTraining(p);
2476-
24772479
/* Add port to port list */
24782480
m_portList[alias] = p;
24792481
saiOidToAlias[id] = alias;
@@ -3073,7 +3075,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
30733075
lt = link_training_mode_map[lt_str];
30743076
if (lt != p.m_link_training)
30753077
{
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)
30773084
{
30783085
SWSS_LOG_ERROR("%s: LT is not supported by the ASIC", alias.c_str());
30793086
// Don't retry
@@ -7157,7 +7164,7 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
71577164

71587165
string status = "off";
71597166

7160-
if ((port.m_link_training > 0) && port.m_port_cap_lt)
7167+
if ((port.m_link_training > 0) && (port.m_cap_lt > 0))
71617168
{
71627169
sai_port_link_training_rx_status_t rx_status;
71637170
sai_port_link_training_failure_status_t failure;
@@ -7187,13 +7194,13 @@ void PortsOrch::updatePortStateLinkTraining(const Port &port)
71877194
m_portStateTable.hset(port.m_alias, "link_training_status", status);
71887195
}
71897196

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)
71917198
{
71927199
if (type == PORT_STATE_POLL_NONE)
71937200
{
71947201
return;
71957202
}
7196-
if (set)
7203+
if (active)
71977204
{
71987205
m_port_state_poll[port.m_alias] |= type;
71997206
m_timer->start();
@@ -7215,7 +7222,11 @@ void PortsOrch::doTask(swss::SelectableTimer &timer)
72157222
m_port_state_poll.erase(it);
72167223
continue;
72177224
}
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)
72197230
{
72207231
updatePortStateLinkTraining(port);
72217232
}

orchagent/portsorch.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class PortsOrch : public Orch, public Subject
351351
} port_state_poll_t;
352352

353353
map<string, uint32_t> m_port_state_poll;
354-
void updatePortStatePoll(const Port &port, port_state_poll_t type, bool set);
354+
void updatePortStatePoll(const Port &port, port_state_poll_t type, bool active);
355355
void updatePortStateLinkTraining(const Port &port);
356356

357357
void getPortSerdesVal(const std::string& s, std::vector<uint32_t> &lane_values);

0 commit comments

Comments
 (0)