Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

merge azure sonic-swss master #1

Merged
merged 30 commits into from
May 22, 2018
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
114faa4
Align with swss-common table name separator changes (#454)
jleveque Apr 11, 2018
98c084a
FdbOrch getPort failed because fdb_entry have no switch_id (#466)
tylerlinp Apr 11, 2018
046628b
[pfcwd]: support BIG_RED_SWITCH mode (#467)
sihuihan88 Apr 13, 2018
a97f3ce
Use the refactored version of Selectables (#470)
pavel-shirshov Apr 16, 2018
880c1e9
[vlanmgr]: Fix the incorrect ip link del command for vlan remove (#474)
jipanyang Apr 16, 2018
57c9425
[crmorch]: neighbor used counter increased twice (#472)
tylerlinp Apr 17, 2018
e849afe
Use priorities in orch (#475)
pavel-shirshov Apr 17, 2018
d2c5a52
Updated CRM test case to check for exact used counter (#476)
prsunny Apr 18, 2018
aef6a46
[Portsorch]: The mtu configuration on the port cannot be updated if t…
leoli-nps Apr 19, 2018
39523aa
[orchagent]: Remove global lock caused by notifications running in an…
pavel-shirshov Apr 19, 2018
84ce5ed
[pfcwd]: create PFCWD acl instead of L3 ACL (#479)
sihuihan88 Apr 20, 2018
ccaa769
Fix ZeroBufferProfile parameters (#485)
andriymoroz-mlnx Apr 23, 2018
32bb66f
Fix tables handling race condition in buffermgr (#484)
andriymoroz-mlnx Apr 24, 2018
4a26e15
[counters]:separate query of port/queue counters (#483)
sihuihan88 Apr 24, 2018
edafa34
[buffermgr]: remove the item from consumer queue if invalid (#489)
sihuihan88 Apr 26, 2018
f939b95
[qosorch]: Optimizations of qosorch (#488)
pavel-shirshov Apr 27, 2018
bc97597
Add ipv6 ACL support in schema file (#490)
zhenggen-xu Apr 30, 2018
bb85c72
Populate existing interface cache, bring down before configDone (#491)
prsunny May 1, 2018
f71005a
[lua]: use not to check whether the field exists (#492)
sihuihan88 May 2, 2018
477d124
[PFCWD]: Periodically poll WD counters (#473)
marian-pritsak May 2, 2018
eef687e
[teamsyncd]: Add team_ifindex2ifname return value check (#500)
May 10, 2018
78c86ca
fix SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH value mismatch bug (#495)
yangbashuang May 10, 2018
0246df7
[copporch]: Add SAI_HOSTIF_TRAP_TYPE_UDLD (#480)
May 11, 2018
410b870
Don't print 'orchagent: :- doPortTask: Failed to get port id by alias…
pavel-shirshov May 14, 2018
681ba13
[aclorch]: remove SAI_ACL_TABLE_ATTR_FIELD_TC from data/mirror acl ty…
sihuihan88 May 16, 2018
1ac125e
[test]: add portchannel vs test (#507)
lguohan May 17, 2018
8314a94
[acl]: Insert new acl rule with priority in between other rules (#482)
simone-dell May 17, 2018
8d810be
[portsorch]: Rewrite validatePortSpeed() method. Use true lazy approa…
pavel-shirshov May 17, 2018
8c23538
[flexcounter]: add support to change port/queue counter poll interval…
sihuihan88 May 18, 2018
7331f92
[queuestat]: remove no need counters from query (#508)
sihuihan88 May 18, 2018
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
Prev Previous commit
Next Next commit
[portsorch]: Rewrite validatePortSpeed() method. Use true lazy approa…
…ch (sonic-net#506)

* We have enough logging inside of the method. Remove the excessive one

* Rewrite portsorch::validatespeed. Use true lazy approach to minimize SAI get operations on each port

* Restore the missed attr.id

* Rename validatePortSpeed to isSpeedSupported. Change logic to return true for erross also. Even we receive an error, we could move further. It's not critical
  • Loading branch information
pavel-shirshov authored May 17, 2018
commit 8d810bef7fcb81b0607afe71611e7bf34e8a3c12
83 changes: 54 additions & 29 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
@@ -757,54 +757,80 @@ bool PortsOrch::setHostIntfsStripTag(Port &port, sai_hostif_vlan_tag_t strip)
return true;
}

bool PortsOrch::validatePortSpeed(sai_object_id_t port_id, sai_uint32_t speed)
bool PortsOrch::isSpeedSupported(const std::string& alias, sai_object_id_t port_id, sai_uint32_t speed)
{
// This method will return false iff we get a list of supported speeds and the requested speed
// is not supported
// Otherwise the method will return true (even if we received errors)

sai_attribute_t attr;
sai_status_t status;

// "Lazy" query of supported speeds for given port
// Once received the list will be stored in m_portSupportedSpeeds
if (!m_portSupportedSpeeds.count(port_id))
{
attr.id = SAI_PORT_ATTR_SUPPORTED_SPEED;
attr.value.u32list.count = 0;
attr.value.u32list.list = NULL;
const auto size_guess = 25; // Guess the size which could be enough

status = sai_port_api->get_port_attribute(port_id, 1, &attr);
if (status == SAI_STATUS_BUFFER_OVERFLOW)
{
std::vector<sai_uint32_t> speeds(attr.value.u32list.count);
std::vector<sai_uint32_t> speeds(size_guess);

for (int attempt = 0; attempt < 2; ++attempt) // two attempts to get our value
{ // first with the guess,
// other with the returned value
attr.id = SAI_PORT_ATTR_SUPPORTED_SPEED;
attr.value.u32list.count = static_cast<uint32_t>(speeds.size());
attr.value.u32list.list = speeds.data();

status = sai_port_api->get_port_attribute(port_id, 1, &attr);
if (status == SAI_STATUS_SUCCESS)
if (status != SAI_STATUS_BUFFER_OVERFLOW)
{
m_portSupportedSpeeds[port_id] = speeds;
}
else
{
SWSS_LOG_ERROR("Failed to get supported speed list for port %lx", port_id);
return false;
break;
}

speeds.resize(attr.value.u32list.count); // if our guess was wrong
// retry with the correct value
}
// TODO: change to macro SAI_STATUS_IS_ATTR_NOT_SUPPORTED once it is fixed in SAI
// https://github.com/opencomputeproject/SAI/pull/710
else if ((((status) & (~0xFFFF)) == SAI_STATUS_ATTR_NOT_SUPPORTED_0) ||
(((status) & (~0xFFFF)) == SAI_STATUS_ATTR_NOT_IMPLEMENTED_0) ||
(status == SAI_STATUS_NOT_IMPLEMENTED))

if (status == SAI_STATUS_SUCCESS)
{
// unable to validate speed if attribute is not supported on platform
// assuming input value is correct
SWSS_LOG_WARN("Unable to validate speed for port %lx. Not supported by platform", port_id);
return true;
speeds.resize(attr.value.u32list.count);
m_portSupportedSpeeds[port_id] = speeds;
}
else
{
SWSS_LOG_ERROR("Failed to get number of supported speeds for port %lx", port_id);
return false;
if (status == SAI_STATUS_BUFFER_OVERFLOW)
{
// something went wrong in SAI implementation
SWSS_LOG_ERROR("Failed to get supported speed list for port %s id=%lx. Not enough container size",
alias.c_str(), port_id);
}
else if (SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) ||
SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status) ||
status == SAI_STATUS_NOT_IMPLEMENTED)
{
// unable to validate speed if attribute is not supported on platform
// assuming input value is correct
SWSS_LOG_WARN("Unable to validate speed for port %s id=%lx. Not supported by platform",
alias.c_str(), port_id);
}
else
{
SWSS_LOG_ERROR("Failed to get a list of supported speeds for port %s id=%lx. Error=%d",
alias.c_str(), port_id, status);
}
m_portSupportedSpeeds[port_id] = {}; // use an empty list,
// we don't want to get the port speed for this port again
return true; // we can't check if the speed is valid, so return true to change the speed
}

}

PortSupportedSpeeds &supp_speeds = m_portSupportedSpeeds[port_id];
const PortSupportedSpeeds &supp_speeds = m_portSupportedSpeeds[port_id];
if (supp_speeds.size() == 0)
{
// we don't have the list for this port, so return true to change speed anyway
return true;
}

return std::find(supp_speeds.begin(), supp_speeds.end(), speed) != supp_speeds.end();
}
@@ -1236,9 +1262,8 @@ void PortsOrch::doPortTask(Consumer &consumer)
{
sai_uint32_t current_speed;

if (!validatePortSpeed(p.m_port_id, speed))
if (!isSpeedSupported(alias, p.m_port_id, speed))
{
SWSS_LOG_ERROR("Failed to set speed %u for port %s. The value is not supported", speed, alias.c_str());
it++;
continue;
}
2 changes: 1 addition & 1 deletion orchagent/portsorch.h
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ class PortsOrch : public Orch, public Subject

bool setBridgePortAdminStatus(sai_object_id_t id, bool up);

bool validatePortSpeed(sai_object_id_t port_id, sai_uint32_t speed);
bool isSpeedSupported(const std::string& alias, sai_object_id_t port_id, sai_uint32_t speed);
bool setPortSpeed(sai_object_id_t port_id, sai_uint32_t speed);
bool getPortSpeed(sai_object_id_t port_id, sai_uint32_t &speed);