Skip to content

Commit ae44701

Browse files
[orchagent] Put port configuration to APPL_DB according to autoneg mode (#1769)
*Before puting port related configuration to APPL_DB, check autoneg mode first. If autoneg mode is enabled, "speed" and "interface_type" will not be put into APPL_DB; if autoneg mode is disabled, "adv_speeds" and "adv_interface_types" will not be put into APPL_DB; else all configuration will be put to APPL_DB for backward compatible.
1 parent 5295f91 commit ae44701

File tree

2 files changed

+56
-8
lines changed

2 files changed

+56
-8
lines changed

orchagent/portsorch.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -2625,26 +2625,23 @@ void PortsOrch::doPortTask(Consumer &consumer)
26252625
{
26262626
an_str = fvValue(i);
26272627
}
2628-
26292628
/* Set advertised speeds */
2630-
if (fvField(i) == "adv_speeds")
2629+
else if (fvField(i) == "adv_speeds")
26312630
{
26322631
adv_speeds_str = fvValue(i);
26332632
}
2634-
26352633
/* Set interface type */
2636-
if (fvField(i) == "interface_type")
2634+
else if (fvField(i) == "interface_type")
26372635
{
26382636
interface_type_str = fvValue(i);
26392637
}
2640-
26412638
/* Set advertised interface type */
2642-
if (fvField(i) == "adv_interface_types")
2639+
else if (fvField(i) == "adv_interface_types")
26432640
{
26442641
adv_interface_types_str = fvValue(i);
26452642
}
26462643
/* Set port serdes Pre-emphasis */
2647-
if (fvField(i) == "preemphasis")
2644+
else if (fvField(i) == "preemphasis")
26482645
{
26492646
getPortSerdesVal(fvValue(i), attr_val);
26502647
serdes_attr.insert(serdes_attr_pair(SAI_PORT_SERDES_ATTR_PREEMPHASIS, attr_val));

portsyncd/portsyncd.cpp

+52-1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ bool handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, boo
235235

236236
void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
237237
{
238+
string autoneg;
239+
vector<FieldValueTuple> attrs;
240+
vector<FieldValueTuple> autoneg_attrs;
241+
vector<FieldValueTuple> force_attrs;
238242

239243
auto it = port_cfg_map.begin();
240244
while (it != port_cfg_map.end())
@@ -250,7 +254,54 @@ void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple>
250254
/* No support for port delete yet */
251255
if (op == SET_COMMAND)
252256
{
253-
p.set(key, values);
257+
258+
for (auto i : values)
259+
{
260+
auto field = fvField(i);
261+
if (field == "adv_speeds")
262+
{
263+
autoneg_attrs.push_back(i);
264+
}
265+
else if (field == "adv_interface_types")
266+
{
267+
autoneg_attrs.push_back(i);
268+
}
269+
else if (field == "speed")
270+
{
271+
force_attrs.push_back(i);
272+
}
273+
else if (field == "interface_type")
274+
{
275+
force_attrs.push_back(i);
276+
}
277+
else if (field == "autoneg")
278+
{
279+
autoneg = fvValue(i);
280+
attrs.push_back(i);
281+
}
282+
else
283+
{
284+
attrs.push_back(i);
285+
}
286+
}
287+
if (autoneg == "on") // autoneg is on, only put adv_speeds and adv_interface_types to APPL_DB
288+
{
289+
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
290+
}
291+
else if (autoneg == "off") // autoneg is off, only put speed and interface_type to APPL_DB
292+
{
293+
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
294+
}
295+
else // autoneg is not configured, put all attributes to APPL_DB
296+
{
297+
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
298+
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
299+
}
300+
p.set(key, attrs);
301+
attrs.clear();
302+
autoneg_attrs.clear();
303+
force_attrs.clear();
304+
autoneg.clear();
254305
}
255306

256307
it = port_cfg_map.erase(it);

0 commit comments

Comments
 (0)