Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[orchagent] Put port configuration to APPL_DB according to autoneg mode #1769

Merged
merged 1 commit into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2507,26 +2507,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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this handled during warmboot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special treatment for warmboot

attrs.clear();
autoneg_attrs.clear();
force_attrs.clear();
autoneg.clear();
}

it = port_cfg_map.erase(it);
Expand Down