Skip to content

Commit

Permalink
[orchagent] Put port configuration to APPL_DB according to autoneg mo…
Browse files Browse the repository at this point in the history
…de (#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.
  • Loading branch information
Junchao-Mellanox authored Jul 7, 2021
1 parent 5295f91 commit ae44701
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
11 changes: 4 additions & 7 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2625,26 +2625,23 @@ void PortsOrch::doPortTask(Consumer &consumer)
{
an_str = fvValue(i);
}

/* Set advertised speeds */
if (fvField(i) == "adv_speeds")
else if (fvField(i) == "adv_speeds")
{
adv_speeds_str = fvValue(i);
}

/* Set interface type */
if (fvField(i) == "interface_type")
else if (fvField(i) == "interface_type")
{
interface_type_str = fvValue(i);
}

/* Set advertised interface type */
if (fvField(i) == "adv_interface_types")
else if (fvField(i) == "adv_interface_types")
{
adv_interface_types_str = fvValue(i);
}
/* Set port serdes Pre-emphasis */
if (fvField(i) == "preemphasis")
else if (fvField(i) == "preemphasis")
{
getPortSerdesVal(fvValue(i), attr_val);
serdes_attr.insert(serdes_attr_pair(SAI_PORT_SERDES_ATTR_PREEMPHASIS, attr_val));
Expand Down
53 changes: 52 additions & 1 deletion portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ bool handlePortConfigFromConfigDB(ProducerStateTable &p, DBConnector &cfgDb, boo

void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple> &port_cfg_map)
{
string autoneg;
vector<FieldValueTuple> attrs;
vector<FieldValueTuple> autoneg_attrs;
vector<FieldValueTuple> force_attrs;

auto it = port_cfg_map.begin();
while (it != port_cfg_map.end())
Expand All @@ -250,7 +254,54 @@ void handlePortConfig(ProducerStateTable &p, map<string, KeyOpFieldsValuesTuple>
/* No support for port delete yet */
if (op == SET_COMMAND)
{
p.set(key, values);

for (auto i : values)
{
auto field = fvField(i);
if (field == "adv_speeds")
{
autoneg_attrs.push_back(i);
}
else if (field == "adv_interface_types")
{
autoneg_attrs.push_back(i);
}
else if (field == "speed")
{
force_attrs.push_back(i);
}
else if (field == "interface_type")
{
force_attrs.push_back(i);
}
else if (field == "autoneg")
{
autoneg = fvValue(i);
attrs.push_back(i);
}
else
{
attrs.push_back(i);
}
}
if (autoneg == "on") // autoneg is on, only put adv_speeds and adv_interface_types to APPL_DB
{
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
}
else if (autoneg == "off") // autoneg is off, only put speed and interface_type to APPL_DB
{
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
}
else // autoneg is not configured, put all attributes to APPL_DB
{
attrs.insert(attrs.end(), autoneg_attrs.begin(), autoneg_attrs.end());
attrs.insert(attrs.end(), force_attrs.begin(), force_attrs.end());
}
p.set(key, attrs);
attrs.clear();
autoneg_attrs.clear();
force_attrs.clear();
autoneg.clear();
}

it = port_cfg_map.erase(it);
Expand Down

0 comments on commit ae44701

Please sign in to comment.