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 bc9a1e8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
32 changes: 22 additions & 10 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,37 +108,50 @@ 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;
}

if (m_pg_ids.empty())
{
init_pg_ids();
}

if (m_multicast_queue_ids.empty() and m_unicast_queue_ids.empty())
{
init_queue_ids();
}

std::string op;
std::string data;
std::vector<swss::FieldValueTuple> values;
Expand Down Expand Up @@ -207,11 +221,9 @@ void WatermarkOrch::doTask(SelectableTimer &timer)

if (&timer == m_telemetryTimer)
{
/* 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();
m_telemetryTimer->stop();
}

clearSingleWm(m_periodicWatermarkTable.get(), "SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES", m_pg_ids);
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 bc9a1e8

Please sign in to comment.