Skip to content

Commit

Permalink
Moving speed setting below interface type setting
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Sep 3, 2024
1 parent 42ea859 commit b148163
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4169,29 +4169,17 @@ void PortsOrch::doPortTask(Consumer &consumer)
SWSS_LOG_NOTICE("Set port %s link event damping config successfully", p.m_alias.c_str());
}

if (pCfg.speed.is_set)
if (pCfg.adv_speeds.is_set)
{
if (p.m_speed != pCfg.speed.value)
if (!p.m_adv_speed_cfg || p.m_adv_speeds != pCfg.adv_speeds.value)
{
if (!isSpeedSupported(p.m_alias, p.m_port_id, pCfg.speed.value))
{
SWSS_LOG_ERROR(
"Unsupported port %s speed %u",
p.m_alias.c_str(), pCfg.speed.value
);
// Speed not supported, dont retry
it = taskMap.erase(it);
continue;
}

// for backward compatible, if autoneg is off, toggle admin status
if (p.m_admin_state_up && !p.m_autoneg)
if (p.m_admin_state_up && p.m_autoneg)
{
/* Bring port down before applying speed */
if (!setPortAdminStatus(p, false))
{
SWSS_LOG_ERROR(
"Failed to set port %s admin status DOWN to set speed",
"Failed to set port %s admin status DOWN to set interface type",
p.m_alias.c_str()
);
it++;
Expand All @@ -4202,12 +4190,14 @@ void PortsOrch::doPortTask(Consumer &consumer)
m_portList[p.m_alias] = p;
}

auto status = setPortSpeed(p, pCfg.speed.value);
auto adv_speeds = swss::join(',', pCfg.adv_speeds.value.begin(), pCfg.adv_speeds.value.end());
auto ori_adv_speeds = swss::join(',', p.m_adv_speeds.begin(), p.m_adv_speeds.end());
auto status = setPortAdvSpeeds(p, pCfg.adv_speeds.value);
if (status != task_success)
{
SWSS_LOG_ERROR(
"Failed to set port %s speed from %u to %u",
p.m_alias.c_str(), p.m_speed, pCfg.speed.value
"Failed to set port %s advertised speed from %s to %s",
p.m_alias.c_str(), ori_adv_speeds.c_str(), adv_speeds.c_str()
);
if (status == task_need_retry)
{
Expand All @@ -4220,26 +4210,22 @@ void PortsOrch::doPortTask(Consumer &consumer)
continue;
}

p.m_speed = pCfg.speed.value;
p.m_adv_speeds = pCfg.adv_speeds.value;
p.m_adv_speed_cfg = true;
m_portList[p.m_alias] = p;

SWSS_LOG_NOTICE(
"Set port %s speed to %u",
p.m_alias.c_str(), pCfg.speed.value
"Set port %s advertised speed from %s to %s",
p.m_alias.c_str(), ori_adv_speeds.c_str(), adv_speeds.c_str()
);
}
else
{
/* Always update Gearbox speed on Gearbox ports */
setGearboxPortsAttr(p, SAI_PORT_ATTR_SPEED, &pCfg.speed.value);
}
}

if (pCfg.adv_speeds.is_set)
if (pCfg.interface_type.is_set)
{
if (!p.m_adv_speed_cfg || p.m_adv_speeds != pCfg.adv_speeds.value)
if (!p.m_intf_cfg || p.m_interface_type != pCfg.interface_type.value)
{
if (p.m_admin_state_up && p.m_autoneg)
if (p.m_admin_state_up && !p.m_autoneg)
{
/* Bring port down before applying speed */
if (!setPortAdminStatus(p, false))
Expand All @@ -4256,14 +4242,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
m_portList[p.m_alias] = p;
}

auto adv_speeds = swss::join(',', pCfg.adv_speeds.value.begin(), pCfg.adv_speeds.value.end());
auto ori_adv_speeds = swss::join(',', p.m_adv_speeds.begin(), p.m_adv_speeds.end());
auto status = setPortAdvSpeeds(p, pCfg.adv_speeds.value);
auto status = setPortInterfaceType(p, pCfg.interface_type.value);
if (status != task_success)
{
SWSS_LOG_ERROR(
"Failed to set port %s advertised speed from %s to %s",
p.m_alias.c_str(), ori_adv_speeds.c_str(), adv_speeds.c_str()
"Failed to set port %s interface type to %s",
p.m_alias.c_str(), m_portHlpr.getPortInterfaceTypeStr(pCfg).c_str()
);
if (status == task_need_retry)
{
Expand All @@ -4276,28 +4260,40 @@ void PortsOrch::doPortTask(Consumer &consumer)
continue;
}

p.m_adv_speeds = pCfg.adv_speeds.value;
p.m_adv_speed_cfg = true;
p.m_interface_type = pCfg.interface_type.value;
p.m_intf_cfg = true;
m_portList[p.m_alias] = p;

SWSS_LOG_NOTICE(
"Set port %s advertised speed from %s to %s",
p.m_alias.c_str(), ori_adv_speeds.c_str(), adv_speeds.c_str()
"Set port %s interface type to %s",
p.m_alias.c_str(), m_portHlpr.getPortInterfaceTypeStr(pCfg).c_str()
);
}
}

if (pCfg.interface_type.is_set)
if (pCfg.speed.is_set)
{
if (!p.m_intf_cfg || p.m_interface_type != pCfg.interface_type.value)
if (p.m_speed != pCfg.speed.value)
{
if (!isSpeedSupported(p.m_alias, p.m_port_id, pCfg.speed.value))
{
SWSS_LOG_ERROR(
"Unsupported port %s speed %u",
p.m_alias.c_str(), pCfg.speed.value
);
// Speed not supported, dont retry
it = taskMap.erase(it);
continue;
}

// for backward compatible, if autoneg is off, toggle admin status
if (p.m_admin_state_up && !p.m_autoneg)
{
/* Bring port down before applying speed */
if (!setPortAdminStatus(p, false))
{
SWSS_LOG_ERROR(
"Failed to set port %s admin status DOWN to set interface type",
"Failed to set port %s admin status DOWN to set speed",
p.m_alias.c_str()
);
it++;
Expand All @@ -4308,12 +4304,12 @@ void PortsOrch::doPortTask(Consumer &consumer)
m_portList[p.m_alias] = p;
}

auto status = setPortInterfaceType(p, pCfg.interface_type.value);
auto status = setPortSpeed(p, pCfg.speed.value);
if (status != task_success)
{
SWSS_LOG_ERROR(
"Failed to set port %s interface type to %s",
p.m_alias.c_str(), m_portHlpr.getPortInterfaceTypeStr(pCfg).c_str()
"Failed to set port %s speed from %u to %u",
p.m_alias.c_str(), p.m_speed, pCfg.speed.value
);
if (status == task_need_retry)
{
Expand All @@ -4326,15 +4322,19 @@ void PortsOrch::doPortTask(Consumer &consumer)
continue;
}

p.m_interface_type = pCfg.interface_type.value;
p.m_intf_cfg = true;
p.m_speed = pCfg.speed.value;
m_portList[p.m_alias] = p;

SWSS_LOG_NOTICE(
"Set port %s interface type to %s",
p.m_alias.c_str(), m_portHlpr.getPortInterfaceTypeStr(pCfg).c_str()
"Set port %s speed to %u",
p.m_alias.c_str(), pCfg.speed.value
);
}
else
{
/* Always update Gearbox speed on Gearbox ports */
setGearboxPortsAttr(p, SAI_PORT_ATTR_SPEED, &pCfg.speed.value);
}
}

if (pCfg.adv_interface_types.is_set)
Expand Down

0 comments on commit b148163

Please # to comment.