Skip to content

Commit ce3ca56

Browse files
authored
Revert "[buffer orch] Bugfix: Don't query counter SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES on a pool where it is not supported (sonic-net#1857)" (sonic-net#1945)
This reverts commit 3d6b1f0. Fix sonic-net/sonic-buildimage#8893 What I did This commit had earlier caused issue on master image warmboot - sonic-net/sonic-buildimage#8722 To fix this issue, this PR was created to retreat sonic-swss head on buildimage - sonic-net/sonic-buildimage#8732 Now, this commit was again pulled into sonic-buildimage as part of sonic-swss submodule advance: sonic-net/sonic-buildimage#8839 And, warm-reboot again broke for the same reason. This change is so that any other swss submodule update on buildimage will not fail warmboot again.
1 parent 5df4f87 commit ce3ca56

1 file changed

Lines changed: 17 additions & 64 deletions

File tree

orchagent/bufferorch.cpp

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ extern sai_object_id_t gSwitchId;
2222

2323

2424
static const vector<sai_buffer_pool_stat_t> bufferPoolWatermarkStatIds =
25-
{
26-
SAI_BUFFER_POOL_STAT_WATERMARK_BYTES
27-
};
28-
29-
static const vector<sai_buffer_pool_stat_t> bufferSharedHeadroomPoolWatermarkStatIds =
30-
{
31-
SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
32-
};
33-
34-
static const vector<sai_buffer_pool_stat_t> bufferPoolAllWatermarkStatIds =
3525
{
3626
SAI_BUFFER_POOL_STAT_WATERMARK_BYTES,
3727
SAI_BUFFER_POOL_STAT_XOFF_ROOM_WATERMARK_BYTES
@@ -234,60 +224,29 @@ void BufferOrch::generateBufferPoolWatermarkCounterIdList(void)
234224
}
235225

236226
// Detokenize the SAI watermark stats to a string, separated by comma
237-
string statListBufferPoolOnly;
227+
string statList;
238228
for (const auto &it : bufferPoolWatermarkStatIds)
239229
{
240-
statListBufferPoolOnly += (sai_serialize_buffer_pool_stat(it) + list_item_delimiter);
230+
statList += (sai_serialize_buffer_pool_stat(it) + list_item_delimiter);
241231
}
242-
string statListBufferPoolAndSharedHeadroomPool = statListBufferPoolOnly;
243-
for (const auto &it : bufferSharedHeadroomPoolWatermarkStatIds)
232+
if (!statList.empty())
244233
{
245-
statListBufferPoolAndSharedHeadroomPool += (sai_serialize_buffer_pool_stat(it) + list_item_delimiter);
246-
}
247-
if (!statListBufferPoolOnly.empty())
248-
{
249-
statListBufferPoolOnly.pop_back();
250-
}
251-
if (!statListBufferPoolAndSharedHeadroomPool.empty())
252-
{
253-
statListBufferPoolAndSharedHeadroomPool.pop_back();
234+
statList.pop_back();
254235
}
255236

256237
// Some platforms do not support buffer pool watermark clear operation on a particular pool
257238
// Invoke the SAI clear_stats API per pool to query the capability from the API call return status
258-
// Some platforms do not support shared headroom pool watermark read operation on a particular pool
259-
// Invoke the SAI get_buffer_pool_stats API per pool to query the capability from the API call return status.
260239
// We use bit mask to mark the clear watermark capability of each buffer pool. We use an unsigned int to place hold
261240
// these bits. This assumes the total number of buffer pools to be no greater than 32, which should satisfy all use cases.
262241
unsigned int noWmClrCapability = 0;
263-
unsigned int noSharedHeadroomPoolWmRdCapability = 0;
264242
unsigned int bitMask = 1;
265-
uint32_t size = static_cast<uint32_t>(bufferSharedHeadroomPoolWatermarkStatIds.size());
266-
vector<uint64_t> counterData(size);
267243
for (const auto &it : *(m_buffer_type_maps[APP_BUFFER_POOL_TABLE_NAME]))
268244
{
269-
sai_status_t status;
270-
// Check whether shared headroom pool water mark is supported
271-
status = sai_buffer_api->get_buffer_pool_stats(
272-
it.second.m_saiObjectId,
273-
size,
274-
reinterpret_cast<const sai_stat_id_t *>(bufferSharedHeadroomPoolWatermarkStatIds.data()),
275-
counterData.data());
276-
if (SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) || SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status)
277-
|| status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED)
278-
{
279-
SWSS_LOG_NOTICE("Read shared headroom pool watermark failed on %s, rv: %s", it.first.c_str(), sai_serialize_status(status).c_str());
280-
noSharedHeadroomPoolWmRdCapability |= bitMask;
281-
}
282-
283-
const auto &watermarkStatIds = (noSharedHeadroomPoolWmRdCapability & bitMask) ? bufferPoolWatermarkStatIds : bufferPoolAllWatermarkStatIds;
284-
285-
status = sai_buffer_api->clear_buffer_pool_stats(
245+
sai_status_t status = sai_buffer_api->clear_buffer_pool_stats(
286246
it.second.m_saiObjectId,
287-
static_cast<uint32_t>(watermarkStatIds.size()),
288-
reinterpret_cast<const sai_stat_id_t *>(watermarkStatIds.data()));
289-
if (SAI_STATUS_IS_ATTR_NOT_SUPPORTED(status) || SAI_STATUS_IS_ATTR_NOT_IMPLEMENTED(status)
290-
|| status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED)
247+
static_cast<uint32_t>(bufferPoolWatermarkStatIds.size()),
248+
reinterpret_cast<const sai_stat_id_t *>(bufferPoolWatermarkStatIds.data()));
249+
if (status == SAI_STATUS_NOT_SUPPORTED || status == SAI_STATUS_NOT_IMPLEMENTED)
291250
{
292251
SWSS_LOG_NOTICE("Clear watermark failed on %s, rv: %s", it.first.c_str(), sai_serialize_status(status).c_str());
293252
noWmClrCapability |= bitMask;
@@ -306,21 +265,11 @@ void BufferOrch::generateBufferPoolWatermarkCounterIdList(void)
306265

307266
// Push buffer pool watermark COUNTER_ID_LIST to FLEX_COUNTER_TABLE on a per buffer pool basis
308267
vector<FieldValueTuple> fvTuples;
309-
268+
fvTuples.emplace_back(BUFFER_POOL_COUNTER_ID_LIST, statList);
310269
bitMask = 1;
311270
for (const auto &it : *(m_buffer_type_maps[APP_BUFFER_POOL_TABLE_NAME]))
312271
{
313272
string key = BUFFER_POOL_WATERMARK_STAT_COUNTER_FLEX_COUNTER_GROUP ":" + sai_serialize_object_id(it.second.m_saiObjectId);
314-
fvTuples.clear();
315-
316-
if (noSharedHeadroomPoolWmRdCapability & bitMask)
317-
{
318-
fvTuples.emplace_back(BUFFER_POOL_COUNTER_ID_LIST, statListBufferPoolOnly);
319-
}
320-
else
321-
{
322-
fvTuples.emplace_back(BUFFER_POOL_COUNTER_ID_LIST, statListBufferPoolAndSharedHeadroomPool);
323-
}
324273

325274
if (noWmClrCapability)
326275
{
@@ -330,11 +279,15 @@ void BufferOrch::generateBufferPoolWatermarkCounterIdList(void)
330279
stats_mode = STATS_MODE_READ;
331280
}
332281
fvTuples.emplace_back(STATS_MODE_FIELD, stats_mode);
333-
}
334-
335-
m_flexCounterTable->set(key, fvTuples);
336282

337-
bitMask <<= 1;
283+
m_flexCounterTable->set(key, fvTuples);
284+
fvTuples.pop_back();
285+
bitMask <<= 1;
286+
}
287+
else
288+
{
289+
m_flexCounterTable->set(key, fvTuples);
290+
}
338291
}
339292

340293
m_isBufferPoolWatermarkCounterIdListGenerated = true;

0 commit comments

Comments
 (0)