Skip to content

Commit

Permalink
Allow buffer profile apply after init (sonic-net#1099)
Browse files Browse the repository at this point in the history
* Allow buffer profile application after init (i.e., at run time)

Signed-off-by: Wenda Ni <wenni@microsoft.com>

* Address comment: Alert when a buffer profile is applied after the
physical port is brought up

Signed-off-by: Wenda Ni <wenni@microsoft.com>

* Remove unnecessary space

Signed-off-by: Wenda Ni <wenni@microsoft.com>

* Correct logic

Signed-off-by: Wenda Ni <wenni@microsoft.com>

* Correct compile error

Signed-off-by: Wenda Ni <wenni@microsoft.com>
  • Loading branch information
wendani authored Oct 29, 2019
1 parent 20747fa commit 59440f2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
28 changes: 26 additions & 2 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,19 @@ task_process_status BufferOrch::processQueue(Consumer &consumer)
}
else
{
SWSS_LOG_ERROR("Queue profile '%s' was inserted after BufferOrch init", key.c_str());
// If a buffer queue profile is not in the initial CONFIG_DB BUFFER_QUEUE table
// at BufferOrch object instantiation, it is considered being applied
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
// the application to guarantee the set order that the buffer queue profile
// should be applied to a physical port before the physical port is brought up to
// carry traffic. Here, we alert to application through syslog when such a wrong
// set order is detected.
for (const auto &port_name : port_names)
{
if (gPortsOrch->isPortAdminUp(port_name)) {
SWSS_LOG_ERROR("Queue profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
}
}
}

return task_process_status::task_success;
Expand Down Expand Up @@ -666,7 +678,19 @@ task_process_status BufferOrch::processPriorityGroup(Consumer &consumer)
}
else
{
SWSS_LOG_ERROR("PG profile '%s' was inserted after BufferOrch init", key.c_str());
// If a buffer pg profile is not in the initial CONFIG_DB BUFFER_PG table
// at BufferOrch object instantiation, it is considered being applied
// at run time, and, in this case, is not tracked in the m_ready_list. It is up to
// the application to guarantee the set order that the buffer pg profile
// should be applied to a physical port before the physical port is brought up to
// carry traffic. Here, we alert to application through syslog when such a wrong
// set order is detected.
for (const auto &port_name : port_names)
{
if (gPortsOrch->isPortAdminUp(port_name)) {
SWSS_LOG_ERROR("PG profile '%s' applied after port %s is up", key.c_str(), port_name.c_str());
}
}
}

return task_process_status::task_success;
Expand Down
11 changes: 11 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ bool PortsOrch::isInitDone()
return m_initDone;
}

bool PortsOrch::isPortAdminUp(const string &alias)
{
auto it = m_portList.find(alias);
if (it == m_portList.end())
{
SWSS_LOG_ERROR("Failed to get Port object by port alias: %s", alias.c_str());
return false;
}

return it->second.m_admin_state_up;
}

map<string, Port>& PortsOrch::getAllPorts()
{
Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class PortsOrch : public Orch, public Subject

bool allPortsReady();
bool isInitDone();
bool isPortAdminUp(const string &alias);

map<string, Port>& getAllPorts();
bool bake() override;
Expand Down
1 change: 0 additions & 1 deletion portsyncd/portsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}


return 1;
}

Expand Down

0 comments on commit 59440f2

Please sign in to comment.