Skip to content

Commit

Permalink
Align watermark flow with port configuration (#2525)
Browse files Browse the repository at this point in the history
*Align watermark flow with port configuration correct the queue, watermark and pg-drop counterpoll functionality according to cli commands
  • Loading branch information
dbarashinvd authored and StormLiangMS committed Dec 27, 2022
1 parent dca78d8 commit 782a2ef
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 137 deletions.
36 changes: 20 additions & 16 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,13 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
{
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
auto queues = tokens[1];
if (op == SET_COMMAND && flexCounterOrch->getQueueCountersState())
if (op == SET_COMMAND &&
(flexCounterOrch->getQueueCountersState() || flexCounterOrch->getQueueWatermarkCountersState()))
{
gPortsOrch->createPortBufferQueueCounters(port, queues);
}
else if (op == DEL_COMMAND && flexCounterOrch->getQueueCountersState())
else if (op == DEL_COMMAND &&
(flexCounterOrch->getQueueCountersState() || flexCounterOrch->getQueueWatermarkCountersState()))
{
gPortsOrch->removePortBufferQueueCounters(port, queues);
}
Expand All @@ -841,23 +843,23 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
* so we added a map that will help us to know what was the last command for this port and priority -
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
if (op == SET_COMMAND)
if (op == SET_COMMAND)
{
if (queue_port_flags[port_name][ind] != SET_COMMAND)
if (queue_port_flags[port_name][ind] != SET_COMMAND)
{
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
gPortsOrch->increasePortRefCount(port_name);
}
}
}
else if (op == DEL_COMMAND)
{
if (queue_port_flags[port_name][ind] == SET_COMMAND)
if (queue_port_flags[port_name][ind] == SET_COMMAND)
{
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
gPortsOrch->decreasePortRefCount(port_name);
}
}
else
}
else
{
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
return task_process_status::task_invalid_entry;
Expand Down Expand Up @@ -1001,11 +1003,13 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
{
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
auto pgs = tokens[1];
if (op == SET_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
if (op == SET_COMMAND &&
(flexCounterOrch->getPgCountersState() || flexCounterOrch->getPgWatermarkCountersState()))
{
gPortsOrch->createPortBufferPgCounters(port, pgs);
}
else if (op == DEL_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
else if (op == DEL_COMMAND &&
(flexCounterOrch->getPgCountersState() || flexCounterOrch->getPgWatermarkCountersState()))
{
gPortsOrch->removePortBufferPgCounters(port, pgs);
}
Expand All @@ -1021,23 +1025,23 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
* so we added a map that will help us to know what was the last command for this port and priority -
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
if (op == SET_COMMAND)
if (op == SET_COMMAND)
{
if (pg_port_flags[port_name][ind] != SET_COMMAND)
if (pg_port_flags[port_name][ind] != SET_COMMAND)
{
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
gPortsOrch->increasePortRefCount(port_name);
}
}
}
else if (op == DEL_COMMAND)
{
if (pg_port_flags[port_name][ind] == SET_COMMAND)
if (pg_port_flags[port_name][ind] == SET_COMMAND)
{
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
gPortsOrch->decreasePortRefCount(port_name);
}
}
else
}
else
{
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
return task_process_status::task_invalid_entry;
Expand Down
34 changes: 30 additions & 4 deletions orchagent/flexcounterorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
#define PORT_KEY "PORT"
#define PORT_BUFFER_DROP_KEY "PORT_BUFFER_DROP"
#define QUEUE_KEY "QUEUE"
#define QUEUE_WATERMARK "QUEUE_WATERMARK"
#define PG_WATERMARK_KEY "PG_WATERMARK"
#define PG_DROP_KEY "PG_DROP"
#define RIF_KEY "RIF"
#define ACL_KEY "ACL"
#define TUNNEL_KEY "TUNNEL"
Expand Down Expand Up @@ -162,11 +164,25 @@ void FlexCounterOrch::doTask(Consumer &consumer)
{
gPortsOrch->generateQueueMap(getQueueConfigurations());
m_queue_enabled = true;
gPortsOrch->addQueueFlexCounters(getQueueConfigurations());
}
else if(key == QUEUE_WATERMARK)
{
gPortsOrch->generateQueueMap(getQueueConfigurations());
m_queue_watermark_enabled = true;
gPortsOrch->addQueueWatermarkFlexCounters(getQueueConfigurations());
}
else if(key == PG_DROP_KEY)
{
gPortsOrch->generatePriorityGroupMap(getPgConfigurations());
m_pg_enabled = true;
gPortsOrch->addPriorityGroupFlexCounters(getPgConfigurations());
}
else if(key == PG_WATERMARK_KEY)
{
gPortsOrch->generatePriorityGroupMap(getPgConfigurations());
m_pg_watermark_enabled = true;
gPortsOrch->addPriorityGroupWatermarkFlexCounters(getPgConfigurations());
}
}
if(gIntfsOrch && (key == RIF_KEY) && (value == "enable"))
Expand Down Expand Up @@ -250,14 +266,24 @@ bool FlexCounterOrch::getPortBufferDropCountersState() const
return m_port_buffer_drop_counter_enabled;
}

bool FlexCounterOrch::getPgWatermarkCountersState() const
bool FlexCounterOrch::getQueueCountersState() const
{
return m_pg_watermark_enabled;
return m_queue_enabled;
}

bool FlexCounterOrch::getQueueCountersState() const
bool FlexCounterOrch::getQueueWatermarkCountersState() const
{
return m_queue_enabled;
return m_queue_watermark_enabled;
}

bool FlexCounterOrch::getPgCountersState() const
{
return m_pg_enabled;
}

bool FlexCounterOrch::getPgWatermarkCountersState() const
{
return m_pg_watermark_enabled;
}

bool FlexCounterOrch::bake()
Expand Down
8 changes: 6 additions & 2 deletions orchagent/flexcounterorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ class FlexCounterOrch: public Orch
virtual ~FlexCounterOrch(void);
bool getPortCountersState() const;
bool getPortBufferDropCountersState() const;
bool getPgWatermarkCountersState() const;
bool getQueueCountersState() const;
bool getQueueWatermarkCountersState() const;
bool getPgCountersState() const;
bool getPgWatermarkCountersState() const;
std::map<std::string, FlexCounterQueueStates> getQueueConfigurations();
std::map<std::string, FlexCounterPgStates> getPgConfigurations();
bool getHostIfTrapCounterState() const {return m_hostif_trap_counter_enabled;}
Expand All @@ -57,8 +59,10 @@ class FlexCounterOrch: public Orch
std::shared_ptr<ProducerTable> m_gbflexCounterGroupTable = nullptr;
bool m_port_counter_enabled = false;
bool m_port_buffer_drop_counter_enabled = false;
bool m_pg_watermark_enabled = false;
bool m_queue_enabled = false;
bool m_queue_watermark_enabled = false;
bool m_pg_enabled = false;
bool m_pg_watermark_enabled = false;
bool m_hostif_trap_counter_enabled = false;
bool m_route_flow_counter_enabled = false;
Table m_flexCounterConfigTable;
Expand Down
Loading

0 comments on commit 782a2ef

Please sign in to comment.