14
14
extern PortsOrch *gPortsOrch ;
15
15
16
16
17
- WatermarkOrch::WatermarkOrch (DBConnector *db, const string tableName ):
18
- Orch(db, tableName )
17
+ WatermarkOrch::WatermarkOrch (DBConnector *db, const vector< string> &tables ):
18
+ Orch(db, tables )
19
19
{
20
20
SWSS_LOG_ENTER ();
21
21
@@ -36,9 +36,6 @@ WatermarkOrch::WatermarkOrch(DBConnector *db, const string tableName):
36
36
m_telemetryTimer = new SelectableTimer (intervT);
37
37
auto executorT = new ExecutableTimer (m_telemetryTimer, this , " WM_TELEMETRY_TIMER" );
38
38
Orch::addExecutor (executorT);
39
- m_telemetryTimer->start ();
40
-
41
- m_telemetryInterval = DEFAULT_TELEMETRY_INTERVAL;
42
39
}
43
40
44
41
WatermarkOrch::~WatermarkOrch ()
@@ -66,19 +63,13 @@ void WatermarkOrch::doTask(Consumer &consumer)
66
63
67
64
if (op == SET_COMMAND)
68
65
{
69
- if (key == " TELEMETRY_INTERVAL " )
66
+ if (consumer. getTableName () == CFG_WATERMARK_TABLE_NAME )
70
67
{
71
- for (std::pair<std::basic_string<char >, std::basic_string<char > > i: fvt)
72
- {
73
- if (i.first == " interval" )
74
- {
75
- m_telemetryInterval = to_uint<uint32_t >(i.second .c_str ());
76
- }
77
- else
78
- {
79
- SWSS_LOG_WARN (" Unsupported key: %s" , i.first .c_str ());
80
- }
81
- }
68
+ handleWmConfigUpdate (key, fvt);
69
+ }
70
+ else if (consumer.getTableName () == CFG_FLEX_COUNTER_TABLE_NAME)
71
+ {
72
+ handleFcConfigUpdate (key, fvt);
82
73
}
83
74
}
84
75
else if (op == DEL_COMMAND)
@@ -94,13 +85,74 @@ void WatermarkOrch::doTask(Consumer &consumer)
94
85
}
95
86
}
96
87
88
+ void WatermarkOrch::handleWmConfigUpdate (const std::string &key, const std::vector<FieldValueTuple> &fvt)
89
+ {
90
+ SWSS_LOG_ENTER ();
91
+ if (key == " TELEMETRY_INTERVAL" )
92
+ {
93
+ for (std::pair<std::basic_string<char >, std::basic_string<char > > i: fvt)
94
+ {
95
+ if (i.first == " interval" )
96
+ {
97
+ auto intervT = timespec { .tv_sec = to_uint<uint32_t >(i.second .c_str ()) , .tv_nsec = 0 };
98
+ m_telemetryTimer->setInterval (intervT);
99
+ // reset the timer interval when current timer expires
100
+ m_timerChanged = true ;
101
+ }
102
+ else
103
+ {
104
+ SWSS_LOG_WARN (" Unsupported key: %s" , i.first .c_str ());
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ void WatermarkOrch::handleFcConfigUpdate (const std::string &key, const std::vector<FieldValueTuple> &fvt)
111
+ {
112
+ SWSS_LOG_ENTER ();
113
+ uint8_t prevStatus = m_wmStatus;
114
+ if (key == " QUEUE_WATERMARK" || key == " PG_WATERMARK" )
115
+ {
116
+ for (std::pair<std::basic_string<char >, std::basic_string<char > > i: fvt)
117
+ {
118
+ if (i.first == " FLEX_COUNTER_STATUS" )
119
+ {
120
+ if (i.second == " enable" )
121
+ {
122
+ m_wmStatus = (uint8_t ) (m_wmStatus | groupToMask.at (key));
123
+ }
124
+ else if (i.second == " disable" )
125
+ {
126
+ m_wmStatus = (uint8_t ) (m_wmStatus & ~(groupToMask.at (key)));
127
+ }
128
+ }
129
+ }
130
+ if (!prevStatus && m_wmStatus)
131
+ {
132
+ m_telemetryTimer->start ();
133
+ }
134
+ SWSS_LOG_DEBUG (" Status of WMs: %u" , m_wmStatus);
135
+ }
136
+ }
137
+
97
138
void WatermarkOrch::doTask (NotificationConsumer &consumer)
98
139
{
140
+ SWSS_LOG_ENTER ();
99
141
if (!gPortsOrch ->isPortReady ())
100
142
{
101
143
return ;
102
144
}
103
145
146
+ if (m_pg_ids.empty ())
147
+ {
148
+ init_pg_ids ();
149
+ }
150
+
151
+ if (m_multicast_queue_ids.empty () and m_unicast_queue_ids.empty ())
152
+ {
153
+ init_queue_ids ();
154
+ }
155
+
104
156
std::string op;
105
157
std::string data;
106
158
std::vector<swss::FieldValueTuple> values;
@@ -170,16 +222,21 @@ void WatermarkOrch::doTask(SelectableTimer &timer)
170
222
171
223
if (&timer == m_telemetryTimer)
172
224
{
173
- /* If the interval was changed */
174
- auto intervT = timespec { .tv_sec = m_telemetryInterval , .tv_nsec = 0 };
175
- m_telemetryTimer->setInterval (intervT);
176
- m_telemetryTimer->reset ();
225
+ if (m_timerChanged)
226
+ {
227
+ m_telemetryTimer->reset ();
228
+ m_timerChanged = false ;
229
+ }
230
+ if (!m_wmStatus)
231
+ {
232
+ m_telemetryTimer->stop ();
233
+ }
177
234
178
235
clearSingleWm (m_periodicWatermarkTable.get (), " SAI_INGRESS_PRIORITY_GROUP_STAT_XOFF_ROOM_WATERMARK_BYTES" , m_pg_ids);
179
236
clearSingleWm (m_periodicWatermarkTable.get (), " SAI_INGRESS_PRIORITY_GROUP_STAT_SHARED_WATERMARK_BYTES" , m_pg_ids);
180
237
clearSingleWm (m_periodicWatermarkTable.get (), " SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES" , m_unicast_queue_ids);
181
238
clearSingleWm (m_periodicWatermarkTable.get (), " SAI_QUEUE_STAT_SHARED_WATERMARK_BYTES" , m_multicast_queue_ids);
182
- SWSS_LOG_INFO (" Periodic watermark cleared by timer!" );
239
+ SWSS_LOG_DEBUG (" Periodic watermark cleared by timer!" );
183
240
}
184
241
}
185
242
0 commit comments