Skip to content

Commit 0a99f54

Browse files
Try get port operational speed from STATE DB (sonic-net#2119)
* Put port operational speed to STATE DB * Remove previous workaround [orchagent] Put port configuration to APPL_DB according to autoneg mode sonic-net#1769
1 parent 828cccf commit 0a99f54

File tree

2 files changed

+14
-58
lines changed

2 files changed

+14
-58
lines changed

orchagent/portsorch.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -4934,7 +4934,7 @@ bool PortsOrch::addLag(string lag_alias, uint32_t spa_id, int32_t switch_id)
49344934
auto lagport = m_portList.find(lag_alias);
49354935
if (lagport != m_portList.end())
49364936
{
4937-
/* The deletion of bridgeport attached to the lag may still be
4937+
/* The deletion of bridgeport attached to the lag may still be
49384938
* pending due to fdb entries still present on the lag. Wait
49394939
* until the cleanup is done.
49404940
*/
@@ -5628,8 +5628,12 @@ void PortsOrch::doTask(NotificationConsumer &consumer)
56285628
SWSS_LOG_NOTICE("%s oper speed is %d", port.m_alias.c_str(), speed);
56295629
updateDbPortOperSpeed(port, speed);
56305630
}
5631+
else
5632+
{
5633+
updateDbPortOperSpeed(port, 0);
5634+
}
56315635
}
5632-
5636+
56335637
/* update m_portList */
56345638
m_portList[port.m_alias] = port;
56355639
}
@@ -5689,9 +5693,9 @@ void PortsOrch::updateDbPortOperSpeed(Port &port, sai_uint32_t speed)
56895693
SWSS_LOG_ENTER();
56905694

56915695
vector<FieldValueTuple> tuples;
5692-
FieldValueTuple tuple("speed", to_string(speed));
5693-
tuples.push_back(tuple);
5694-
m_portTable->set(port.m_alias, tuples);
5696+
string speedStr = speed != 0 ? to_string(speed) : "N/A";
5697+
tuples.emplace_back(std::make_pair("speed", speedStr));
5698+
m_portStateTable.set(port.m_alias, tuples);
56955699

56965700
// We don't set port.m_speed = speed here, because CONFIG_DB still hold the old
56975701
// value. If we set it here, next time configure any attributes related port will
@@ -5738,6 +5742,10 @@ void PortsOrch::refreshPortStatus()
57385742
SWSS_LOG_INFO("%s oper speed is %d", port.m_alias.c_str(), speed);
57395743
updateDbPortOperSpeed(port, speed);
57405744
}
5745+
else
5746+
{
5747+
updateDbPortOperSpeed(port, 0);
5748+
}
57415749
}
57425750
}
57435751
}

portsyncd/portsyncd.cpp

+1-53
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ void handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, boo
228228

229229
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
230230
{
231-
string autoneg;
232-
vector<FieldValueTuple> attrs;
233-
vector<FieldValueTuple> autoneg_attrs;
234-
vector<FieldValueTuple> force_attrs;
235-
236231
auto it = port_cfg_map.begin();
237232
while (it != port_cfg_map.end())
238233
{
@@ -247,54 +242,7 @@ void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple>
247242
/* No support for port delete yet */
248243
if (op == SET_COMMAND)
249244
{
250-
251-
for (auto i : values)
252-
{
253-
auto field = fvField(i);
254-
if (field == "adv_speeds")
255-
{
256-
autoneg_attrs.push_back(i);
257-
}
258-
else if (field == "adv_interface_types")
259-
{
260-
autoneg_attrs.push_back(i);
261-
}
262-
else if (field == "speed")
263-
{
264-
force_attrs.push_back(i);
265-
}
266-
else if (field == "interface_type")
267-
{
268-
force_attrs.push_back(i);
269-
}
270-
else if (field == "autoneg")
271-
{
272-
autoneg = fvValue(i);
273-
attrs.push_back(i);
274-
}
275-
else
276-
{
277-
attrs.push_back(i);
278-
}
279-
}
280-
if (autoneg == "on") // autoneg is on, only put adv_speeds and adv_interface_types to APPL_DB
281-
{
282-
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
283-
}
284-
else if (autoneg == "off") // autoneg is off, only put speed and interface_type to APPL_DB
285-
{
286-
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
287-
}
288-
else // autoneg is not configured, put all attributes to APPL_DB
289-
{
290-
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
291-
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
292-
}
293-
p.set(key, attrs);
294-
attrs.clear();
295-
autoneg_attrs.clear();
296-
force_attrs.clear();
297-
autoneg.clear();
245+
p.set(key, values);
298246
}
299247

300248
it = port_cfg_map.erase(it);

0 commit comments

Comments
 (0)