Skip to content

Commit b865352

Browse files
authored
Align watermark flow with port configuration (#2525)
*Align watermark flow with port configuration correct the queue, watermark and pg-drop counterpoll functionality according to cli commands
1 parent f2d2fb3 commit b865352

File tree

6 files changed

+389
-137
lines changed

6 files changed

+389
-137
lines changed

orchagent/bufferorch.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,13 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
822822
{
823823
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
824824
auto queues = tokens[1];
825-
if (op == SET_COMMAND && flexCounterOrch->getQueueCountersState())
825+
if (op == SET_COMMAND &&
826+
(flexCounterOrch->getQueueCountersState() || flexCounterOrch->getQueueWatermarkCountersState()))
826827
{
827828
gPortsOrch->createPortBufferQueueCounters(port, queues);
828829
}
829-
else if (op == DEL_COMMAND && flexCounterOrch->getQueueCountersState())
830+
else if (op == DEL_COMMAND &&
831+
(flexCounterOrch->getQueueCountersState() || flexCounterOrch->getQueueWatermarkCountersState()))
830832
{
831833
gPortsOrch->removePortBufferQueueCounters(port, queues);
832834
}
@@ -841,23 +843,23 @@ task_process_status BufferOrch::processQueue(KeyOpFieldsValuesTuple &tuple)
841843
* so we added a map that will help us to know what was the last command for this port and priority -
842844
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
843845
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
844-
if (op == SET_COMMAND)
846+
if (op == SET_COMMAND)
845847
{
846-
if (queue_port_flags[port_name][ind] != SET_COMMAND)
848+
if (queue_port_flags[port_name][ind] != SET_COMMAND)
847849
{
848850
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
849851
gPortsOrch->increasePortRefCount(port_name);
850852
}
851-
}
853+
}
852854
else if (op == DEL_COMMAND)
853855
{
854-
if (queue_port_flags[port_name][ind] == SET_COMMAND)
856+
if (queue_port_flags[port_name][ind] == SET_COMMAND)
855857
{
856858
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
857859
gPortsOrch->decreasePortRefCount(port_name);
858860
}
859-
}
860-
else
861+
}
862+
else
861863
{
862864
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
863865
return task_process_status::task_invalid_entry;
@@ -1001,11 +1003,13 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
10011003
{
10021004
auto flexCounterOrch = gDirectory.get<FlexCounterOrch*>();
10031005
auto pgs = tokens[1];
1004-
if (op == SET_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
1006+
if (op == SET_COMMAND &&
1007+
(flexCounterOrch->getPgCountersState() || flexCounterOrch->getPgWatermarkCountersState()))
10051008
{
10061009
gPortsOrch->createPortBufferPgCounters(port, pgs);
10071010
}
1008-
else if (op == DEL_COMMAND && flexCounterOrch->getPgWatermarkCountersState())
1011+
else if (op == DEL_COMMAND &&
1012+
(flexCounterOrch->getPgCountersState() || flexCounterOrch->getPgWatermarkCountersState()))
10091013
{
10101014
gPortsOrch->removePortBufferPgCounters(port, pgs);
10111015
}
@@ -1021,23 +1025,23 @@ task_process_status BufferOrch::processPriorityGroup(KeyOpFieldsValuesTuple &tup
10211025
* so we added a map that will help us to know what was the last command for this port and priority -
10221026
* if the last command was set command then it is a modify command and we dont need to increase the buffer counter
10231027
* all other cases (no last command exist or del command was the last command) it means that we need to increase the ref counter */
1024-
if (op == SET_COMMAND)
1028+
if (op == SET_COMMAND)
10251029
{
1026-
if (pg_port_flags[port_name][ind] != SET_COMMAND)
1030+
if (pg_port_flags[port_name][ind] != SET_COMMAND)
10271031
{
10281032
/* if the last operation was not "set" then it's create and not modify - need to increase ref counter */
10291033
gPortsOrch->increasePortRefCount(port_name);
10301034
}
1031-
}
1035+
}
10321036
else if (op == DEL_COMMAND)
10331037
{
1034-
if (pg_port_flags[port_name][ind] == SET_COMMAND)
1038+
if (pg_port_flags[port_name][ind] == SET_COMMAND)
10351039
{
10361040
/* we need to decrease ref counter only if the last operation was "SET_COMMAND" */
10371041
gPortsOrch->decreasePortRefCount(port_name);
10381042
}
1039-
}
1040-
else
1043+
}
1044+
else
10411045
{
10421046
SWSS_LOG_ERROR("operation value is not SET or DEL (op = %s)", op.c_str());
10431047
return task_process_status::task_invalid_entry;

orchagent/flexcounterorch.cpp

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ extern FlowCounterRouteOrch *gFlowCounterRouteOrch;
2929
#define PORT_KEY "PORT"
3030
#define PORT_BUFFER_DROP_KEY "PORT_BUFFER_DROP"
3131
#define QUEUE_KEY "QUEUE"
32+
#define QUEUE_WATERMARK "QUEUE_WATERMARK"
3233
#define PG_WATERMARK_KEY "PG_WATERMARK"
34+
#define PG_DROP_KEY "PG_DROP"
3335
#define RIF_KEY "RIF"
3436
#define ACL_KEY "ACL"
3537
#define TUNNEL_KEY "TUNNEL"
@@ -162,11 +164,25 @@ void FlexCounterOrch::doTask(Consumer &consumer)
162164
{
163165
gPortsOrch->generateQueueMap(getQueueConfigurations());
164166
m_queue_enabled = true;
167+
gPortsOrch->addQueueFlexCounters(getQueueConfigurations());
168+
}
169+
else if(key == QUEUE_WATERMARK)
170+
{
171+
gPortsOrch->generateQueueMap(getQueueConfigurations());
172+
m_queue_watermark_enabled = true;
173+
gPortsOrch->addQueueWatermarkFlexCounters(getQueueConfigurations());
174+
}
175+
else if(key == PG_DROP_KEY)
176+
{
177+
gPortsOrch->generatePriorityGroupMap(getPgConfigurations());
178+
m_pg_enabled = true;
179+
gPortsOrch->addPriorityGroupFlexCounters(getPgConfigurations());
165180
}
166181
else if(key == PG_WATERMARK_KEY)
167182
{
168183
gPortsOrch->generatePriorityGroupMap(getPgConfigurations());
169184
m_pg_watermark_enabled = true;
185+
gPortsOrch->addPriorityGroupWatermarkFlexCounters(getPgConfigurations());
170186
}
171187
}
172188
if(gIntfsOrch && (key == RIF_KEY) && (value == "enable"))
@@ -250,14 +266,24 @@ bool FlexCounterOrch::getPortBufferDropCountersState() const
250266
return m_port_buffer_drop_counter_enabled;
251267
}
252268

253-
bool FlexCounterOrch::getPgWatermarkCountersState() const
269+
bool FlexCounterOrch::getQueueCountersState() const
254270
{
255-
return m_pg_watermark_enabled;
271+
return m_queue_enabled;
256272
}
257273

258-
bool FlexCounterOrch::getQueueCountersState() const
274+
bool FlexCounterOrch::getQueueWatermarkCountersState() const
259275
{
260-
return m_queue_enabled;
276+
return m_queue_watermark_enabled;
277+
}
278+
279+
bool FlexCounterOrch::getPgCountersState() const
280+
{
281+
return m_pg_enabled;
282+
}
283+
284+
bool FlexCounterOrch::getPgWatermarkCountersState() const
285+
{
286+
return m_pg_watermark_enabled;
261287
}
262288

263289
bool FlexCounterOrch::bake()

orchagent/flexcounterorch.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ class FlexCounterOrch: public Orch
4242
virtual ~FlexCounterOrch(void);
4343
bool getPortCountersState() const;
4444
bool getPortBufferDropCountersState() const;
45-
bool getPgWatermarkCountersState() const;
4645
bool getQueueCountersState() const;
46+
bool getQueueWatermarkCountersState() const;
47+
bool getPgCountersState() const;
48+
bool getPgWatermarkCountersState() const;
4749
std::map<std::string, FlexCounterQueueStates> getQueueConfigurations();
4850
std::map<std::string, FlexCounterPgStates> getPgConfigurations();
4951
bool getHostIfTrapCounterState() const {return m_hostif_trap_counter_enabled;}
@@ -57,8 +59,10 @@ class FlexCounterOrch: public Orch
5759
std::shared_ptr<ProducerTable> m_gbflexCounterGroupTable = nullptr;
5860
bool m_port_counter_enabled = false;
5961
bool m_port_buffer_drop_counter_enabled = false;
60-
bool m_pg_watermark_enabled = false;
6162
bool m_queue_enabled = false;
63+
bool m_queue_watermark_enabled = false;
64+
bool m_pg_enabled = false;
65+
bool m_pg_watermark_enabled = false;
6266
bool m_hostif_trap_counter_enabled = false;
6367
bool m_route_flow_counter_enabled = false;
6468
Table m_flexCounterConfigTable;

0 commit comments

Comments
 (0)