Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
  • Loading branch information
Mykola Faryma committed Apr 19, 2019
1 parent 53d9766 commit 48ee316
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
18 changes: 11 additions & 7 deletions orchagent/watermarkorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void WatermarkOrch::doTask(Consumer &consumer)

void WatermarkOrch::handleWmConfigUpdate(const std::string &key, const std::vector<FieldValueTuple> &fvt)
{
SWSS_LOG_ENTER();
if (key == "TELEMETRY_INTERVAL")
{
for (std::pair<std::basic_string<char>, std::basic_string<char> > i: fvt)
Expand All @@ -107,32 +108,35 @@ void WatermarkOrch::handleWmConfigUpdate(const std::string &key, const std::vect

void WatermarkOrch::handleFcConfigUpdate(const std::string &key, const std::vector<FieldValueTuple> &fvt)
{

SWSS_LOG_ENTER();
uint8_t prevStatus = m_wmStatus;
if (key == "QUEUE_WATERMARK" || key == "PG_WATERMARK")
{
for (std::pair<std::basic_string<char>, std::basic_string<char> > i: fvt)
{
if (i.first == "FLEX_COUNTER_STATUS")
{
if (key == "QUEUE_WATERMARK")
if (i.second == "enable")
{
m_qWmEnabled = (i.second == "enable");
m_wmStatus = (uint8_t) (m_wmStatus | groupToMask.at(key));
}
else if (key == "PG_WATERMARK")
else if (i.second == "disable")
{
m_pgWmEnabled = (i.second == "enable");
m_wmStatus = (uint8_t) (m_wmStatus & ~(groupToMask.at(key)));
}
}
}
if (isTimerEnabled())
if (!prevStatus && m_wmStatus)
{
m_telemetryTimer->start();
}
SWSS_LOG_DEBUG("Status of WMs: %u", m_wmStatus);
}
}

void WatermarkOrch::doTask(NotificationConsumer &consumer)
{
SWSS_LOG_ENTER();
if (!gPortsOrch->isPortReady())
{
return;
Expand Down Expand Up @@ -209,7 +213,7 @@ void WatermarkOrch::doTask(SelectableTimer &timer)
{
/* Timer is only running when the watermark polling is on *
* if it is disabled we will not restart the timer at the end of current interval */
if (isTimerEnabled())
if (m_wmStatus)
{
m_telemetryTimer->reset();
}
Expand Down
23 changes: 16 additions & 7 deletions orchagent/watermarkorch.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
#ifndef WATERMARKORCH_H
#define WATERMARKORCH_H

#include <map>

#include "orch.h"
#include "port.h"

#include "notificationconsumer.h"
#include "timer.h"

const uint8_t queue_wm_status_mask = 1 << 0;
const uint8_t pg_wm_status_mask = 1 << 1;

static const map<string, const uint8_t> groupToMask =
{
{ "QUEUE_WATERMARK", queue_wm_status_mask },
{ "PG_WATERMARK", pg_wm_status_mask }
};

class WatermarkOrch : public Orch
{
Expand Down Expand Up @@ -36,14 +46,13 @@ class WatermarkOrch : public Orch
return m_countersDb;
}

bool isTimerEnabled()
{
return m_qWmEnabled || m_pgWmEnabled;
}

private:
bool m_qWmEnabled = false;
bool m_pgWmEnabled = false;
/*
[7-2] - unused
[1] - pg wm status
[0] - queue wm status (least significant bit)
*/
uint8_t m_wmStatus = 0;

shared_ptr<DBConnector> m_countersDb = nullptr;
shared_ptr<DBConnector> m_appDb = nullptr;
Expand Down

0 comments on commit 48ee316

Please sign in to comment.